diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-04-05 21:24:58 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-04-05 21:24:58 (GMT) |
commit | 965ce8799190b7017a41cd00eede083b342a15fb (patch) | |
tree | b903bd81fdf0c37363160a69aa0371ddac4b90c7 /Lib | |
parent | 1cdd83c2abf273cc5d5d214f064cc2125dd0f537 (diff) | |
download | cpython-965ce8799190b7017a41cd00eede083b342a15fb.zip cpython-965ce8799190b7017a41cd00eede083b342a15fb.tar.gz cpython-965ce8799190b7017a41cd00eede083b342a15fb.tar.bz2 |
Merged revisions 70908,70939,71009,71022,71036 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70908 | jesse.noller | 2009-03-31 17:20:35 -0500 (Tue, 31 Mar 2009) | 1 line
Issue 5619: Pass MS CRT debug flags into subprocesses
........
r70939 | jesse.noller | 2009-03-31 22:45:50 -0500 (Tue, 31 Mar 2009) | 1 line
Fix multiprocessing.event to match the new threading.Event API
........
r71009 | jesse.noller | 2009-04-01 19:03:28 -0500 (Wed, 01 Apr 2009) | 1 line
issue5545: Switch to Autoconf for multiprocessing; special thanks to Martin Lowis for help
........
r71022 | jesse.noller | 2009-04-01 21:32:55 -0500 (Wed, 01 Apr 2009) | 1 line
Issue 3110: Additional protection for SEM_VALUE_MAX on platforms, thanks to Martin Loewis
........
r71036 | jesse.noller | 2009-04-01 23:22:09 -0500 (Wed, 01 Apr 2009) | 1 line
Issue 3551: Raise ValueError if the size causes ERROR_NO_SYSTEM_RESOURCES
........
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/multiprocessing/synchronize.py | 5 | ||||
-rw-r--r-- | Lib/test/test_multiprocessing.py | 16 |
2 files changed, 14 insertions, 7 deletions
diff --git a/Lib/multiprocessing/synchronize.py b/Lib/multiprocessing/synchronize.py index 08d7c5d..8e994df 100644 --- a/Lib/multiprocessing/synchronize.py +++ b/Lib/multiprocessing/synchronize.py @@ -301,5 +301,10 @@ class Event(object): self._flag.release() else: self._cond.wait(timeout) + + if self._flag.acquire(False): + self._flag.release() + return True + return False finally: self._cond.release() diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index be108b1..69309ba 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -750,20 +750,22 @@ class _TestEvent(BaseTestCase): # Removed temporaily, due to API shear, this does not # work with threading._Event objects. is_set == isSet - #self.assertEqual(event.is_set(), False) + self.assertEqual(event.is_set(), False) - self.assertEqual(wait(0.0), None) + # Removed, threading.Event.wait() will return the value of the __flag + # instead of None. API Shear with the semaphore backed mp.Event + self.assertEqual(wait(0.0), False) self.assertTimingAlmostEqual(wait.elapsed, 0.0) - self.assertEqual(wait(TIMEOUT1), None) + self.assertEqual(wait(TIMEOUT1), False) self.assertTimingAlmostEqual(wait.elapsed, TIMEOUT1) event.set() # See note above on the API differences - # self.assertEqual(event.is_set(), True) - self.assertEqual(wait(), None) + self.assertEqual(event.is_set(), True) + self.assertEqual(wait(), True) self.assertTimingAlmostEqual(wait.elapsed, 0.0) - self.assertEqual(wait(TIMEOUT1), None) + self.assertEqual(wait(TIMEOUT1), True) self.assertTimingAlmostEqual(wait.elapsed, 0.0) # self.assertEqual(event.is_set(), True) @@ -772,7 +774,7 @@ class _TestEvent(BaseTestCase): #self.assertEqual(event.is_set(), False) self.Process(target=self._test_event, args=(event,)).start() - self.assertEqual(wait(), None) + self.assertEqual(wait(), True) # # |