diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-03-10 22:02:19 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-03-14 09:24:01 -0700 |
commit | d57e5baf22dccb5160249299e6db039f69a4214d (patch) | |
tree | 1ce1ff8ff947f33e3ebd085e4e51396a908b480f /pym/_emerge/PollScheduler.py | |
parent | bcb3ead57e5f207652f506a13604f60dbebf047b (diff) | |
download | portage-d57e5baf22dccb5160249299e6db039f69a4214d.tar.gz portage-d57e5baf22dccb5160249299e6db039f69a4214d.tar.bz2 portage-d57e5baf22dccb5160249299e6db039f69a4214d.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.py | 21 |
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 |