From 4aae276eca9a9213ad45158d30ae2f15843dd463 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Sat, 4 Oct 2014 20:20:10 +0200 Subject: 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. --- Lib/concurrent/futures/_base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Lib/concurrent/futures/_base.py') diff --git a/Lib/concurrent/futures/_base.py b/Lib/concurrent/futures/_base.py index c13b3b6b29..9e447137ad 100644 --- a/Lib/concurrent/futures/_base.py +++ b/Lib/concurrent/futures/_base.py @@ -520,7 +520,7 @@ class Executor(object): """ raise NotImplementedError() - def map(self, fn, *iterables, timeout=None): + def map(self, fn, *iterables, timeout=None, chunksize=1): """Returns a iterator equivalent to map(fn, iter). Args: @@ -528,6 +528,10 @@ class Executor(object): passed iterables. timeout: The maximum number of seconds to wait. If None, then there is no limit on the wait time. + chunksize: The size of the chunks the iterable will be broken into + before being passed to a child process. This argument is only + used by ProcessPoolExecutor; it is ignored by + ThreadPoolExecutor. Returns: An iterator equivalent to: map(func, *iterables) but the calls may -- cgit v1.2.1