summaryrefslogtreecommitdiffstats
path: root/Lib/test/lock_tests.py
diff options
context:
space:
mode:
authorCharles-François Natali <neologix@free.fr>2012-01-07 17:26:39 (GMT)
committerCharles-François Natali <neologix@free.fr>2012-01-07 17:26:39 (GMT)
commit61d28d6a740dac9705ae5b1efc7cb67a9a110bf1 (patch)
treec4a52adb3ce2ce12edbd598cf5152d9fffc2ffb3 /Lib/test/lock_tests.py
parent5e60857e91056e5bb4a22783c31eaa3153cac051 (diff)
parentded0348c08f298fda4426eb2a62cc3d50eed25b5 (diff)
downloadcpython-61d28d6a740dac9705ae5b1efc7cb67a9a110bf1.zip
cpython-61d28d6a740dac9705ae5b1efc7cb67a9a110bf1.tar.gz
cpython-61d28d6a740dac9705ae5b1efc7cb67a9a110bf1.tar.bz2
Issue #13502: threading: Fix a race condition in Event.wait() that made it
return False when the event was set and cleared right after.
Diffstat (limited to 'Lib/test/lock_tests.py')
-rw-r--r--Lib/test/lock_tests.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py
index 12871c1..d88f364 100644
--- a/Lib/test/lock_tests.py
+++ b/Lib/test/lock_tests.py
@@ -353,6 +353,22 @@ class EventTests(BaseTestCase):
for r, dt in results2:
self.assertTrue(r)
+ def test_set_and_clear(self):
+ # Issue #13502: check that wait() returns true even when the event is
+ # cleared before the waiting thread is woken up.
+ evt = self.eventtype()
+ results = []
+ N = 5
+ def f():
+ results.append(evt.wait(1))
+ b = Bunch(f, N)
+ b.wait_for_started()
+ time.sleep(0.5)
+ evt.set()
+ evt.clear()
+ b.wait_for_finished()
+ self.assertEqual(results, [True] * N)
+
class ConditionTests(BaseTestCase):
"""