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/_emerge/
@ 2011-12-15 23:55 Zac Medico
  0 siblings, 0 replies; 4+ messages in thread
From: Zac Medico @ 2011-12-15 23:55 UTC (permalink / raw
  To: gentoo-commits

commit:     915348ce34fc499ac295b8f0ffee9f0829803542
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 15 23:55:42 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Dec 15 23:55:42 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=915348ce

test_poll: test different sizes, and pty too

---
 pym/_emerge/PipeReader.py              |    4 +++-
 pym/portage/tests/process/test_poll.py |   23 +++++++++++++++++------
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/pym/_emerge/PipeReader.py b/pym/_emerge/PipeReader.py
index af8cfdd..78acb72 100644
--- a/pym/_emerge/PipeReader.py
+++ b/pym/_emerge/PipeReader.py
@@ -64,7 +64,9 @@ class PipeReader(AbstractPollTask):
 				try:
 					data = os.read(fd, self._bufsize)
 				except OSError as e:
-					if e.errno not in (errno.EAGAIN,):
+					# EIO happens with pty on Linux after the
+					# slave end of the pty has been closed.
+					if e.errno not in (errno.EAGAIN, errno.EIO):
 						raise
 					break
 				else:

diff --git a/pym/portage/tests/process/test_poll.py b/pym/portage/tests/process/test_poll.py
index c3b50d4..e7a4702 100644
--- a/pym/portage/tests/process/test_poll.py
+++ b/pym/portage/tests/process/test_poll.py
@@ -3,25 +3,28 @@
 
 from portage import os
 from portage.tests import TestCase
+from portage.util._pty import _create_pty_or_pipe
 from _emerge.PollScheduler import PollScheduler
 from _emerge.PipeReader import PipeReader
 from _emerge.SpawnProcess import SpawnProcess
 
 class PipeReaderTestCase(TestCase):
 
-	def testPipeReader(self):
+	def _testPipeReader(self, test_string, use_pty):
 		"""
 		Use a poll loop to read data from a pipe and assert that
 		the data written to the pipe is identical to the data
 		read from the pipe.
 		"""
 
-		test_string = 2 * "blah blah blah\n"
-
 		scheduler = PollScheduler().sched_iface
-		master_fd, slave_fd = os.pipe()
+		if use_pty:
+			got_pty, master_fd, slave_fd = _create_pty_or_pipe()
+		else:
+			got_pty = False
+			master_fd, slave_fd = os.pipe()
 		master_file = os.fdopen(master_fd, 'rb', 0)
-		slave_file = os.fdopen(slave_fd, 'wb')
+		slave_file = os.fdopen(slave_fd, 'wb', 0)
 		producer = SpawnProcess(
 			args=["bash", "-c", "echo -n '%s'" % test_string],
 			env=os.environ, fd_pipes={1:slave_fd},
@@ -44,4 +47,12 @@ class PipeReaderTestCase(TestCase):
 		self.assertEqual(consumer.returncode, os.EX_OK)
 
 		output = consumer.getvalue().decode('ascii', 'replace')
-		self.assertEqual(test_string, output)
+		return (output, got_pty)
+
+	def testPipeReader(self):
+		for use_pty in (False, True):
+			for x in (1, 2, 5, 6, 7, 8, 2**5, 2**10, 2**12, 2**13, 2**14):
+				test_string = x * "a"
+				output, got_pty = self._testPipeReader(test_string, use_pty)
+				self.assertEqual(test_string, output,
+					"x = %s, use_pty = %s, got_pty = %s" % (x, use_pty, got_pty))



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

* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/process/, pym/_emerge/
@ 2011-12-16  2:03 Zac Medico
  0 siblings, 0 replies; 4+ messages in thread
From: Zac Medico @ 2011-12-16  2:03 UTC (permalink / raw
  To: gentoo-commits

commit:     30d2d0a9db486c5a70848ad5d27b37a3ec48f271
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 16 02:02:32 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Dec 16 02:02:32 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=30d2d0a9

SpawnProcess: work around array.fromfile() bugs

When I extended test_poll to test SpawnProcess array.fromfile() usage,
it exposed bugs in array.fromfile() that I couldn't find a way to
handle. So, use os.read() instead.

---
 pym/_emerge/AbstractPollTask.py        |   23 +++++++++--
 pym/_emerge/SpawnProcess.py            |   31 ++++++++++-----
 pym/portage/tests/process/test_poll.py |   66 +++++++++++++++++++++++++++++--
 3 files changed, 100 insertions(+), 20 deletions(-)

diff --git a/pym/_emerge/AbstractPollTask.py b/pym/_emerge/AbstractPollTask.py
index f7f3a95..ea13587 100644
--- a/pym/_emerge/AbstractPollTask.py
+++ b/pym/_emerge/AbstractPollTask.py
@@ -2,7 +2,9 @@
 # Distributed under the terms of the GNU General Public License v2
 
 import array
+import errno
 import logging
+import os
 
 from portage.util import writemsg_level
 from _emerge.AsynchronousTask import AsynchronousTask
@@ -20,7 +22,7 @@ class AbstractPollTask(AsynchronousTask):
 	def isAlive(self):
 		return bool(self._registered)
 
-	def _read_buf(self, f, event):
+	def _read_buf(self, fd, event):
 		"""
 		| POLLIN | RETURN
 		| BIT    | VALUE
@@ -32,13 +34,26 @@ class AbstractPollTask(AsynchronousTask):
 		| ---------------------------------------------------
 		| 0      | None
 		"""
+		# NOTE: array.fromfile() is no longer used here because it has
+		# bugs in all known versions of Python (including Python 2.7
+		# and Python 3.2).
 		buf = None
 		if event & PollConstants.POLLIN:
 			buf = array.array('B')
 			try:
-				buf.fromfile(f, self._bufsize)
-			except (EOFError, IOError):
-				pass
+				# Python >=3.2
+				frombytes = buf.frombytes
+			except AttributeError:
+				frombytes = buf.fromstring
+			try:
+				frombytes(os.read(fd, self._bufsize))
+			except OSError as e:
+				# EIO happens with pty on Linux after the
+				# slave end of the pty has been closed.
+				if e.errno not in (errno.EAGAIN, errno.EIO):
+					raise
+				buf = None
+
 		return buf
 
 	def _unregister(self):

diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py
index 84493fe..c2f4928 100644
--- a/pym/_emerge/SpawnProcess.py
+++ b/pym/_emerge/SpawnProcess.py
@@ -165,11 +165,20 @@ class SpawnProcess(SubProcess):
 	def _output_handler(self, fd, event):
 
 		files = self._files
-		buf = self._read_buf(files.process, event)
+		while True:
+			buf = self._read_buf(fd, event)
 
-		if buf is not None:
+			if buf is None:
+				# not a POLLIN event, EAGAIN, etc...
+				break
 
-			if buf:
+			if not buf:
+				# EOF
+				self._unregister()
+				self.wait()
+				break
+
+			else:
 				if not self.background:
 					write_successful = False
 					failures = 0
@@ -217,9 +226,6 @@ class SpawnProcess(SubProcess):
 						data = buf.tostring()
 					files.log.write(data)
 				files.log.flush()
-			else:
-				self._unregister()
-				self.wait()
 
 		self._unregister_if_appropriate(event)
 
@@ -230,15 +236,18 @@ class SpawnProcess(SubProcess):
 		monitor the process from inside a poll() loop.
 		"""
 
-		buf = self._read_buf(self._files.process, event)
+		while True:
+			buf = self._read_buf(fd, event)
 
-		if buf is not None:
+			if buf is None:
+				# not a POLLIN event, EAGAIN, etc...
+				break
 
-			if buf:
-				pass
-			else:
+			if not buf:
+				# EOF
 				self._unregister()
 				self.wait()
+				break
 
 		self._unregister_if_appropriate(event)
 

diff --git a/pym/portage/tests/process/test_poll.py b/pym/portage/tests/process/test_poll.py
index e7a4702..9b1f9cb 100644
--- a/pym/portage/tests/process/test_poll.py
+++ b/pym/portage/tests/process/test_poll.py
@@ -1,6 +1,8 @@
 # Copyright 1998-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+import tempfile
+
 from portage import os
 from portage.tests import TestCase
 from portage.util._pty import _create_pty_or_pipe
@@ -8,6 +10,13 @@ from _emerge.PollScheduler import PollScheduler
 from _emerge.PipeReader import PipeReader
 from _emerge.SpawnProcess import SpawnProcess
 
+class _SpawnProcessPty(SpawnProcess):
+	__slots__ = ("got_pty",)
+	def _pipe(self, fd_pipes):
+		got_pty, master_fd, slave_fd = _create_pty_or_pipe()
+		self.got_pty = got_pty
+		return (master_fd, slave_fd)
+
 class PipeReaderTestCase(TestCase):
 
 	def _testPipeReader(self, test_string, use_pty):
@@ -49,10 +58,57 @@ class PipeReaderTestCase(TestCase):
 		output = consumer.getvalue().decode('ascii', 'replace')
 		return (output, got_pty)
 
+	def _testPipeReaderArray(self, test_string, use_pty):
+		"""
+		Use a poll loop to read data from a pipe and assert that
+		the data written to the pipe is identical to the data
+		read from the pipe.
+		"""
+
+		scheduler = PollScheduler().sched_iface
+		if use_pty:
+			spawn_process = _SpawnProcessPty
+		else:
+			spawn_process = SpawnProcess
+
+		fd, logfile = tempfile.mkstemp()
+		os.close(fd)
+		producer = spawn_process(
+			background=True,
+			args=["bash", "-c", "echo -n '%s'" % test_string],
+			env=os.environ,
+			scheduler=scheduler, logfile=logfile)
+
+		try:
+			producer.start()
+			scheduler.schedule()
+			self.assertEqual(producer.returncode, os.EX_OK)
+
+			if use_pty:
+				got_pty = producer.got_pty
+			else:
+				got_pty = False
+
+			with open(logfile, 'rb') as f:
+				output = f.read().decode('ascii')
+			return (output, got_pty)
+		finally:
+			try:
+				os.unlink(logfile)
+			except OSError:
+				pass
+
 	def testPipeReader(self):
 		for use_pty in (False, True):
-			for x in (1, 2, 5, 6, 7, 8, 2**5, 2**10, 2**12, 2**13, 2**14):
-				test_string = x * "a"
-				output, got_pty = self._testPipeReader(test_string, use_pty)
-				self.assertEqual(test_string, output,
-					"x = %s, use_pty = %s, got_pty = %s" % (x, use_pty, got_pty))
+			for use_array in (False, True):
+				for x in (1, 2, 5, 6, 7, 8, 2**5, 2**10, 2**12, 2**13, 2**14):
+					test_string = x * "a"
+					if use_array:
+						method = self._testPipeReaderArray
+					else:
+						method = self._testPipeReader
+					output, got_pty = method(test_string, use_pty)
+					self.assertEqual(test_string, output,
+						"x = %s, len(output) = %s, use_array = %s, "
+						"use_pty = %s, got_pty = %s" %
+						(x, len(output), use_array, use_pty, got_pty))



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

* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/process/, pym/_emerge/
@ 2011-12-16 21:56 Zac Medico
  0 siblings, 0 replies; 4+ messages in thread
From: Zac Medico @ 2011-12-16 21:56 UTC (permalink / raw
  To: gentoo-commits

commit:     47247149a48d8b4267ad849ff10924e7b6a6f3e2
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 16 21:56:03 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Dec 16 21:56:03 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=47247149

test_poll: fix array test

Since SpawnProcess no longer uses array, add conditional array support
to PipeReader and use that for tests.

---
 pym/_emerge/AbstractPollTask.py        |   49 +++++++++++++++++++
 pym/_emerge/PipeReader.py              |   29 ++++++++++-
 pym/portage/tests/process/test_poll.py |   82 ++++++++------------------------
 3 files changed, 96 insertions(+), 64 deletions(-)

diff --git a/pym/_emerge/AbstractPollTask.py b/pym/_emerge/AbstractPollTask.py
index b3c0b2d..83e6c7b 100644
--- a/pym/_emerge/AbstractPollTask.py
+++ b/pym/_emerge/AbstractPollTask.py
@@ -1,6 +1,7 @@
 # Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+import array
 import errno
 import logging
 import os
@@ -21,6 +22,54 @@ class AbstractPollTask(AsynchronousTask):
 	def isAlive(self):
 		return bool(self._registered)
 
+	def _read_array(self, f, event):
+		"""
+		NOTE: array.fromfile() is used here only for testing purposes,
+		because it has bugs in all known versions of Python (including
+		Python 2.7 and Python 3.2).
+
+		| POLLIN | RETURN
+		| BIT    | VALUE
+		| ---------------------------------------------------
+		| 1      | Read self._bufsize into an instance of
+		|        | array.array('B') and return it, ignoring
+		|        | EOFError and IOError. An empty array
+		|        | indicates EOF.
+		| ---------------------------------------------------
+		| 0      | None
+		"""
+		buf = None
+		if event & PollConstants.POLLIN:
+			buf = array.array('B')
+			try:
+				buf.fromfile(f, self._bufsize)
+			except EOFError:
+				pass
+			except TypeError:
+				# Python 3.2:
+				# TypeError: read() didn't return bytes
+				pass
+			except IOError as e:
+				# EIO happens with pty on Linux after the
+				# slave end of the pty has been closed.
+				if e.errno == errno.EIO:
+					# EOF: return empty string of bytes
+					pass
+				elif e.errno == errno.EAGAIN:
+					# EAGAIN: return None
+					buf = None
+				else:
+					raise
+
+		if buf is not None:
+			try:
+				# Python >=3.2
+				buf = buf.tobytes()
+			except AttributeError:
+				buf = buf.tostring()
+
+		return buf
+
 	def _read_buf(self, fd, event):
 		"""
 		| POLLIN | RETURN

diff --git a/pym/_emerge/PipeReader.py b/pym/_emerge/PipeReader.py
index 9fedbff..b162fe5 100644
--- a/pym/_emerge/PipeReader.py
+++ b/pym/_emerge/PipeReader.py
@@ -15,16 +15,22 @@ class PipeReader(AbstractPollTask):
 	"""
 
 	__slots__ = ("input_files",) + \
-		("_read_data", "_reg_ids")
+		("_read_data", "_reg_ids", "_use_array")
 
 	def _start(self):
 		self._reg_ids = set()
 		self._read_data = []
+
+		if self._use_array:
+			output_handler = self._array_output_handler
+		else:
+			output_handler = self._output_handler
+
 		for k, f in self.input_files.items():
 			fcntl.fcntl(f.fileno(), fcntl.F_SETFL,
 				fcntl.fcntl(f.fileno(), fcntl.F_GETFL) | os.O_NONBLOCK)
 			self._reg_ids.add(self.scheduler.register(f.fileno(),
-				self._registered_events, self._output_handler))
+				self._registered_events, output_handler))
 		self._registered = True
 
 	def isAlive(self):
@@ -68,6 +74,25 @@ class PipeReader(AbstractPollTask):
 
 		self._unregister_if_appropriate(event)
 
+	def _array_output_handler(self, fd, event):
+
+		for f in self.input_files.values():
+			if f.fileno() == fd:
+				break
+
+		while True:
+			data = self._read_array(f, event)
+			if data is None:
+				break
+			if data:
+				self._read_data.append(data)
+			else:
+				self._unregister()
+				self.wait()
+				break
+
+		self._unregister_if_appropriate(event)
+
 	def _unregister(self):
 		"""
 		Unregister from the scheduler and close open files.

diff --git a/pym/portage/tests/process/test_poll.py b/pym/portage/tests/process/test_poll.py
index 9b1f9cb..f1ddcb3 100644
--- a/pym/portage/tests/process/test_poll.py
+++ b/pym/portage/tests/process/test_poll.py
@@ -1,8 +1,6 @@
 # Copyright 1998-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-import tempfile
-
 from portage import os
 from portage.tests import TestCase
 from portage.util._pty import _create_pty_or_pipe
@@ -10,15 +8,10 @@ from _emerge.PollScheduler import PollScheduler
 from _emerge.PipeReader import PipeReader
 from _emerge.SpawnProcess import SpawnProcess
 
-class _SpawnProcessPty(SpawnProcess):
-	__slots__ = ("got_pty",)
-	def _pipe(self, fd_pipes):
-		got_pty, master_fd, slave_fd = _create_pty_or_pipe()
-		self.got_pty = got_pty
-		return (master_fd, slave_fd)
-
 class PipeReaderTestCase(TestCase):
 
+	_use_array = False
+
 	def _testPipeReader(self, test_string, use_pty):
 		"""
 		Use a poll loop to read data from a pipe and assert that
@@ -43,7 +36,7 @@ class PipeReaderTestCase(TestCase):
 
 		consumer = PipeReader(
 			input_files={"producer" : master_file},
-			scheduler=scheduler)
+			scheduler=scheduler, _use_array=self._use_array)
 
 		consumer.start()
 
@@ -58,57 +51,22 @@ class PipeReaderTestCase(TestCase):
 		output = consumer.getvalue().decode('ascii', 'replace')
 		return (output, got_pty)
 
-	def _testPipeReaderArray(self, test_string, use_pty):
-		"""
-		Use a poll loop to read data from a pipe and assert that
-		the data written to the pipe is identical to the data
-		read from the pipe.
-		"""
-
-		scheduler = PollScheduler().sched_iface
-		if use_pty:
-			spawn_process = _SpawnProcessPty
-		else:
-			spawn_process = SpawnProcess
-
-		fd, logfile = tempfile.mkstemp()
-		os.close(fd)
-		producer = spawn_process(
-			background=True,
-			args=["bash", "-c", "echo -n '%s'" % test_string],
-			env=os.environ,
-			scheduler=scheduler, logfile=logfile)
-
-		try:
-			producer.start()
-			scheduler.schedule()
-			self.assertEqual(producer.returncode, os.EX_OK)
-
-			if use_pty:
-				got_pty = producer.got_pty
-			else:
-				got_pty = False
-
-			with open(logfile, 'rb') as f:
-				output = f.read().decode('ascii')
-			return (output, got_pty)
-		finally:
-			try:
-				os.unlink(logfile)
-			except OSError:
-				pass
-
 	def testPipeReader(self):
 		for use_pty in (False, True):
-			for use_array in (False, True):
-				for x in (1, 2, 5, 6, 7, 8, 2**5, 2**10, 2**12, 2**13, 2**14):
-					test_string = x * "a"
-					if use_array:
-						method = self._testPipeReaderArray
-					else:
-						method = self._testPipeReader
-					output, got_pty = method(test_string, use_pty)
-					self.assertEqual(test_string, output,
-						"x = %s, len(output) = %s, use_array = %s, "
-						"use_pty = %s, got_pty = %s" %
-						(x, len(output), use_array, use_pty, got_pty))
+			for x in (1, 2, 5, 6, 7, 8, 2**5, 2**10, 2**12, 2**13, 2**14):
+				test_string = x * "a"
+				output, got_pty = self._testPipeReader(test_string, use_pty)
+				self.assertEqual(test_string, output,
+					"x = %s, len(output) = %s, "
+					"use_pty = %s, got_pty = %s" %
+					(x, len(output), use_pty, got_pty))
+
+class PipeReaderArrayTestCase(PipeReaderTestCase):
+
+	_use_array = True
+
+	def __init__(self, *args, **kwargs):
+		super(PipeReaderArrayTestCase, self).__init__(*args, **kwargs)
+		# http://bugs.python.org/issue5380
+		# https://bugs.pypy.org/issue956
+		self.todo = True



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

* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/process/, pym/_emerge/
@ 2012-02-08 21:04 Zac Medico
  0 siblings, 0 replies; 4+ messages in thread
From: Zac Medico @ 2012-02-08 21:04 UTC (permalink / raw
  To: gentoo-commits

commit:     49c4585425ee161cf82805f28fb497167856cc01
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Feb  8 21:04:33 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Feb  8 21:04:33 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=49c45854

PollScheduler: don't inherit EventLoop

---
 pym/_emerge/MetadataRegen.py           |    4 ++--
 pym/_emerge/PollScheduler.py           |   22 ++++++++++++----------
 pym/_emerge/QueueScheduler.py          |    8 ++++----
 pym/_emerge/Scheduler.py               |   24 ++++++++++++------------
 pym/portage/tests/process/test_poll.py |    2 +-
 5 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/pym/_emerge/MetadataRegen.py b/pym/_emerge/MetadataRegen.py
index 813ebc9..07fd397 100644
--- a/pym/_emerge/MetadataRegen.py
+++ b/pym/_emerge/MetadataRegen.py
@@ -88,10 +88,10 @@ class MetadataRegen(PollScheduler):
 		dead_nodes = {}
 
 		while self._schedule():
-			self._poll_loop()
+			self.sched_iface.run()
 
 		while self._jobs:
-			self._poll_loop()
+			self.sched_iface.run()
 
 		if self._terminated_tasks:
 			self.returncode = 1

diff --git a/pym/_emerge/PollScheduler.py b/pym/_emerge/PollScheduler.py
index 983bfa9..b9188f7 100644
--- a/pym/_emerge/PollScheduler.py
+++ b/pym/_emerge/PollScheduler.py
@@ -359,11 +359,11 @@ class EventLoop(object):
 		del self._poll_event_handlers[f]
 		return True
 
-class PollScheduler(EventLoop):
+class PollScheduler(object):
 
 	class _sched_iface_class(SlotObject):
 		__slots__ = ("idle_add", "io_add_watch", "iteration",
-			"output", "register", "schedule",
+			"output", "register", "run",
 			"source_remove", "timeout_add", "unregister")
 
 	def __init__(self):
@@ -375,16 +375,18 @@ class PollScheduler(EventLoop):
 		self._jobs = 0
 		self._scheduling = False
 		self._background = False
+		self._event_loop = EventLoop()
+		self._event_loop._schedule = self._schedule
 		self.sched_iface = self._sched_iface_class(
-			idle_add=self._idle_add,
-			io_add_watch=self._register,
-			iteration=self._iteration,
+			idle_add=self._event_loop._idle_add,
+			io_add_watch=self._event_loop._register,
+			iteration=self._event_loop._iteration,
 			output=self._task_output,
-			register=self._register,
-			schedule=self._poll_loop,
-			source_remove=self._unregister,
-			timeout_add=self._timeout_add,
-			unregister=self._unregister)
+			register=self._event_loop._register,
+			run=self._event_loop._poll_loop,
+			source_remove=self._event_loop._unregister,
+			timeout_add=self._event_loop._timeout_add,
+			unregister=self._event_loop._unregister)
 
 	def terminate(self):
 		"""

diff --git a/pym/_emerge/QueueScheduler.py b/pym/_emerge/QueueScheduler.py
index e115ba1..99cfb23 100644
--- a/pym/_emerge/QueueScheduler.py
+++ b/pym/_emerge/QueueScheduler.py
@@ -40,22 +40,22 @@ class QueueScheduler(PollScheduler):
 				timeout_callback.timed_out = True
 				return False
 			timeout_callback.timed_out = False
-			timeout_callback.timeout_id = self._timeout_add(
+			timeout_callback.timeout_id = self.sched_iface.timeout_add(
 				timeout, timeout_callback)
 
 		try:
 
 			while not (timeout_callback is not None and
 				timeout_callback.timed_out) and self._schedule():
-				self._iteration()
+				self.sched_iface.iteration()
 
 			while not (timeout_callback is not None and
 				timeout_callback.timed_out) and self._running_job_count():
-				self._iteration()
+				self.sched_iface.iteration()
 
 		finally:
 			if timeout_callback is not None:
-				self._unregister(timeout_callback.timeout_id)
+				self.sched_iface.unregister(timeout_callback.timeout_id)
 
 	def _schedule_tasks(self):
 		"""

diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py
index afcdda8..d2d6ad8 100644
--- a/pym/_emerge/Scheduler.py
+++ b/pym/_emerge/Scheduler.py
@@ -196,8 +196,8 @@ class Scheduler(PollScheduler):
 
 		self._status_display = JobStatusDisplay(
 			xterm_titles=('notitles' not in settings.features))
-		self._idle_add(self._idle_schedule)
-		self._timeout_add(self._max_display_latency,
+		self.sched_iface.idle_add(self._idle_schedule)
+		self.sched_iface.timeout_add(self._max_display_latency,
 			self._status_display.display)
 		self._max_load = myopts.get("--load-average")
 		max_jobs = myopts.get("--jobs")
@@ -219,16 +219,16 @@ class Scheduler(PollScheduler):
 			schedule=self._schedule_fetch)
 		self._sched_iface = self._iface_class(
 			fetch=fetch_iface, output=self._task_output,
-			idle_add=self._idle_add,
-			io_add_watch=self._register,
-			iteration=self._iteration,
-			register=self._register,
-			schedule=self._poll_loop,
+			idle_add=self._event_loop._idle_add,
+			io_add_watch=self._event_loop._register,
+			iteration=self._event_loop._iteration,
+			register=self._event_loop._register,
+			schedule=self._event_loop._poll_loop,
 			scheduleSetup=self._schedule_setup,
 			scheduleUnpack=self._schedule_unpack,
-			source_remove=self._unregister,
-			timeout_add=self._timeout_add,
-			unregister=self._unregister)
+			source_remove=self._event_loop._unregister,
+			timeout_add=self._event_loop._timeout_add,
+			unregister=self._event_loop._unregister)
 
 		self._prefetchers = weakref.WeakValueDictionary()
 		self._pkg_queue = []
@@ -1500,13 +1500,13 @@ class Scheduler(PollScheduler):
 			self._set_max_jobs(1)
 
 		while self._schedule():
-			self._poll_loop()
+			self.sched_iface.run()
 
 		while True:
 			self._schedule()
 			if not self._is_work_scheduled():
 				break
-			self._poll_loop()
+			self.sched_iface.run()
 
 	def _keep_scheduling(self):
 		return bool(not self._terminated_tasks and self._pkg_queue and \

diff --git a/pym/portage/tests/process/test_poll.py b/pym/portage/tests/process/test_poll.py
index 22c9c2d..8f5d738 100644
--- a/pym/portage/tests/process/test_poll.py
+++ b/pym/portage/tests/process/test_poll.py
@@ -55,7 +55,7 @@ class PipeReaderTestCase(TestCase):
 		# is necessary to avoid "ResourceWarning: unclosed file"
 		# warnings since Python 3.2 (and also ensures that we
 		# don't leave any zombie child processes).
-		scheduler.schedule()
+		scheduler.run()
 		self.assertEqual(producer.returncode, os.EX_OK)
 		self.assertEqual(consumer.returncode, os.EX_OK)
 



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

end of thread, other threads:[~2012-02-08 21:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-15 23:55 [gentoo-commits] proj/portage:master commit in: pym/portage/tests/process/, pym/_emerge/ Zac Medico
  -- strict thread matches above, loose matches on Subject: below --
2011-12-16  2:03 Zac Medico
2011-12-16 21:56 Zac Medico
2012-02-08 21:04 Zac Medico

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