diff options
author | Charles-François Natali <neologix@free.fr> | 2012-01-07 17:24:56 (GMT) |
---|---|---|
committer | Charles-François Natali <neologix@free.fr> | 2012-01-07 17:24:56 (GMT) |
commit | ded0348c08f298fda4426eb2a62cc3d50eed25b5 (patch) | |
tree | f762e7f1f50cce89494a53a5744ad307d0d02b2d /Lib/threading.py | |
parent | b52e7a9a364096d355d32927c537389cfc10a5db (diff) | |
download | cpython-ded0348c08f298fda4426eb2a62cc3d50eed25b5.zip cpython-ded0348c08f298fda4426eb2a62cc3d50eed25b5.tar.gz cpython-ded0348c08f298fda4426eb2a62cc3d50eed25b5.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 043e6c8..fe92f10 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -418,9 +418,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() |