Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b9915973
Commit
b9915973
authored
Jan 27, 2014
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #20367: Fix behavior of concurrent.futures.as_completed() for duplicate
arguments. Patch by Glenn Langford.
parent
d1c85fd2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
3 deletions
+17
-3
Doc/library/concurrent.futures.rst
Doc/library/concurrent.futures.rst
+2
-1
Lib/concurrent/futures/_base.py
Lib/concurrent/futures/_base.py
+4
-2
Lib/test/test_concurrent_futures.py
Lib/test/test_concurrent_futures.py
+7
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/concurrent.futures.rst
View file @
b9915973
...
...
@@ -368,7 +368,8 @@ Module Functions
Returns an iterator over the :class:`Future` instances (possibly created by
different :class:`Executor` instances) given by *fs* that yields futures as
they complete (finished or were cancelled). Any futures that completed
they complete (finished or were cancelled). Any futures given by *fs* that
are duplicated will be returned once. Any futures that completed
before :func:`as_completed` is called will be yielded first. The returned
iterator raises a :exc:`TimeoutError` if :meth:`~iterator.__next__` is
called and the result isn't available after *timeout* seconds from the
...
...
Lib/concurrent/futures/_base.py
View file @
b9915973
...
...
@@ -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
:
...
...
Lib/test/test_concurrent_futures.py
View file @
b9915973
...
...
@@ -344,6 +344,13 @@ class AsCompletedTests:
SUCCESSFUL_FUTURE
]),
completed_futures
)
def
test_duplicate_futures
(
self
):
# Issue 20367. Duplicate futures should not raise exceptions or give
# duplicate responses.
future1
=
self
.
executor
.
submit
(
time
.
sleep
,
2
)
completed
=
[
f
for
f
in
futures
.
as_completed
([
future1
,
future1
])]
self
.
assertEqual
(
len
(
completed
),
1
)
class
ThreadPoolAsCompletedTests
(
ThreadPoolMixin
,
AsCompletedTests
,
unittest
.
TestCase
):
pass
...
...
Misc/ACKS
View file @
b9915973
...
...
@@ -703,6 +703,7 @@ Ronan Lamy
Torsten Landschoff
Łukasz Langa
Tino Lange
Glenn Langford
Andrew Langmead
Detlef Lannert
Soren Larsen
...
...
Misc/NEWS
View file @
b9915973
...
...
@@ -50,6 +50,9 @@ Core and Builtins
Library
-------
- Issue #20367: Fix behavior of concurrent.futures.as_completed() for
duplicate arguments. Patch by Glenn Langford.
- Issue #8260: The read(), readline() and readlines() methods of
codecs.StreamReader returned incomplete data when were called after
readline() or read(size). Based on patch by Amaury Forgeot d'
Arc
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment