I'm exploring the Python multiprocessing module and don't understand why the following code does not print anything at all. Without the while-loop the program prints Worker_1 as expected.
import multiprocessing, time
def worker1():
print 'Worker_1'
while 1:
print 'Worker_1'
time.sleep(3)
return
if __name__ == '__main__':
jobs = []
p = multiprocessing.Process(target=worker1)
jobs.append(p)
p.start()
p.join()after yourp.start(). If the main program exits after the subprocess is started, does the subprocess continue? I don't think so, but I don't know. Note that this means you'll have to do some shenanigans to make the worker stop when you want it to. Alternatively, look at the fork module maybe.