diff options
author | Benjamin Peterson <benjamin@python.org> | 2015-10-11 02:36:40 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2015-10-11 02:36:40 (GMT) |
commit | 062f4cec5e457a78068c942faef999886adf53ff (patch) | |
tree | 962a73ba205d6806d50afebf0f88162ecfe1342a /Lib/threading.py | |
parent | e5df40727c3bb24dbf38b74a6c1e0e2a6b70b429 (diff) | |
parent | 414918a939b02aa3f7048ba341a3f6862ab9a71e (diff) | |
download | cpython-062f4cec5e457a78068c942faef999886adf53ff.zip cpython-062f4cec5e457a78068c942faef999886adf53ff.tar.gz cpython-062f4cec5e457a78068c942faef999886adf53ff.tar.bz2 |
merge 3.4 (#25362)
Diffstat (limited to 'Lib/threading.py')
-rw-r--r-- | Lib/threading.py | 15 |
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 |