from time import sleep from multiprocessing import Process g1 = 100 g2 = 200 # a function that blocks for a moment def task(): global g1 global g2 # block for a moment print(f'task: g1 = {g1}') sleep(5) g1 = 10000 g2 = 20000 print(f'task: g1 = {g1}, g2 = {g2}') # create a process p = Process(target=task) # run the process g1 = 1000 g2 = 2000 p.start() # wait for the child process to finish p.join() print(f'main process: g1 = {g1}, g2 = {g2}')