[New-bugs-announce] [issue20319] concurrent.futures.wait() can block forever even if Futures have completed

Glenn Langford report at bugs.python.org
Tue Jan 21 01:18:39 CET 2014


New submission from Glenn Langford:

concurrent.futures.wait() can get into a state where it blocks forever on waiter.event.wait(), even when the underlying Futures have completed.

This is demonstrated in a stress test where a large number of wait() calls are run in multiple threads, contending for the same Futures.

The cause is believed to be waiter removal, which is done without locking the Future. 

A suggested fix which appears to work is to change the following code in wait():

for f in fs:
    f._waiters.remove(waiter)

to:

for f in fs:
    with f._condition:
        f._waiters.remove(waiter)

----------
components: Library (Lib)
files: stress_wait.py
messages: 208592
nosy: glangford
priority: normal
severity: normal
status: open
title: concurrent.futures.wait() can block forever even if Futures have completed
type: behavior
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file33580/stress_wait.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20319>
_______________________________________


More information about the New-bugs-announce mailing list