mirror of
https://github.com/python/cpython.git
synced 2025-10-02 13:22:19 +00:00
merge 3.5 (#25362)
This commit is contained in:
commit
10dcff7a04
1 changed files with 3 additions and 12 deletions
|
@ -514,12 +514,9 @@ class Event:
|
||||||
that call wait() once the flag is true will not block at all.
|
that call wait() once the flag is true will not block at all.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self._cond.acquire()
|
with self._cond:
|
||||||
try:
|
|
||||||
self._flag = True
|
self._flag = True
|
||||||
self._cond.notify_all()
|
self._cond.notify_all()
|
||||||
finally:
|
|
||||||
self._cond.release()
|
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
"""Reset the internal flag to false.
|
"""Reset the internal flag to false.
|
||||||
|
@ -528,11 +525,8 @@ class Event:
|
||||||
set the internal flag to true again.
|
set the internal flag to true again.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self._cond.acquire()
|
with self._cond:
|
||||||
try:
|
|
||||||
self._flag = False
|
self._flag = False
|
||||||
finally:
|
|
||||||
self._cond.release()
|
|
||||||
|
|
||||||
def wait(self, timeout=None):
|
def wait(self, timeout=None):
|
||||||
"""Block until the internal flag is true.
|
"""Block until the internal flag is true.
|
||||||
|
@ -549,14 +543,11 @@ class Event:
|
||||||
True except if a timeout is given and the operation times out.
|
True except if a timeout is given and the operation times out.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self._cond.acquire()
|
with self._cond:
|
||||||
try:
|
|
||||||
signaled = self._flag
|
signaled = self._flag
|
||||||
if not signaled:
|
if not signaled:
|
||||||
signaled = self._cond.wait(timeout)
|
signaled = self._cond.wait(timeout)
|
||||||
return signaled
|
return signaled
|
||||||
finally:
|
|
||||||
self._cond.release()
|
|
||||||
|
|
||||||
|
|
||||||
# A barrier class. Inspired in part by the pthread_barrier_* api and
|
# A barrier class. Inspired in part by the pthread_barrier_* api and
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue