[Python-checkins] commit of r41524 - in python/trunk: Lib Misc
brett.cannon@python.org
brett.cannon at python.org
Wed Nov 23 03:15:56 CET 2005
Author: brett.cannon
Date: Wed Nov 23 03:15:50 2005
New Revision: 41524
Modified:
python/trunk/Lib/threading.py
python/trunk/Misc/ACKS
python/trunk/Misc/NEWS
Log:
Prevent threading.Thread.join() from blocking when a previous call raised an
exception (e.g., passing in an illegal argument).
Applies patch #1314396. Thanks Eric Blossom.
Modified: python/trunk/Lib/threading.py
==============================================================================
--- python/trunk/Lib/threading.py (original)
+++ python/trunk/Lib/threading.py Wed Nov 23 03:15:50 2005
@@ -536,24 +536,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/trunk/Misc/ACKS
==============================================================================
--- python/trunk/Misc/ACKS (original)
+++ python/trunk/Misc/ACKS Wed Nov 23 03:15:50 2005
@@ -63,6 +63,7 @@
Martin Bless
Pablo Bleyer
Erik van Blokland
+Eric Blossom
Finn Bock
Paul Boddie
Matthew Boedicker
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Wed Nov 23 03:15:50 2005
@@ -284,6 +284,10 @@
Library
-------
+- Patch #1314396: prevent deadlock for threading.Thread.join() when an exception
+ is raised within the method itself on a previous call (e.g., passing in an
+ illegal argument)
+
- Bug #1340337: change time.strptime() to always return ValueError when there
is an error in the format string.
More information about the Python-checkins
mailing list