From: Brett Cannon Date: Wed, 23 Nov 2005 02:19:18 +0000 (+0000) Subject: Backport of patch #1314396: prevent threading.Thread.join() from blocking if a X-Git-Tag: v2.4.3c1~202 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cfced277da25701300b5aeb3fde0f563ed456eab;p=thirdparty%2FPython%2Fcpython.git 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). --- diff --git a/Lib/threading.py b/Lib/threading.py index 6def594326cc..8788ee571c75 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -534,24 +534,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/NEWS b/Misc/NEWS index 18c078464c01..b551b23f15b9 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -44,6 +44,10 @@ Extension Modules 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.