python interpreter waits for child process to die

Posted by Moulik Kallupalam on Stack Overflow See other posts from Stack Overflow or by Moulik Kallupalam
Published on 2011-06-23T23:11:53Z Indexed on 2011/06/24 0:22 UTC
Read the original article Hit count: 169

Filed under:
|

Contents of check.py:

from multiprocessing import Process
import time
import sys

def slp():
 time.sleep(30)
 f=open("yeah.txt","w")
 f.close()

if __name__=="__main__" :
 x=Process(target=slp)
 x.start()
 sys.exit()

In windows 7, from cmd, if I call python check.py, it doesn't immediately exit, but instead waits for 30 seconds. And if I kill cmd, the child dies too- no "yeah.txt" is created.

How do I make ensure the child continues to run even if parent is killed and also that the parent doesn't wait for child process to end?

© Stack Overflow or respective owner

Related posts about python

Related posts about multiprocessing