1 |
Author: zmedico |
2 |
Date: 2008-07-06 03:44:25 +0000 (Sun, 06 Jul 2008) |
3 |
New Revision: 10952 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/_emerge/__init__.py |
7 |
Log: |
8 |
Split out a CompositeTask._start_task() for subclasses to use as a generic |
9 |
way to start a task. |
10 |
|
11 |
|
12 |
Modified: main/trunk/pym/_emerge/__init__.py |
13 |
=================================================================== |
14 |
--- main/trunk/pym/_emerge/__init__.py 2008-07-06 01:51:50 UTC (rev 10951) |
15 |
+++ main/trunk/pym/_emerge/__init__.py 2008-07-06 03:44:25 UTC (rev 10952) |
16 |
@@ -1565,6 +1565,19 @@ |
17 |
self._current_task = None |
18 |
self.returncode = task.returncode |
19 |
|
20 |
+ def _start_task(self, task, exit_handler): |
21 |
+ """ |
22 |
+ Register exit handler for the given task, set it |
23 |
+ as self._current_task, and call task.start(). |
24 |
+ |
25 |
+ Subclasses can use this as a generic way to start |
26 |
+ a task. |
27 |
+ |
28 |
+ """ |
29 |
+ task.addExitListener(exit_handler) |
30 |
+ self._current_task = task |
31 |
+ task.start() |
32 |
+ |
33 |
class TaskSequence(CompositeTask): |
34 |
""" |
35 |
A collection of tasks that executes sequentially. Each task |
36 |
@@ -1589,10 +1602,8 @@ |
37 |
CompositeTask.cancel(self) |
38 |
|
39 |
def _start_next_task(self): |
40 |
- self._current_task = self._task_queue.popleft() |
41 |
- task = self._current_task |
42 |
- task.addExitListener(self._task_exit_handler) |
43 |
- task.start() |
44 |
+ self._start_task(self._task_queue.popleft(), |
45 |
+ self._task_exit_handler) |
46 |
|
47 |
def _task_exit_handler(self, task): |
48 |
if self._default_exit(task) == os.EX_OK and \ |
49 |
@@ -2006,9 +2017,7 @@ |
50 |
phase = "clean" |
51 |
clean_phase = EbuildPhase(pkg=pkg, phase=phase, |
52 |
scheduler=scheduler, settings=settings, tree=tree) |
53 |
- clean_phase.addExitListener(self._clean_phase_exit) |
54 |
- self._current_task = clean_phase |
55 |
- clean_phase.start() |
56 |
+ self._start_task(clean_phase, self._clean_phase_exit) |
57 |
|
58 |
def _clean_phase_exit(self, clean_phase): |
59 |
|
60 |
@@ -2037,9 +2046,7 @@ |
61 |
pkg=pkg, phase=phase, scheduler=scheduler, |
62 |
settings=settings, tree=tree)) |
63 |
|
64 |
- ebuild_phases.addExitListener(self._final_exit) |
65 |
- self._current_task = ebuild_phases |
66 |
- ebuild_phases.start() |
67 |
+ self._start_task(ebuild_phases, self._final_exit) |
68 |
|
69 |
class EbuildPhase(SubProcess): |
70 |
|
71 |
|
72 |
-- |
73 |
gentoo-commits@l.g.o mailing list |