1 |
commit: 839f369f259a7c019c1f544bf4c153058355f6d4 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Feb 7 02:52:32 2012 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Feb 7 19:12:11 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=839f369f |
7 |
|
8 |
AsynchronousTask: merge _waiting from subclass |
9 |
|
10 |
--- |
11 |
pym/_emerge/AsynchronousLock.py | 7 ++----- |
12 |
pym/_emerge/AsynchronousTask.py | 10 ++++++++-- |
13 |
2 files changed, 10 insertions(+), 7 deletions(-) |
14 |
|
15 |
diff --git a/pym/_emerge/AsynchronousLock.py b/pym/_emerge/AsynchronousLock.py |
16 |
index ae3bde4..3593834 100644 |
17 |
--- a/pym/_emerge/AsynchronousLock.py |
18 |
+++ b/pym/_emerge/AsynchronousLock.py |
19 |
@@ -36,7 +36,7 @@ class AsynchronousLock(AsynchronousTask): |
20 |
|
21 |
__slots__ = ('path', 'scheduler',) + \ |
22 |
('_imp', '_force_async', '_force_dummy', '_force_process', \ |
23 |
- '_force_thread', '_waiting') |
24 |
+ '_force_thread') |
25 |
|
26 |
_use_process_by_default = True |
27 |
|
28 |
@@ -67,8 +67,7 @@ class AsynchronousLock(AsynchronousTask): |
29 |
|
30 |
def _imp_exit(self, imp): |
31 |
# call exit listeners |
32 |
- if not self._waiting: |
33 |
- self.wait() |
34 |
+ self.wait() |
35 |
|
36 |
def _cancel(self): |
37 |
if isinstance(self._imp, AsynchronousTask): |
38 |
@@ -82,9 +81,7 @@ class AsynchronousLock(AsynchronousTask): |
39 |
def _wait(self): |
40 |
if self.returncode is not None: |
41 |
return self.returncode |
42 |
- self._waiting = True |
43 |
self.returncode = self._imp.wait() |
44 |
- self._waiting = False |
45 |
return self.returncode |
46 |
|
47 |
def unlock(self): |
48 |
|
49 |
diff --git a/pym/_emerge/AsynchronousTask.py b/pym/_emerge/AsynchronousTask.py |
50 |
index 36522ca..4aa5980 100644 |
51 |
--- a/pym/_emerge/AsynchronousTask.py |
52 |
+++ b/pym/_emerge/AsynchronousTask.py |
53 |
@@ -14,7 +14,8 @@ class AsynchronousTask(SlotObject): |
54 |
""" |
55 |
|
56 |
__slots__ = ("background", "cancelled", "returncode") + \ |
57 |
- ("_exit_listeners", "_exit_listener_stack", "_start_listeners") |
58 |
+ ("_exit_listeners", "_exit_listener_stack", "_start_listeners", |
59 |
+ "_waiting") |
60 |
|
61 |
def start(self): |
62 |
""" |
63 |
@@ -42,7 +43,12 @@ class AsynchronousTask(SlotObject): |
64 |
|
65 |
def wait(self): |
66 |
if self.returncode is None: |
67 |
- self._wait() |
68 |
+ if not self._waiting: |
69 |
+ self._waiting = True |
70 |
+ try: |
71 |
+ self._wait() |
72 |
+ finally: |
73 |
+ self._waiting = False |
74 |
self._wait_hook() |
75 |
return self.returncode |