mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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.
This commit is contained in:
parent
5c6e0a1a0c
commit
ad07ff2c77
3 changed files with 23 additions and 16 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue