When using multiprocessing.pool and pool.map, it seems that the map function has to be defined before creating the pool. Why is this necessary?
Here is the working version:
import multiprocessing
def my_power(x):
return x * x
_pool = multiprocessing.Pool()
my_list = _pool.map(my_power, list(range(10)))
print(my_list)
The version that gets the error, AttributeError: Can't get attribute 'my_power'...
_pool = multiprocessing.Pool()
def my_power(x):
return x * x
my_list = _pool.map(my_power, list(range(10)))
print(my_list)