summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/_emerge/MetadataRegen.py4
-rw-r--r--pym/_emerge/PollScheduler.py22
-rw-r--r--pym/_emerge/QueueScheduler.py8
-rw-r--r--pym/_emerge/Scheduler.py24
-rw-r--r--pym/portage/tests/process/test_poll.py2
5 files changed, 31 insertions, 29 deletions
diff --git a/pym/_emerge/MetadataRegen.py b/pym/_emerge/MetadataRegen.py
index 813ebc93e..07fd397dd 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 983bfa9cc..b9188f769 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 e115ba1aa..99cfb23a8 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 afcdda8e9..d2d6ad805 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 22c9c2d1a..8f5d738dc 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)