This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author reeyarn
Recipients ned.deily, reeyarn, ronaldoussoren
Date 2020-12-22.02:27:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1608604051.65.0.530063618833.issue42708@roundup.psfhosted.org>
In-reply-to
Content
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]))
History
Date User Action Args
2020-12-22 02:27:31reeyarnsetrecipients: + reeyarn, ronaldoussoren, ned.deily
2020-12-22 02:27:31reeyarnsetmessageid: <1608604051.65.0.530063618833.issue42708@roundup.psfhosted.org>
2020-12-22 02:27:31reeyarnlinkissue42708 messages
2020-12-22 02:27:31reeyarncreate