summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-03-16 20:44:55 -0700
committerZac Medico <zmedico@gentoo.org>2011-03-16 20:44:55 -0700
commit9fa6881ac70e799e09fe98c1eb24177663f3b0e5 (patch)
tree85c20c2588036bcfbc3e66549b4509f4a20b2887
parent947f4bdcd0303a0170d9e1bac3d0964f747ce36b (diff)
downloadportage-9fa6881ac70e799e09fe98c1eb24177663f3b0e5.tar.gz
portage-9fa6881ac70e799e09fe98c1eb24177663f3b0e5.tar.bz2
portage-9fa6881ac70e799e09fe98c1eb24177663f3b0e5.zip
CompositeTask: handle unstarted terminated tasks
-rw-r--r--pym/_emerge/Binpkg.py4
-rw-r--r--pym/_emerge/CompositeTask.py22
-rw-r--r--pym/_emerge/EbuildExecuter.py4
3 files changed, 24 insertions, 6 deletions
diff --git a/pym/_emerge/Binpkg.py b/pym/_emerge/Binpkg.py
index 65a5ef4a5..b011b001f 100644
--- a/pym/_emerge/Binpkg.py
+++ b/pym/_emerge/Binpkg.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from _emerge.EbuildPhase import EbuildPhase
@@ -277,7 +277,7 @@ class Binpkg(CompositeTask):
settings=settings)
setup_phase.addExitListener(self._setup_exit)
- self._current_task = setup_phase
+ self._task_queued(setup_phase)
self.scheduler.scheduleSetup(setup_phase)
def _setup_exit(self, setup_phase):
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
diff --git a/pym/_emerge/EbuildExecuter.py b/pym/_emerge/EbuildExecuter.py
index b28c73793..f8febd47c 100644
--- a/pym/_emerge/EbuildExecuter.py
+++ b/pym/_emerge/EbuildExecuter.py
@@ -51,7 +51,7 @@ class EbuildExecuter(CompositeTask):
settings=settings)
setup_phase.addExitListener(self._setup_exit)
- self._current_task = setup_phase
+ self._task_queued(setup_phase)
self.scheduler.scheduleSetup(setup_phase)
def _setup_exit(self, setup_phase):
@@ -69,7 +69,7 @@ class EbuildExecuter(CompositeTask):
# otherwise they can interfere with eachother.
unpack_phase.addExitListener(self._unpack_exit)
- self._current_task = unpack_phase
+ self._task_queued(unpack_phase)
self.scheduler.scheduleUnpack(unpack_phase)
else: