summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJesse Noller <jnoller@gmail.com>2009-04-01 03:45:50 (GMT)
committerJesse Noller <jnoller@gmail.com>2009-04-01 03:45:50 (GMT)
commit02cb0eb231fc01e2a50cbe14f6da7a8df52959ef (patch)
tree48835ed26dd10e33babaf8bbde4f770b898ca0fd /Lib
parenta83da3507f6f6075cce143cb118d3ddb23df981c (diff)
downloadcpython-02cb0eb231fc01e2a50cbe14f6da7a8df52959ef.zip
cpython-02cb0eb231fc01e2a50cbe14f6da7a8df52959ef.tar.gz
cpython-02cb0eb231fc01e2a50cbe14f6da7a8df52959ef.tar.bz2
Fix multiprocessing.event to match the new threading.Event API
Diffstat (limited to 'Lib')
-rw-r--r--Lib/multiprocessing/synchronize.py5
-rw-r--r--Lib/test/test_multiprocessing.py16
2 files changed, 14 insertions, 7 deletions
diff --git a/Lib/multiprocessing/synchronize.py b/Lib/multiprocessing/synchronize.py
index dacf45a..716f3c7 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 a446ac3..8ef2e2f 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -749,20 +749,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)
@@ -771,7 +773,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)
#
#