Comments¶
multiprocess is a fork of the Python standard libary multiprocessing . multiprocess extends multiprocessing to provide enhanced serialization, using dill. multiprocess leverages multiprocessing to support the spawning of processes using the API of the python standard library's threading module.
multiprocessing.Pool.map
does not work with lambda functions due to the fact that lambda functions cannot be pickled. There are multiple approaches to avoid the issue. You can define a function or usefunctools.partial
.
In [10]:
from multiprocessing import Pool
In [11]:
pool = Pool(2)
In [12]:
numbers = [
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16],
]
In [13]:
pool.map(sum, numbers)
Out[13]:
In [ ]: