diff options
author | Charles-François Natali <neologix@free.fr> | 2012-01-07 17:26:39 (GMT) |
---|---|---|
committer | Charles-François Natali <neologix@free.fr> | 2012-01-07 17:26:39 (GMT) |
commit | 61d28d6a740dac9705ae5b1efc7cb67a9a110bf1 (patch) | |
tree | c4a52adb3ce2ce12edbd598cf5152d9fffc2ffb3 /Lib/threading.py | |
parent | 5e60857e91056e5bb4a22783c31eaa3153cac051 (diff) | |
parent | ded0348c08f298fda4426eb2a62cc3d50eed25b5 (diff) | |
download | cpython-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/threading.py')
-rw-r--r-- | Lib/threading.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/threading.py b/Lib/threading.py index 2362be6..e85e269 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -408,9 +408,10 @@ class Event(_Verbose): def wait(self, timeout=None): self._cond.acquire() try: - if not self._flag: - self._cond.wait(timeout) - return self._flag + signaled = self._flag + if not signaled: + signaled = self._cond.wait(timeout) + return signaled finally: self._cond.release() |