File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -290,6 +290,7 @@ def wait(self, timeout=None):
290290 waiter .acquire ()
291291 self ._waiters .append (waiter )
292292 saved_state = self ._release_save ()
293+ gotit = False
293294 try : # restore state no matter what (e.g., KeyboardInterrupt)
294295 if timeout is None :
295296 waiter .acquire ()
@@ -299,14 +300,14 @@ def wait(self, timeout=None):
299300 gotit = waiter .acquire (True , timeout )
300301 else :
301302 gotit = waiter .acquire (False )
302- if not gotit :
303- try :
304- self ._waiters .remove (waiter )
305- except ValueError :
306- pass
307303 return gotit
308304 finally :
309305 self ._acquire_restore (saved_state )
306+ if not gotit :
307+ try :
308+ self ._waiters .remove (waiter )
309+ except ValueError :
310+ pass
310311
311312 def wait_for (self , predicate , timeout = None ):
312313 """Wait until a condition evaluates to True.
Original file line number Diff line number Diff line change @@ -1518,4 +1518,5 @@ Cheng Zhang
15181518Kai Zhu
15191519Tarek Ziadé
15201520Gennadiy Zlobin
1521+ Doug Zongker
15211522Peter Åstrand
Original file line number Diff line number Diff line change @@ -124,6 +124,10 @@ Core and Builtins
124124Library
125125-------
126126
127+ - Issue #22185: Fix an occasional RuntimeError in threading.Condition.wait()
128+ caused by mutation of the waiters queue without holding the lock. Patch
129+ by Doug Zongker.
130+
127131- Issue #22287: On UNIX, _PyTime_gettimeofday() now uses
128132 clock_gettime(CLOCK_REALTIME) if available. As a side effect, Python now
129133 depends on the librt library on Solaris and on Linux (only with glibc older
You can’t perform that action at this time.
0 commit comments