summaryrefslogtreecommitdiffstats
path: root/Lib/concurrent
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2014-01-26 17:57:51 (GMT)
committerGuido van Rossum <guido@python.org>2014-01-26 17:57:51 (GMT)
commite6994ff6e341d049ca974d88f14ad608f5cf7a64 (patch)
treefdf31e84a04b142f35c0d16fd1e36343a3e4119e /Lib/concurrent
parent252fd0c24b15e38c80053a9569272654fd12868a (diff)
downloadcpython-e6994ff6e341d049ca974d88f14ad608f5cf7a64.zip
cpython-e6994ff6e341d049ca974d88f14ad608f5cf7a64.tar.gz
cpython-e6994ff6e341d049ca974d88f14ad608f5cf7a64.tar.bz2
Fix issue #20367: concurrent.futures.as_completed() for duplicate arguments.
Patch by Glenn Langford.
Diffstat (limited to 'Lib/concurrent')
-rw-r--r--Lib/concurrent/futures/_base.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/concurrent/futures/_base.py b/Lib/concurrent/futures/_base.py
index 3d03280..c3b1f01 100644
--- a/Lib/concurrent/futures/_base.py
+++ b/Lib/concurrent/futures/_base.py
@@ -181,7 +181,8 @@ def as_completed(fs, timeout=None):
Returns:
An iterator that yields the given Futures as they complete (finished or
- cancelled).
+ cancelled). If any given Futures are duplicated, they will be returned
+ once.
Raises:
TimeoutError: If the entire result iterator could not be generated
@@ -190,11 +191,12 @@ def as_completed(fs, timeout=None):
if timeout is not None:
end_time = timeout + time.time()
+ fs = set(fs)
with _AcquireFutures(fs):
finished = set(
f for f in fs
if f._state in [CANCELLED_AND_NOTIFIED, FINISHED])
- pending = set(fs) - finished
+ pending = fs - finished
waiter = _create_and_install_waiters(fs, _AS_COMPLETED)
try: