diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-05-17 14:25:47 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-05-17 14:25:47 -0700 |
commit | 1650ac2944b7cbd5a462d2ce39993e2f202807c4 (patch) | |
tree | 72b94ce2f9bc1818b1fbeb1e1c289b844d2aa026 | |
parent | f94e8ce0c0296cc97ae1a080a21d32c8d23ec2e4 (diff) | |
download | portage-1650ac2944b7cbd5a462d2ce39993e2f202807c4.tar.gz portage-1650ac2944b7cbd5a462d2ce39993e2f202807c4.tar.bz2 portage-1650ac2944b7cbd5a462d2ce39993e2f202807c4.zip |
AsynchronousLock: implement _poll() and test
-rw-r--r-- | pym/_emerge/AsynchronousLock.py | 10 | ||||
-rw-r--r-- | pym/_emerge/AsynchronousTask.py | 2 | ||||
-rw-r--r-- | pym/portage/tests/locks/test_asynchronous_lock.py | 2 |
3 files changed, 14 insertions, 0 deletions
diff --git a/pym/_emerge/AsynchronousLock.py b/pym/_emerge/AsynchronousLock.py index 1135df744..86b102b8b 100644 --- a/pym/_emerge/AsynchronousLock.py +++ b/pym/_emerge/AsynchronousLock.py @@ -73,6 +73,11 @@ class AsynchronousLock(AsynchronousTask): if self._imp is not None: self._imp.cancel() + def _poll(self): + if self._imp is not None: + return self._imp.poll() + return self.returncode + def _wait(self): if self.returncode is not None: return self.returncode @@ -232,6 +237,11 @@ class _LockProcess(AbstractPollTask): if self._proc is not None: self._proc.cancel() + def _poll(self): + if self._proc is not None: + return self._proc.poll() + return self.returncode + def _wait(self): if self.returncode is not None: return self.returncode diff --git a/pym/_emerge/AsynchronousTask.py b/pym/_emerge/AsynchronousTask.py index 2b654ec00..cac1d5594 100644 --- a/pym/_emerge/AsynchronousTask.py +++ b/pym/_emerge/AsynchronousTask.py @@ -32,6 +32,8 @@ class AsynchronousTask(SlotObject): def poll(self): self._wait_hook() + if self.returncode is not None: + return self.returncode return self._poll() def _poll(self): diff --git a/pym/portage/tests/locks/test_asynchronous_lock.py b/pym/portage/tests/locks/test_asynchronous_lock.py index d592f4b22..50b9c93a5 100644 --- a/pym/portage/tests/locks/test_asynchronous_lock.py +++ b/pym/portage/tests/locks/test_asynchronous_lock.py @@ -56,6 +56,7 @@ class AsynchronousLockTestCase(TestCase): _force_async=True, _force_process=True) lock2.start() # lock2 should we waiting for lock1 to release + self.assertEqual(lock2.poll(), None) self.assertEqual(lock2.returncode, None) lock1.unlock() @@ -78,6 +79,7 @@ class AsynchronousLockTestCase(TestCase): _force_async=True, _force_process=True) lock2.start() # lock2 should we waiting for lock1 to release + self.assertEqual(lock2.poll(), None) self.assertEqual(lock2.returncode, None) # Cancel lock2 and then check wait() and returncode results. |