-# 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
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):
__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):
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()
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
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
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):
# 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: