From: Zac Medico Date: Thu, 9 Feb 2012 00:33:14 +0000 (-0800) Subject: SequentialTaskQueue: schedule automatically X-Git-Tag: v2.2.0_alpha86~38 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4620d6aba1c5c10344e311585516ee43819b703c;p=portage.git SequentialTaskQueue: schedule automatically This is needed to compensate for the removal of _idle_schedule in commit 8c1fcf5a9ba9fa4d406a4d0cc284fe73a84f5a63, so that the Scheduler's task queues operate without needing their schedule methods called inside Scheduler._schedule_tasks(). --- diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index ee7a02ca3..d3f77611d 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -1514,6 +1514,8 @@ class Scheduler(PollScheduler): while True: + state_change = 0 + # When the number of jobs and merges drops to zero, # process a single merge from _merge_wait_queue if # it's not empty. We only process one since these are @@ -1524,17 +1526,15 @@ class Scheduler(PollScheduler): not self._task_queues.merge): task = self._merge_wait_queue.popleft() task.addExitListener(self._merge_wait_exit_handler) + self._merge_wait_scheduled.append(task) self._task_queues.merge.add(task) self._status_display.merges = len(self._task_queues.merge) - self._merge_wait_scheduled.append(task) + state_change += 1 - self._schedule_tasks_imp() - self._status_display.display() + if self._schedule_tasks_imp(): + state_change += 1 - state_change = 0 - for q in self._task_queues.values(): - if q.schedule(): - state_change += 1 + self._status_display.display() # Cancel prefetchers if they're the only reason # the main poll loop is still running. diff --git a/pym/_emerge/SequentialTaskQueue.py b/pym/_emerge/SequentialTaskQueue.py index c1c98c411..88ac844d9 100644 --- a/pym/_emerge/SequentialTaskQueue.py +++ b/pym/_emerge/SequentialTaskQueue.py @@ -1,4 +1,4 @@ -# Copyright 1999-2009 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import sys @@ -20,10 +20,12 @@ class SequentialTaskQueue(SlotObject): def add(self, task): self._task_queue.append(task) self._dirty = True + self.schedule() def addFront(self, task): self._task_queue.appendleft(task) self._dirty = True + self.schedule() def schedule(self): @@ -69,6 +71,7 @@ class SequentialTaskQueue(SlotObject): self.running_tasks.remove(task) if self._task_queue: self._dirty = True + self.schedule() def clear(self): self._task_queue.clear()