Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b754f4

Browse files
committed
Issue #20319: concurrent.futures.wait() can block forever even if Futures have completed
1 parent 0ba5f0d commit 2b754f4

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

Lib/concurrent/futures/_base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ def as_completed(fs, timeout=None):
225225

226226
finally:
227227
for f in fs:
228-
f._waiters.remove(waiter)
228+
with f._condition:
229+
f._waiters.remove(waiter)
229230

230231
DoneAndNotDoneFutures = collections.namedtuple(
231232
'DoneAndNotDoneFutures', 'done not_done')
@@ -272,7 +273,8 @@ def wait(fs, timeout=None, return_when=ALL_COMPLETED):
272273

273274
waiter.event.wait(timeout)
274275
for f in fs:
275-
f._waiters.remove(waiter)
276+
with f._condition:
277+
f._waiters.remove(waiter)
276278

277279
done.update(waiter.finished_futures)
278280
return DoneAndNotDoneFutures(done, set(fs) - done)

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ Library
6969

7070
- Issue #17481: inspect.getfullargspec() now uses inspect.signature() API.
7171

72+
- Issue #15304: concurrent.futures.wait() can block forever even if
73+
Futures have completed. Patch by Glenn Langford.
74+
75+
Fix warning message when `os.chdir()` fails inside
76+
`test.support.temp_cwd()`. Patch by Chris Jerdonek.
77+
7278
IDLE
7379
----
7480

0 commit comments

Comments
 (0)