3 ms·
It works on the REPL as long as you create the pool after the function has been defined: >>> import multiprocessing >>> def hello(x): ... return
by hcarvalhoalves 13y ago
It works on the REPL as long as you create the pool after the function has been defined:
>>> import multiprocessing
>>> def hello(x):
... return x + 1
...
>>> pool = multiprocessing.Pool(8)
>>> pool.map(hello, range(10))
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
It looks like the pool takes a peek at the module during instantiation. Maybe could be worked around by having a lazy pool that only inspects when you call map.