why the print function on multiprocessing is not printing?

  multiprocessing, python

I have the following simple script for multiprocessing but is not printing the messages.
Can anyone identify if I am doing any mistakes?

import multiprocessing
import time



start = time.perf_counter()


def do_something():
    print('Sleeping for 1 second')
    time.sleep(1)
    print('Done sleeping...')
    
if __name__ == '__main__':
    p1 = multiprocessing.Process(target=do_something)
    p2 = multiprocessing.Process(target=do_something)
    
    p1.start()
    p2.start()
    
    p1.join()
    p2.join()

    finish = time.perf_counter()
    print(f'Finished in {round(finish-start,2)} seconds')

Source: Python Questions

LEAVE A COMMENT