cpython: 78a38f8bd5d9 (original) (raw)
Mercurial > cpython
changeset 92269:78a38f8bd5d9
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. [#22185]
Antoine Pitrou solipsis@pitrou.net | |
---|---|
date | Fri, 29 Aug 2014 23:27:33 +0200 |
parents | ab81b4cdc33c(current diff)4cce39cfe46c(diff) |
children | c499cc2c4a06 |
files | Lib/threading.py Misc/ACKS Misc/NEWS |
diffstat | 3 files changed, 11 insertions(+), 5 deletions(-)[+] [-] Lib/threading.py 11 Misc/ACKS 1 Misc/NEWS 4 |
line wrap: on
line diff
--- a/Lib/threading.py +++ b/Lib/threading.py @@ -290,6 +290,7 @@ class Condition: waiter.acquire() self._waiters.append(waiter) saved_state = self._release_save()
gotit = False[](#l1.7) try: # restore state no matter what (e.g., KeyboardInterrupt)[](#l1.8) if timeout is None:[](#l1.9) waiter.acquire()[](#l1.10)
@@ -299,14 +300,14 @@ class Condition: gotit = waiter.acquire(True, timeout) else: gotit = waiter.acquire(False)
if not gotit:[](#l1.15)
try:[](#l1.16)
self._waiters.remove(waiter)[](#l1.17)
except ValueError:[](#l1.18)
pass[](#l1.19) return gotit[](#l1.20) finally:[](#l1.21) self._acquire_restore(saved_state)[](#l1.22)
if not gotit:[](#l1.23)
try:[](#l1.24)
self._waiters.remove(waiter)[](#l1.25)
except ValueError:[](#l1.26)
pass[](#l1.27)
def wait_for(self, predicate, timeout=None): """Wait until a condition evaluates to True.
--- a/Misc/ACKS +++ b/Misc/ACKS @@ -1518,4 +1518,5 @@ Cheng Zhang Kai Zhu Tarek Ziadé Gennadiy Zlobin +Doug Zongker Peter Åstrand
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -124,6 +124,10 @@ Core and Builtins Library ------- +- Issue #22185: Fix an occasional RuntimeError in threading.Condition.wait()