summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-10-04 18:20:10 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-10-04 18:20:10 (GMT)
commit4aae276eca9a9213ad45158d30ae2f15843dd463 (patch)
treee3ec365b19f7eb88212595c3ea47f3362bfe75e3 /Lib/test
parente4f47088af0040d73449d0cb0fe1e6d863f3ad07 (diff)
downloadcpython-4aae276eca9a9213ad45158d30ae2f15843dd463.zip
cpython-4aae276eca9a9213ad45158d30ae2f15843dd463.tar.gz
cpython-4aae276eca9a9213ad45158d30ae2f15843dd463.tar.bz2
Issue #11271: concurrent.futures.Executor.map() now takes a *chunksize*
argument to allow batching of tasks in child processes and improve performance of ProcessPoolExecutor. Patch by Dan O'Reilly.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_concurrent_futures.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py
index 11560e6..7f92618 100644
--- a/Lib/test/test_concurrent_futures.py
+++ b/Lib/test/test_concurrent_futures.py
@@ -464,6 +464,22 @@ class ProcessPoolExecutorTest(ProcessPoolMixin, ExecutorTest, unittest.TestCase)
# Submitting other jobs fails as well.
self.assertRaises(BrokenProcessPool, self.executor.submit, pow, 2, 8)
+ def test_map_chunksize(self):
+ def bad_map():
+ list(self.executor.map(pow, range(40), range(40), chunksize=-1))
+
+ ref = list(map(pow, range(40), range(40)))
+ self.assertEqual(
+ list(self.executor.map(pow, range(40), range(40), chunksize=6)),
+ ref)
+ self.assertEqual(
+ list(self.executor.map(pow, range(40), range(40), chunksize=50)),
+ ref)
+ self.assertEqual(
+ list(self.executor.map(pow, range(40), range(40), chunksize=40)),
+ ref)
+ self.assertRaises(ValueError, bad_map)
+
class FutureTests(unittest.TestCase):
def test_done_callback_with_result(self):