diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2014-08-29 21:26:36 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2014-08-29 21:26:36 (GMT) |
commit | a64b92edd3b7c9145e014aac9a15821d7b05b71a (patch) | |
tree | 9cae5e961535d1a43449d920c80091fd60c0900f | |
parent | 6685883c02b29b66813343e6380133cd49df4300 (diff) | |
download | cpython-a64b92edd3b7c9145e014aac9a15821d7b05b71a.zip cpython-a64b92edd3b7c9145e014aac9a15821d7b05b71a.tar.gz cpython-a64b92edd3b7c9145e014aac9a15821d7b05b71a.tar.bz2 |
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.
-rw-r--r-- | Lib/threading.py | 11 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS | 4 |
3 files changed, 11 insertions, 5 deletions
diff --git a/Lib/threading.py b/Lib/threading.py index 3407083..dfe9d41 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -284,6 +284,7 @@ class Condition: 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 @@ class Condition: 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. @@ -1500,4 +1500,5 @@ Cheng Zhang Kai Zhu Tarek Ziadé Gennadiy Zlobin +Doug Zongker Peter Åstrand @@ -27,6 +27,10 @@ Core and Builtins 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. |