changeset: 92268:4cce39cfe46c branch: 3.4 parent: 92262:a3452677a386 user: Antoine Pitrou date: Fri Aug 29 23:26:36 2014 +0200 files: Lib/threading.py Misc/ACKS Misc/NEWS description: Issue #22185: Fix an occasional RuntimeError in threading.Condition.wait() caused by mutation of the waiters queue without holding the lock. Patch by Doug Zongker. diff -r a3452677a386 -r 4cce39cfe46c Lib/threading.py --- a/Lib/threading.py Fri Aug 29 07:07:35 2014 +0300 +++ b/Lib/threading.py Fri Aug 29 23:26:36 2014 +0200 @@ -284,6 +284,7 @@ waiter.acquire() self._waiters.append(waiter) saved_state = self._release_save() + gotit = False try: # restore state no matter what (e.g., KeyboardInterrupt) if timeout is None: waiter.acquire() @@ -293,14 +294,14 @@ gotit = waiter.acquire(True, timeout) else: gotit = waiter.acquire(False) - if not gotit: - try: - self._waiters.remove(waiter) - except ValueError: - pass return gotit finally: self._acquire_restore(saved_state) + if not gotit: + try: + self._waiters.remove(waiter) + except ValueError: + pass def wait_for(self, predicate, timeout=None): """Wait until a condition evaluates to True. diff -r a3452677a386 -r 4cce39cfe46c Misc/ACKS --- a/Misc/ACKS Fri Aug 29 07:07:35 2014 +0300 +++ b/Misc/ACKS Fri Aug 29 23:26:36 2014 +0200 @@ -1500,4 +1500,5 @@ Kai Zhu Tarek Ziadé Gennadiy Zlobin +Doug Zongker Peter Åstrand diff -r a3452677a386 -r 4cce39cfe46c Misc/NEWS --- a/Misc/NEWS Fri Aug 29 07:07:35 2014 +0300 +++ b/Misc/NEWS Fri Aug 29 23:26:36 2014 +0200 @@ -27,6 +27,10 @@ Library ------- +- Issue #22185: Fix an occasional RuntimeError in threading.Condition.wait() + caused by mutation of the waiters queue without holding the lock. Patch + by Doug Zongker. + - Issue #22182: Use e.args to unpack exceptions correctly in distutils.file_util.move_file. Patch by Claudiu Popa.