From e8b66e3e9781aaad8535085007aa12b9a2a64742 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 6 Oct 2012 15:00:53 -0700 Subject: [PATCH] PollScheduler: move _main_loop to Scheduler --- pym/_emerge/PollScheduler.py | 30 ------------------------------ pym/_emerge/Scheduler.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/pym/_emerge/PollScheduler.py b/pym/_emerge/PollScheduler.py index dbf137f85..105943fd4 100644 --- a/pym/_emerge/PollScheduler.py +++ b/pym/_emerge/PollScheduler.py @@ -147,36 +147,6 @@ class PollScheduler(object): finally: self._scheduling = False - def _main_loop(self): - term_check_id = self.sched_iface.idle_add(self._termination_check) - loadavg_check_id = None - if self._max_load is not None: - # We have to schedule periodically, in case the load - # average has changed since the last call. - loadavg_check_id = self.sched_iface.timeout_add( - self._loadavg_latency, self._schedule) - - try: - # Populate initial event sources. Unless we're scheduling - # based on load average, we only need to do this once - # here, since it can be called during the loop from within - # event handlers. - self._schedule() - - # Loop while there are jobs to be scheduled. - while self._keep_scheduling(): - self.sched_iface.iteration() - - # Clean shutdown of previously scheduled jobs. In the - # case of termination, this allows for basic cleanup - # such as flushing of buffered output to logs. - while self._is_work_scheduled(): - self.sched_iface.iteration() - finally: - self.sched_iface.source_remove(term_check_id) - if loadavg_check_id is not None: - self.sched_iface.source_remove(loadavg_check_id) - def _is_work_scheduled(self): return bool(self._running_job_count()) diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 6a8793874..1814344de 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -1338,6 +1338,36 @@ class Scheduler(PollScheduler): blocker_db = self._blocker_db[pkg.root] blocker_db.discardBlocker(pkg) + def _main_loop(self): + term_check_id = self.sched_iface.idle_add(self._termination_check) + loadavg_check_id = None + if self._max_load is not None: + # We have to schedule periodically, in case the load + # average has changed since the last call. + loadavg_check_id = self.sched_iface.timeout_add( + self._loadavg_latency, self._schedule) + + try: + # Populate initial event sources. Unless we're scheduling + # based on load average, we only need to do this once + # here, since it can be called during the loop from within + # event handlers. + self._schedule() + + # Loop while there are jobs to be scheduled. + while self._keep_scheduling(): + self.sched_iface.iteration() + + # Clean shutdown of previously scheduled jobs. In the + # case of termination, this allows for basic cleanup + # such as flushing of buffered output to logs. + while self._is_work_scheduled(): + self.sched_iface.iteration() + finally: + self.sched_iface.source_remove(term_check_id) + if loadavg_check_id is not None: + self.sched_iface.source_remove(loadavg_check_id) + def _merge(self): if self._opts_no_background.intersection(self.myopts): -- 2.26.2