[issue20367] concurrent.futures.as_completed() fails when given duplicate Futures

STINNER Victor report at bugs.python.org
Fri Jan 24 16:55:05 CET 2014


STINNER Victor added the comment:

Hum, you should also modify the documentation to explicit the
behaviour. Example: "Duplicates futures are only yielded once".

You may add the same sentence in the asyncio.as_completed()
documentation. It looks like asyncio tests doesn't test as_completed()
with duplicated future. You may write a new patch to modify asyncio
doc and tests. It should be very similar.

+        completed = [f for f in futures.as_completed( [f1,f1] ) ]

You can just use list(futures.as_completed([f1,f1])). Please no space
around parenthesis (see the PEP 8).

+        self.assertEqual( len(completed), 1 )

No space around parenthesis (see the PEP 8):
self.assertEqual(len(completed), 1).

You may check the list value instead: self.assertEqual(completed, [f1])

(Why "f1" name? There is no f2, maybe rename to f?)

----------

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


More information about the Python-bugs-list mailing list