diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-03-16 20:44:55 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-03-18 12:48:18 -0700 |
commit | ef507665cb7b3fe697126f75e794025edf3f03eb (patch) | |
tree | 3d2d9ca09da417fddef8ab6d755aa2772733e7d4 /pym/_emerge/CompositeTask.py | |
parent | cd01cd70242e7fc9c2d52375948bbe76378f1471 (diff) | |
download | portage-ef507665cb7b3fe697126f75e794025edf3f03eb.tar.gz portage-ef507665cb7b3fe697126f75e794025edf3f03eb.tar.bz2 portage-ef507665cb7b3fe697126f75e794025edf3f03eb.zip |
CompositeTask: handle unstarted terminated tasks
Diffstat (limited to 'pym/_emerge/CompositeTask.py')
-rw-r--r-- | pym/_emerge/CompositeTask.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/pym/_emerge/CompositeTask.py b/pym/_emerge/CompositeTask.py index b5e8ce5bb..8e8f0843c 100644 --- a/pym/_emerge/CompositeTask.py +++ b/pym/_emerge/CompositeTask.py @@ -8,13 +8,19 @@ class CompositeTask(AsynchronousTask): __slots__ = ("scheduler",) + ("_current_task",) + _TASK_QUEUED = -1 + def isAlive(self): return self._current_task is not None def cancel(self): self.cancelled = True if self._current_task is not None: - self._current_task.cancel() + if self._current_task is self._TASK_QUEUED: + self.returncode = 1 + self._current_task = None + else: + self._current_task.cancel() AsynchronousTask.cancel(self) def _poll(self): @@ -32,7 +38,9 @@ class CompositeTask(AsynchronousTask): prev = None while True: task = self._current_task - if task is None or task is prev: + if task is None or \ + task is self._TASK_QUEUED or \ + task is prev: # don't poll the same task more than once break task.poll() @@ -48,6 +56,10 @@ class CompositeTask(AsynchronousTask): if task is None: # don't wait for the same task more than once break + if task is self._TASK_QUEUED: + self.returncode = 1 + self._current_task = None + break if task is prev: if self.returncode is not None: # This is expected if we're being @@ -123,3 +135,9 @@ class CompositeTask(AsynchronousTask): self._current_task = task task.start() + def _task_queued(self, task): + task.addStartListener(self._task_queued_start_handler) + self._current_task = self._TASK_QUEUED + + def _task_queued_start_handler(self, task): + self._current_task = task |