Reputation: 1455
I am trying to run 2 things in parallel with multiprocessing, I have this code:
from multiprocessing import Process
def secondProcess():
x = 0
while True:
x += 1
if __name__ == '__main__':
p = Process(target=secondProcess())
p.start()
print "blah"
p.join()
What seems to happen is that the second process starts running but it does not proceed with running the parent process, it just hangs until the second process finishes (so in this case never). So "blah" is never printed.
How can I make it run both in parallel?
Upvotes: 3
Views: 317
Reputation: 3820
You don't want to call secondProcess
. You want to pass it as a parameter.
p = Process(target=secondProcess)
Upvotes: 5