PollScheduler: move _main_loop to Scheduler
authorZac Medico <zmedico@gentoo.org>
Sat, 6 Oct 2012 22:00:53 +0000 (15:00 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 6 Oct 2012 22:00:53 +0000 (15:00 -0700)
pym/_emerge/PollScheduler.py
pym/_emerge/Scheduler.py

index dbf137f85a4d3c8b2f7114b404901a3a7b9b4531..105943fd485f7a3c0e468e94540d60eedf80b344 100644 (file)
@@ -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())
 
index 6a87938744d763e3c661e551e89209c21319cf29..1814344de984da141b99231c1b9ddfb2e32256fc 100644 (file)
@@ -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):