aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-03-10 22:02:19 -0800
committerZac Medico <zmedico@gentoo.org>2011-03-10 22:02:19 -0800
commit9411ac7406c6e775998bf6055ca8f022acce9e25 (patch)
tree3f3ce2da2f612a389d8855ce3f50bb274d4b5ecb /pym/_emerge/PollScheduler.py
parentPollScheduler: call _terminate_tasks in _schedule (diff)
downloadportage-9411ac7406c6e775998bf6055ca8f022acce9e25.tar.gz
portage-9411ac7406c6e775998bf6055ca8f022acce9e25.tar.bz2
portage-9411ac7406c6e775998bf6055ca8f022acce9e25.zip
PollScheduler: tweek termination logic
* PollScheduler and all subclasses now use the _terminated_tasks variable to check whether or not _terminate_tasks() has been called, and behave appropriately in that case. * The _schedule_tasks() method now has documentation about the relationship with _terminate_tasks() and _terminated_tasks.
Diffstat (limited to 'pym/_emerge/PollScheduler.py')
-rw-r--r--pym/_emerge/PollScheduler.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/pym/_emerge/PollScheduler.py b/pym/_emerge/PollScheduler.py
index 94fd92407..8f4bd64b9 100644
--- a/pym/_emerge/PollScheduler.py
+++ b/pym/_emerge/PollScheduler.py
@@ -65,6 +65,24 @@ class PollScheduler(object):
"""
raise NotImplementedError()
+ def _schedule_tasks(self):
+ """
+ This is called from inside the _schedule() method, which
+ guarantees the following:
+
+ 1) It will not be called recursively.
+ 2) _terminate_tasks() will not be called while it is running.
+ 3) The state of the boolean _terminated_tasks variable will
+ not change while it is running.
+
+ Unless this method is used to perform user interface updates,
+ or something like that, the first thing it should do is check
+ the state of _terminated_tasks and if that is True then it
+ should return False immediately (since there's no need to
+ schedule anything after _terminate_tasks() has been called).
+ """
+ raise NotImplementedError()
+
def _schedule(self):
"""
Calls _schedule_tasks() and automatically returns early from
@@ -90,6 +108,9 @@ class PollScheduler(object):
return self._jobs
def _can_add_job(self):
+ if self._terminated_tasks:
+ return False
+
max_jobs = self._max_jobs
max_load = self._max_load