summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-07-06 00:44:00 +0000
committerZac Medico <zmedico@gentoo.org>2008-07-06 00:44:00 +0000
commitb2324127404c2013bcb24d9929ad2e0394d9113c (patch)
tree13b91507c09904078794e7f5f845538023ae3b5f /pym
parent45fef7c9adb8ba0004a1e404b0f40cd3eb5fb196 (diff)
downloadportage-b2324127404c2013bcb24d9929ad2e0394d9113c.tar.gz
portage-b2324127404c2013bcb24d9929ad2e0394d9113c.tar.bz2
portage-b2324127404c2013bcb24d9929ad2e0394d9113c.zip
Add a CompositeTask._assert_current() method that asynchronous callbacks
can use detect possible bugs. svn path=/main/trunk/; revision=10949
Diffstat (limited to 'pym')
-rw-r--r--pym/_emerge/__init__.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index daa04980d..a16e532e9 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -1527,6 +1527,15 @@ class CompositeTask(AsynchronousTask):
self._wait_hook()
return self.returncode
+ def _assert_current(self, task):
+ """
+ Raises an AssertionError if the given task is not the
+ same one as self._current_task. This can be useful
+ for detecting bugs.
+ """
+ if task is not self._current_task:
+ raise AssertionError("Unrecognized task: %s" % (task,))
+
class TaskSequence(CompositeTask):
"""
A collection of tasks that executes sequentially. Each task
@@ -1557,9 +1566,8 @@ class TaskSequence(CompositeTask):
task.start()
def _task_exit_handler(self, task):
- if task is not self._current_task:
- raise AssertionError("Unrecognized task: %s" % (task,))
+ self._assert_current(task)
if self._task_queue and \
task.returncode == os.EX_OK:
self._start_next_task()
@@ -1979,6 +1987,7 @@ class EbuildExecuter(CompositeTask):
def _clean_phase_exit(self, clean_phase):
+ self._assert_current(clean_phase)
if clean_phase.returncode != os.EX_OK:
self.returncode = clean_phase.returncode
self._current_task = None
@@ -2011,6 +2020,8 @@ class EbuildExecuter(CompositeTask):
ebuild_phases.start()
def _ebuild_phases_exit(self, ebuild_phases):
+
+ self._assert_current(ebuild_phases)
self.returncode = ebuild_phases.returncode
self._current_task = None