- Calling join() on a Process instance makes the calling process to wait for the corresponding process.
- Once the process is complete the called process proceeds.
- In the examples provided on multiprocessing it is the main process that calls the join() method on the Process instances corresponding the child processes.
- Calling join() on the Process instance for the same process results in deadlock.
- join() can be called only on an already started process.
- join() is similar to a person waiting for another person to complete something and proceeding after it.
import multiprocessing as multiproc
mq = multiproc.Queue()
# Create child processes
# Start all the child processes
print("Child processes started....main process waiting for children to complete")
# Wait for all the child processes to complete
print("Child processes completed execution")
while mq.empty() is False:
print("Parent process ending")
Parent process started
Child processes started....main process waiting for children to complete
Child processes completed execution
Parent process ending