Kaydet (Commit) ad07ff2c authored tarafından Brett Cannon's avatar Brett Cannon

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.
üst 5c6e0a1a
...@@ -536,24 +536,26 @@ class Thread(_Verbose): ...@@ -536,24 +536,26 @@ class Thread(_Verbose):
if not self.__stopped: if not self.__stopped:
self._note("%s.join(): waiting until thread stops", self) self._note("%s.join(): waiting until thread stops", self)
self.__block.acquire() self.__block.acquire()
if timeout is None: try:
while not self.__stopped: if timeout is None:
self.__block.wait() while not self.__stopped:
if __debug__: self.__block.wait()
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:
if __debug__: if __debug__:
self._note("%s.join(): thread stopped", self) 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): def getName(self):
assert self.__initialized, "Thread.__init__() not called" assert self.__initialized, "Thread.__init__() not called"
......
...@@ -63,6 +63,7 @@ Roy Bixler ...@@ -63,6 +63,7 @@ Roy Bixler
Martin Bless Martin Bless
Pablo Bleyer Pablo Bleyer
Erik van Blokland Erik van Blokland
Eric Blossom
Finn Bock Finn Bock
Paul Boddie Paul Boddie
Matthew Boedicker Matthew Boedicker
......
...@@ -284,6 +284,10 @@ Extension Modules ...@@ -284,6 +284,10 @@ Extension Modules
Library 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 - Bug #1340337: change time.strptime() to always return ValueError when there
is an error in the format string. is an error in the format string.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment