mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #20319: concurrent.futures.wait() can block forever even if Futures have completed
This commit is contained in:
parent
0ba5f0d386
commit
2b754f49a5
2 changed files with 10 additions and 2 deletions
|
@ -225,7 +225,8 @@ def as_completed(fs, timeout=None):
|
|||
|
||||
finally:
|
||||
for f in fs:
|
||||
f._waiters.remove(waiter)
|
||||
with f._condition:
|
||||
f._waiters.remove(waiter)
|
||||
|
||||
DoneAndNotDoneFutures = collections.namedtuple(
|
||||
'DoneAndNotDoneFutures', 'done not_done')
|
||||
|
@ -272,7 +273,8 @@ def wait(fs, timeout=None, return_when=ALL_COMPLETED):
|
|||
|
||||
waiter.event.wait(timeout)
|
||||
for f in fs:
|
||||
f._waiters.remove(waiter)
|
||||
with f._condition:
|
||||
f._waiters.remove(waiter)
|
||||
|
||||
done.update(waiter.finished_futures)
|
||||
return DoneAndNotDoneFutures(done, set(fs) - done)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue