mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +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:
parent
b52e7a9a36
commit
ded0348c08
4 changed files with 27 additions and 5 deletions
|
@ -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()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue