Reputation: 10850
I had an asynchronous function being called like this:
from multiprocessing import Process
def my_function(arg1, arg2):
print 'Long process begins'
p = Process(target=my_function, args=(arg1, arg2,)).start()
How can I make this blocking? I need to finish the process before running the rest of the script.
Upvotes: 1
Views: 195
Reputation: 34698
Use p.join()
Block the calling thread until the process whose join() method is called terminates or until the optional timeout occurs.
If timeout is None then there is no timeout.
A process can be joined many times.
A process cannot join itself because this would cause a deadlock. It is an error to attempt to join a process before it has been started.
Upvotes: 2