1 |
commit: 1650ac2944b7cbd5a462d2ce39993e2f202807c4 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue May 17 21:25:47 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue May 17 21:25:47 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=1650ac29 |
7 |
|
8 |
AsynchronousLock: implement _poll() and test |
9 |
|
10 |
--- |
11 |
pym/_emerge/AsynchronousLock.py | 10 ++++++++++ |
12 |
pym/_emerge/AsynchronousTask.py | 2 ++ |
13 |
pym/portage/tests/locks/test_asynchronous_lock.py | 2 ++ |
14 |
3 files changed, 14 insertions(+), 0 deletions(-) |
15 |
|
16 |
diff --git a/pym/_emerge/AsynchronousLock.py b/pym/_emerge/AsynchronousLock.py |
17 |
index 1135df7..86b102b 100644 |
18 |
--- a/pym/_emerge/AsynchronousLock.py |
19 |
+++ b/pym/_emerge/AsynchronousLock.py |
20 |
@@ -73,6 +73,11 @@ class AsynchronousLock(AsynchronousTask): |
21 |
if self._imp is not None: |
22 |
self._imp.cancel() |
23 |
|
24 |
+ def _poll(self): |
25 |
+ if self._imp is not None: |
26 |
+ return self._imp.poll() |
27 |
+ return self.returncode |
28 |
+ |
29 |
def _wait(self): |
30 |
if self.returncode is not None: |
31 |
return self.returncode |
32 |
@@ -232,6 +237,11 @@ class _LockProcess(AbstractPollTask): |
33 |
if self._proc is not None: |
34 |
self._proc.cancel() |
35 |
|
36 |
+ def _poll(self): |
37 |
+ if self._proc is not None: |
38 |
+ return self._proc.poll() |
39 |
+ return self.returncode |
40 |
+ |
41 |
def _wait(self): |
42 |
if self.returncode is not None: |
43 |
return self.returncode |
44 |
|
45 |
diff --git a/pym/_emerge/AsynchronousTask.py b/pym/_emerge/AsynchronousTask.py |
46 |
index 2b654ec..cac1d55 100644 |
47 |
--- a/pym/_emerge/AsynchronousTask.py |
48 |
+++ b/pym/_emerge/AsynchronousTask.py |
49 |
@@ -32,6 +32,8 @@ class AsynchronousTask(SlotObject): |
50 |
|
51 |
def poll(self): |
52 |
self._wait_hook() |
53 |
+ if self.returncode is not None: |
54 |
+ return self.returncode |
55 |
return self._poll() |
56 |
|
57 |
def _poll(self): |
58 |
|
59 |
diff --git a/pym/portage/tests/locks/test_asynchronous_lock.py b/pym/portage/tests/locks/test_asynchronous_lock.py |
60 |
index d592f4b..50b9c93 100644 |
61 |
--- a/pym/portage/tests/locks/test_asynchronous_lock.py |
62 |
+++ b/pym/portage/tests/locks/test_asynchronous_lock.py |
63 |
@@ -56,6 +56,7 @@ class AsynchronousLockTestCase(TestCase): |
64 |
_force_async=True, _force_process=True) |
65 |
lock2.start() |
66 |
# lock2 should we waiting for lock1 to release |
67 |
+ self.assertEqual(lock2.poll(), None) |
68 |
self.assertEqual(lock2.returncode, None) |
69 |
|
70 |
lock1.unlock() |
71 |
@@ -78,6 +79,7 @@ class AsynchronousLockTestCase(TestCase): |
72 |
_force_async=True, _force_process=True) |
73 |
lock2.start() |
74 |
# lock2 should we waiting for lock1 to release |
75 |
+ self.assertEqual(lock2.poll(), None) |
76 |
self.assertEqual(lock2.returncode, None) |
77 |
|
78 |
# Cancel lock2 and then check wait() and returncode results. |