Reeyarn Li <reey...@gmail.com> 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):
    return x*x


##File: run.py

from multiprocessing import Pool
import defs

if __name__ == '__main__':
    with Pool(5) as p:
        print(p.map(defs.f, [1, 2, 3]))

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42708>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to