mirror of
https://github.com/python/cpython.git
synced 2025-08-23 18:24:46 +00:00
Issue #13502: threading: Fix a race condition in Event.wait() that made it
return False when the event was set and cleared right after.
This commit is contained in:
commit
61d28d6a74
4 changed files with 27 additions and 5 deletions
|
@ -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()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue