[Python-checkins] commit of r41525 - in python/branches/release24-maint: Lib Misc

brett.cannon@python.org brett.cannon at python.org
Wed Nov 23 03:19:24 CET 2005


Author: brett.cannon
Date: Wed Nov 23 03:19:18 2005
New Revision: 41525

Modified:
   python/branches/release24-maint/Lib/threading.py
   python/branches/release24-maint/Misc/NEWS
Log:
Backport of patch #1314396: prevent threading.Thread.join() from blocking if a
previous call raised an exception (e.g., calling it with an illegal argument).


Modified: python/branches/release24-maint/Lib/threading.py
==============================================================================
--- python/branches/release24-maint/Lib/threading.py	(original)
+++ python/branches/release24-maint/Lib/threading.py	Wed Nov 23 03:19:18 2005
@@ -534,24 +534,26 @@
             if not self.__stopped:
                 self._note("%s.join(): waiting until thread stops", self)
         self.__block.acquire()
-        if timeout is None:
-            while not self.__stopped:
-                self.__block.wait()
-            if __debug__:
-                self._note("%s.join(): thread stopped", self)
-        else:
-            deadline = _time() + timeout
-            while not self.__stopped:
-                delay = deadline - _time()
-                if delay <= 0:
-                    if __debug__:
-                        self._note("%s.join(): timed out", self)
-                    break
-                self.__block.wait(delay)
-            else:
+        try:
+            if timeout is None:
+                while not self.__stopped:
+                    self.__block.wait()
                 if __debug__:
                     self._note("%s.join(): thread stopped", self)
-        self.__block.release()
+            else:
+                deadline = _time() + timeout
+                while not self.__stopped:
+                    delay = deadline - _time()
+                    if delay <= 0:
+                        if __debug__:
+                            self._note("%s.join(): timed out", self)
+                        break
+                    self.__block.wait(delay)
+                else:
+                    if __debug__:
+                        self._note("%s.join(): thread stopped", self)
+        finally:
+            self.__block.release()
 
     def getName(self):
         assert self.__initialized, "Thread.__init__() not called"

Modified: python/branches/release24-maint/Misc/NEWS
==============================================================================
--- python/branches/release24-maint/Misc/NEWS	(original)
+++ python/branches/release24-maint/Misc/NEWS	Wed Nov 23 03:19:18 2005
@@ -44,6 +44,10 @@
 Library
 -------
 
+- Patch #1314396: Prevent threading.Thread.join() from blocking if a previous
+  call caused an exception to be raised (e.g., calling join() with an illegal
+  argument).
+
 - urllib.unquote() now handles Unicode strings correctly.  Formerly, it would
   either ignore the substitution or raise UnicodeDecodeError.
 


More information about the Python-checkins mailing list