New submission from Reeyarn Li :
I just run the sample code from multiprocessing's documentation page:
#https://docs.python.org/3/library/multiprocessing.html
from multiprocessing import Pool
def f(x):
return x*x
with Pool(5) as p:
print(p.map(f, [1, 2, 3]))
## end of code
A
Reeyarn Li added the comment:
There is already a solution:
https://stackoverflow.com/questions/41385708/multiprocessing-example-giving-attributeerror
When putting the function into a separate file and import it in the main file,
there is no error at all.
##File: defs.py
def f(x