[Python-checkins] cpython (merge 3.4 -> 3.5): merge 3.4 (#25362)

benjamin.peterson python-checkins at python.org
Sat Oct 10 22:37:05 EDT 2015


https://hg.python.org/cpython/rev/794101c6e560
changeset:   98664:794101c6e560
branch:      3.5
parent:      98660:ae98209ff69a
parent:      98663:62e87422a1a9
user:        Benjamin Peterson <benjamin at python.org>
date:        Sat Oct 10 19:36:40 2015 -0700
summary:
  merge 3.4 (#25362)

files:
  Lib/threading.py |  15 +++------------
  1 files changed, 3 insertions(+), 12 deletions(-)


diff --git a/Lib/threading.py b/Lib/threading.py
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -514,12 +514,9 @@
         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 @@
         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 @@
         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

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list