summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2005-11-23 02:15:50 (GMT)
committerBrett Cannon <bcannon@gmail.com>2005-11-23 02:15:50 (GMT)
commitad07ff2c77699c49b99140c0e1f36bfcdc9b2e17 (patch)
tree9dff63c51f2b08de5b74b77dae1c24aa85fa2fe5
parent5c6e0a1a0cac0b918e2a6ed7573db49cf6d0f6a5 (diff)
downloadcpython-ad07ff2c77699c49b99140c0e1f36bfcdc9b2e17.zip
cpython-ad07ff2c77699c49b99140c0e1f36bfcdc9b2e17.tar.gz
cpython-ad07ff2c77699c49b99140c0e1f36bfcdc9b2e17.tar.bz2
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.
-rw-r--r--Lib/threading.py34
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS4
3 files changed, 23 insertions, 16 deletions
diff --git a/Lib/threading.py b/Lib/threading.py
index fe4490f..9cc108e 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -536,24 +536,26 @@ class Thread(_Verbose):
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"
diff --git a/Misc/ACKS b/Misc/ACKS
index 72ed346..8eebc05 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -63,6 +63,7 @@ Roy Bixler
Martin Bless
Pablo Bleyer
Erik van Blokland
+Eric Blossom
Finn Bock
Paul Boddie
Matthew Boedicker
diff --git a/Misc/NEWS b/Misc/NEWS
index 9550156..73171f3 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -284,6 +284,10 @@ Extension Modules
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.