Commit 050ce6a4 authored by Brian Quinlan's avatar Brian Quinlan

Merge to tip.

parents c8d6e06f 05b88306
...@@ -536,15 +536,19 @@ class Executor(object): ...@@ -536,15 +536,19 @@ class Executor(object):
fs = [self.submit(fn, *args) for args in zip(*iterables)] fs = [self.submit(fn, *args) for args in zip(*iterables)]
try: # Yield must be hidden in closure so that the futures are submitted
for future in fs: # before the first iterator value is required.
if timeout is None: def result_iterator():
yield future.result() try:
else: for future in fs:
yield future.result(end_time - time.time()) if timeout is None:
finally: yield future.result()
for future in fs: else:
future.cancel() yield future.result(end_time - time.time())
finally:
for future in fs:
future.cancel()
return result_iterator()
def shutdown(self, wait=True): def shutdown(self, wait=True):
"""Clean-up the resources associated with the Executor. """Clean-up the resources associated with the Executor.
......
...@@ -369,7 +369,15 @@ class ExecutorTest(unittest.TestCase): ...@@ -369,7 +369,15 @@ class ExecutorTest(unittest.TestCase):
class ThreadPoolExecutorTest(ThreadPoolMixin, ExecutorTest): 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): class ProcessPoolExecutorTest(ProcessPoolMixin, ExecutorTest):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment