Title: concurrent.futures.wait() blocks forever when given duplicate Futures
Type: Stage:
Components: Versions: Python 3.3, Python 3.4
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: mark.dickinson, tim.peters, vstinner
Priority: normal Keywords: patch

Created on 2014-01-23 15:33 by glangford, last changed 2014-07-18 16:45 by glangford.

File name Uploaded Description Edit glangford, 2014-01-23 15:33
issue20369.patch glangford, 2014-01-23 19:20 review
issue20369.patch glangford, 2014-01-25 21:46 review
issue20369.patch glangford, 2014-01-27 17:49 review
Messages (4)
msg208960 - (view) Author: Glenn Langford (glangford) * Date: 2014-01-23 15:33
For a Future f which has already completed, 
  wait( [f,f], return_when=ALL_COMPLETED ) 
blocks forever.

This is because the test in wait():

  if len(done) == len(fs)

is comparing the length of a set to the length of a list. 

If f has not completed, wait( [f,f] ) will yield f once. The behaviour should be consistent with as_completed() - see issue #20367.
msg208979 - (view) Author: Glenn Langford (glangford) * Date: 2014-01-23 19:20
Proposed patch...please treat with an appropriate level of suspicion since this is my first patch submission. :-)  

A corresponding change will be made to as_completed() for #20367. Suggestions welcome.
msg209241 - (view) Author: Glenn Langford (glangford) * Date: 2014-01-25 21:46
Updated patch with a test case, and added a minor note to the docstring to clarify behaviour.

The use of sleep() in the test is not great, but it is the most obvious way to test and it is consistent with the approach used in other concurrent test cases.
msg209454 - (view) Author: Glenn Langford (glangford) * Date: 2014-01-27 17:49
Updated patch with change to Doc/library/concurrent.futures.rst.
Date User Action Args
2014-07-18 16:45:55glangfordsetnosy: - glangford
2014-01-27 17:49:41glangfordsetfiles: + issue20369.patch

messages: + msg209454
2014-01-25 21:46:30glangfordsetfiles: + issue20369.patch

messages: + msg209241
2014-01-23 19:20:56glangfordsetfiles: + issue20369.patch
keywords: + patch
messages: + msg208979
2014-01-23 15:33:51glangfordcreate