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
f007876b
Commit
f007876b
authored
13 years ago
by
Brian Quinlan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #11777: Executor.map does not submit futures until iter.next() is called
parent
0df80926
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
10 deletions
+22
-10
Lib/concurrent/futures/_base.py
Lib/concurrent/futures/_base.py
+13
-9
Lib/test/test_concurrent_futures.py
Lib/test/test_concurrent_futures.py
+9
-1
No files found.
Lib/concurrent/futures/_base.py
View file @
f007876b
...
...
@@ -536,15 +536,19 @@ class Executor(object):
fs
=
[
self
.
submit
(
fn
,
*
args
)
for
args
in
zip
(
*
iterables
)]
try
:
for
future
in
fs
:
if
timeout
is
None
:
yield
future
.
result
()
else
:
yield
future
.
result
(
end_time
-
time
.
time
())
finally
:
for
future
in
fs
:
future
.
cancel
()
# Yield must be hidden in closure so that the futures are submitted
# before the first iterator value is required.
def
result_iterator
():
try
:
for
future
in
fs
:
if
timeout
is
None
:
yield
future
.
result
()
else
:
yield
future
.
result
(
end_time
-
time
.
time
())
finally
:
for
future
in
fs
:
future
.
cancel
()
return
result_iterator
()
def
shutdown
(
self
,
wait
=
True
):
"""Clean-up the resources associated with the Executor.
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_concurrent_futures.py
View file @
f007876b
...
...
@@ -369,7 +369,15 @@ class ExecutorTest(unittest.TestCase):
class
ThreadPoolExecutorTest
(
ThreadPoolMixin
,
ExecutorTest
):
pass
def
test_map_submits_without_iteration
(
self
):
"""Tests verifying issue 11777."""
finished
=
[]
def
record_finished
(
n
):
finished
.
append
(
n
)
self
.
executor
.
map
(
record_finished
,
range
(
10
))
self
.
executor
.
shutdown
(
wait
=
True
)
self
.
assertCountEqual
(
finished
,
range
(
10
))
class
ProcessPoolExecutorTest
(
ProcessPoolMixin
,
ExecutorTest
):
...
...
This diff is collapsed.
Click to expand it.
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