Multiprocessing Don't Start
i just started learning about multiprocessing module today and i was trying this code but it didn't work and i don't know why it doesn't give me any error or any thing it just end
Solution 1:
Umm, you can still use start and join
import multiprocessing
def x ():
print ("hi")
example=multiprocessing.Process(target=x)
example.start() # START
example.join() # JOINRunning in the python repl, I get,
>>>import multiprocessing>>>defx ():...print ("hi")...>>>example=multiprocessing.Process(target=x)>>>example.start(); example.join()
hi
>>>The only reason the second example seems to work is because you are calling x (notice target=x() vs target=x).
Your first example works but without join, the program is terminated after main is finished (but before the child process is finished). This creates a zombie process and possibly prevents it from doing more work, like printing hi to standard output
Post a Comment for "Multiprocessing Don't Start"