How To Multiprocess Functions
How can non-iterable kwargs be included in the map function of concurrent.futures? For example, in the code below, how can c be called as False for all function calls of single? Th
Solution 1:
You can use a functools.partial
for that:
from functools import partial
single2 = partial(single,c=False)
will generate a function single2
where c
is set to False
. So you can use:
from functools import partial
results = executor.map(partial(single,c=False), iterable_a, iterable_b)
So your map
calls a function generated from partial(single,c=False)
and you map
with that function.
Post a Comment for "How To Multiprocess Functions"