from time import sleep import multiprocessing import sys n = 20 if (len(sys.argv) > 1) : n = int (sys.argv[1]) # a function that blocks for a moment def task(): res = [i for i in range(n)] toMain.put(res) print("task done!") toMain = multiprocessing.Queue() # create a process p = multiprocessing.Process(target=task) # run the process p.start() p.join() print("Main thread done")