I am studying about multi processing. When I run the below code, I wondered that starting process means process start immediately .
My code as follows:
import time
import multiprocessing
def do_something():
print('Sleeping 1 seconds...')
time.sleep(1)
print('Completed...')
if __name__ == '__main__':
start = time.perf_counter()
processes = []
for _ in range(4):
p = multiprocessing.Process(target=do_something)
p.start()
processes.append(p)
print('Hello~')
for process in processes:
process.join()
finish = time.perf_counter()
print(f'Finished in {round(finish-start,2)} second(s)')
As far as I know, 'start' method do start process. So, I expected that 'Hellow~' would be printed after starting do_something function as follows.
But actual result as follows:
As you can see, 'Hello~' is printed even before starting process!! Why does a such result occur?