from time import sleep from multiprocessing import Process # a function that blocks for a moment def task(): # block for a moment sleep(1) # display a message print('task Process running for 1 second') sleep(10) print('task Process running for 11 second') # create a process p = Process(target=task) # run the process p.start() print('Main thread after task process starts...') sleep(2) print('Main thread 2 seconds after task process starts...') sleep(5) print('Main thread waiting for the process after 4 seconds...') # wait for the process to finish p.join()