multiprocessing

A forum for general discussion of the Python programming language.

multiprocessing

Postby honza » Sun Jun 09, 2013 1:07 pm

Good afternoon,

I have problem with basic example of multiprocessing. The p.map(), returns error and I do not know why. Problem you can see on picture and here is code:

from multiprocessing import Pool
p = Pool(5)
def f(x):
return x*x
p.map(f, [1,2,3])

Do you now where is a problem, please? Thank you and have a nice day.
Jan
Attachments
error_multi.png
error_multi.png (227.59 KiB) Viewed 732 times
honza
 
Posts: 1
Joined: Sun Jun 09, 2013 12:54 pm

Re: multiprocessing

Postby Yoriz » Sun Jun 09, 2013 6:01 pm

It tells you right before that example that the following example will not work in the interactive interpreter.

Note
Functionality within this package requires that the __main__ module be importable by the children. This is covered in Programming guidelines however it is worth pointing out here. This means that some examples, such as the multiprocessing.Pool examples will not work in the interactive interpreter. For example:
Due to the reasons discussed here we will be moving to python-forum.io/ on October 1 2016
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
Yoriz
 
Posts: 1672
Joined: Fri Feb 08, 2013 1:35 am
Location: UK


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 1 guest