diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-03-10 21:21:19 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-03-14 09:23:47 -0700 |
commit | bcb3ead57e5f207652f506a13604f60dbebf047b (patch) | |
tree | b5e370a30243c6112d88ee6f04360d0986f8cbd1 /pym | |
parent | 48fad6f94aa044c638d5cad8851b4fed8e80309b (diff) | |
download | portage-bcb3ead57e5f207652f506a13604f60dbebf047b.tar.gz portage-bcb3ead57e5f207652f506a13604f60dbebf047b.tar.bz2 portage-bcb3ead57e5f207652f506a13604f60dbebf047b.zip |
PollScheduler: call _terminate_tasks in _schedule
This prevents it from being called while the _schedule_tasks()
implementation is running, in order to avoid potential interference.
Diffstat (limited to 'pym')
-rw-r--r-- | pym/_emerge/PollScheduler.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/pym/_emerge/PollScheduler.py b/pym/_emerge/PollScheduler.py index a319066c0..94fd92407 100644 --- a/pym/_emerge/PollScheduler.py +++ b/pym/_emerge/PollScheduler.py @@ -57,9 +57,11 @@ class PollScheduler(object): def _terminate_tasks(self): """ Send signals to terminate all tasks. This is called once - from the event dispatching thread. All task should be - cleaned up at the earliest opportunity, but not necessarily - before this method returns. + from self._schedule() in the event dispatching thread. This + prevents it from being called while the _schedule_tasks() + implementation is running, in order to avoid potential + interference. All tasks should be cleaned up at the earliest + opportunity, but not necessarily before this method returns. """ raise NotImplementedError() @@ -74,6 +76,12 @@ class PollScheduler(object): return False self._scheduling = True try: + + if self._terminated.is_set() and \ + not self._terminated_tasks: + self._terminated_tasks = True + self._terminate_tasks() + return self._schedule_tasks() finally: self._scheduling = False @@ -145,10 +153,6 @@ class PollScheduler(object): raises StopIteration if timeout is None and there are no file descriptors to poll. """ - if self._terminated.is_set() and \ - not self._terminated_tasks: - self._terminated_tasks = True - self._terminate_tasks() if not self._poll_event_queue: self._poll(timeout) if not self._poll_event_queue: |