public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/process/, pym/portage/util/_async/
@ 2013-01-07  9:16 Zac Medico
  0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2013-01-07  9:16 UTC (permalink / raw
  To: gentoo-commits

commit:     e132ec4f753b9df4769f7e58dfc661617c7375b8
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  7 09:16:11 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jan  7 09:16:11 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e132ec4f

PipeLogger: handle file object for input_fd

---
 pym/portage/tests/process/test_PopenProcess.py |    7 ++-----
 pym/portage/util/_async/PipeLogger.py          |   16 ++++++++++++----
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/pym/portage/tests/process/test_PopenProcess.py b/pym/portage/tests/process/test_PopenProcess.py
index 5ede164..88da0b3 100644
--- a/pym/portage/tests/process/test_PopenProcess.py
+++ b/pym/portage/tests/process/test_PopenProcess.py
@@ -1,4 +1,4 @@
-# Copyright 2012 Gentoo Foundation
+# Copyright 2012-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import subprocess
@@ -53,12 +53,9 @@ class PopenPipeTestCase(TestCase):
 		try:
 
 			consumer = PipeLogger(background=True,
-				input_fd=os.dup(producer.proc.stdout.fileno()),
+				input_fd=producer.proc.stdout,
 				log_file_path=log_file_path)
 
-			# Close the stdout pipe, since we duplicated it, and it
-			# must be closed in order to avoid a ResourceWarning.
-			producer.proc.stdout.close()
 			producer.pipe_reader = consumer
 
 			producer.start()

diff --git a/pym/portage/util/_async/PipeLogger.py b/pym/portage/util/_async/PipeLogger.py
index 5464879..d0b1323 100644
--- a/pym/portage/util/_async/PipeLogger.py
+++ b/pym/portage/util/_async/PipeLogger.py
@@ -46,10 +46,15 @@ class PipeLogger(AbstractPollTask):
 		else:
 			fcntl_flags |= fcntl.FD_CLOEXEC
 
-		fcntl.fcntl(self.input_fd, fcntl.F_SETFL,
-			fcntl.fcntl(self.input_fd, fcntl.F_GETFL) | fcntl_flags)
+		if isinstance(self.input_fd, int):
+			fd = self.input_fd
+		else:
+			fd = self.input_fd.fileno()
+
+		fcntl.fcntl(fd, fcntl.F_SETFL,
+			fcntl.fcntl(fd, fcntl.F_GETFL) | fcntl_flags)
 
-		self._reg_id = self.scheduler.io_add_watch(self.input_fd,
+		self._reg_id = self.scheduler.io_add_watch(fd,
 			self._registered_events, self._output_handler)
 		self._registered = True
 
@@ -133,7 +138,10 @@ class PipeLogger(AbstractPollTask):
 			self._reg_id = None
 
 		if self.input_fd is not None:
-			os.close(self.input_fd)
+			if isinstance(self.input_fd, int):
+				os.close(self.input_fd)
+			else:
+				self.input_fd.close()
 			self.input_fd = None
 
 		if self.stdout_fd is not None:


^ permalink raw reply related	[flat|nested] 2+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/process/, pym/portage/util/_async/
@ 2012-12-28  6:30 Zac Medico
  0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2012-12-28  6:30 UTC (permalink / raw
  To: gentoo-commits

commit:     df7f1d3e00a9f0de1c631422b91cac3d074ddc0f
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 28 06:30:07 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Dec 28 06:30:07 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=df7f1d3e

PipeReaderBlockingIO handle threading ImportError

---
 .../tests/process/test_PopenProcessBlockingIO.py   |    1 +
 pym/portage/util/_async/PipeReaderBlockingIO.py    |    6 +++++-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/pym/portage/tests/process/test_PopenProcessBlockingIO.py b/pym/portage/tests/process/test_PopenProcessBlockingIO.py
index 9cdad32..9ee291a 100644
--- a/pym/portage/tests/process/test_PopenProcessBlockingIO.py
+++ b/pym/portage/tests/process/test_PopenProcessBlockingIO.py
@@ -6,6 +6,7 @@ import subprocess
 try:
 	import threading
 except ImportError:
+	# dummy_threading will not suffice
 	threading = None
 
 from portage import os

diff --git a/pym/portage/util/_async/PipeReaderBlockingIO.py b/pym/portage/util/_async/PipeReaderBlockingIO.py
index 8ce2ec5..b06adf6 100644
--- a/pym/portage/util/_async/PipeReaderBlockingIO.py
+++ b/pym/portage/util/_async/PipeReaderBlockingIO.py
@@ -1,7 +1,11 @@
 # Copyright 2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-import threading
+try:
+	import threading
+except ImportError:
+	# dummy_threading will not suffice
+	threading = None
 
 from portage import os
 from _emerge.AbstractPollTask import AbstractPollTask


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-07  9:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-07  9:16 [gentoo-commits] proj/portage:master commit in: pym/portage/tests/process/, pym/portage/util/_async/ Zac Medico
  -- strict thread matches above, loose matches on Subject: below --
2012-12-28  6:30 Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox