summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2015-10-11 02:36:51 (GMT)
committerBenjamin Peterson <benjamin@python.org>2015-10-11 02:36:51 (GMT)
commit10dcff7a0415b302d5eb8de8e7763c7eab85e3dc (patch)
treefb21255a2f2b3c4553f3b40ebc45b9dc43348710
parent90ccccf9ed408f2a70c253fc2b5f4b3b5f4da33f (diff)
parent062f4cec5e457a78068c942faef999886adf53ff (diff)
downloadcpython-10dcff7a0415b302d5eb8de8e7763c7eab85e3dc.zip
cpython-10dcff7a0415b302d5eb8de8e7763c7eab85e3dc.tar.gz
cpython-10dcff7a0415b302d5eb8de8e7763c7eab85e3dc.tar.bz2
merge 3.5 (#25362)
-rw-r--r--Lib/threading.py15
1 files changed, 3 insertions, 12 deletions
diff --git a/Lib/threading.py b/Lib/threading.py
index 4b4ec38..828019d 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -514,12 +514,9 @@ class Event:
that call wait() once the flag is true will not block at all.
"""
- self._cond.acquire()
- try:
+ with self._cond:
self._flag = True
self._cond.notify_all()
- finally:
- self._cond.release()
def clear(self):
"""Reset the internal flag to false.
@@ -528,11 +525,8 @@ class Event:
set the internal flag to true again.
"""
- self._cond.acquire()
- try:
+ with self._cond:
self._flag = False
- finally:
- self._cond.release()
def wait(self, timeout=None):
"""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.
"""
- self._cond.acquire()
- try:
+ with self._cond:
signaled = self._flag
if not signaled:
signaled = self._cond.wait(timeout)
return signaled
- finally:
- self._cond.release()
# A barrier class. Inspired in part by the pthread_barrier_* api and