Make Scheduler._schedule_tasks() use a loop to ensure that _merge_wait_queue
authorZac Medico <zmedico@gentoo.org>
Thu, 8 Jul 2010 00:56:14 +0000 (17:56 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 8 Jul 2010 00:56:14 +0000 (17:56 -0700)
is emptied whenever possible.

pym/_emerge/Scheduler.py

index a6368fcb40d1f5526d8e7e78e45340a92cdbec1e..94391fc8dbc53e85633dcfbcd666df5c880b452f 100644 (file)
@@ -1459,35 +1459,37 @@ class Scheduler(PollScheduler):
 
        def _schedule_tasks(self):
 
-               # When the number of jobs drops to zero, process all waiting merges.
-               if not self._jobs and self._merge_wait_queue:
-                       for task in self._merge_wait_queue:
-                               task.addExitListener(self._merge_wait_exit_handler)
-                               self._task_queues.merge.add(task)
-                       self._status_display.merges = len(self._task_queues.merge)
-                       self._merge_wait_scheduled.extend(self._merge_wait_queue)
-                       del self._merge_wait_queue[:]
-
-               self._schedule_tasks_imp()
-               self._status_display.display()
-
-               state_change = 0
-               for q in self._task_queues.values():
-                       if q.schedule():
-                               state_change += 1
+               while True:
 
-               # Cancel prefetchers if they're the only reason
-               # the main poll loop is still running.
-               if self._failed_pkgs and not self._build_opts.fetchonly and \
-                       not self._is_work_scheduled() and \
-                       self._task_queues.fetch:
-                       self._task_queues.fetch.clear()
-                       state_change += 1
+                       # When the number of jobs drops to zero, process all waiting merges.
+                       if not self._jobs and self._merge_wait_queue:
+                               for task in self._merge_wait_queue:
+                                       task.addExitListener(self._merge_wait_exit_handler)
+                                       self._task_queues.merge.add(task)
+                               self._status_display.merges = len(self._task_queues.merge)
+                               self._merge_wait_scheduled.extend(self._merge_wait_queue)
+                               del self._merge_wait_queue[:]
 
-               if state_change:
                        self._schedule_tasks_imp()
                        self._status_display.display()
 
+                       state_change = 0
+                       for q in self._task_queues.values():
+                               if q.schedule():
+                                       state_change += 1
+
+                       # Cancel prefetchers if they're the only reason
+                       # the main poll loop is still running.
+                       if self._failed_pkgs and not self._build_opts.fetchonly and \
+                               not self._is_work_scheduled() and \
+                               self._task_queues.fetch:
+                               self._task_queues.fetch.clear()
+                               state_change += 1
+
+                       if not (state_change or \
+                               (not self._jobs and self._merge_wait_queue)):
+                               break
+
                return self._keep_scheduling()
 
        def _job_delay(self):