I want to start a daemon process using multiprocessing exiting the main thread. I wrote this code:
import multiprocessing as mp
from time import sleep
def mytarget():
while True:
print "yes"
sleep(1)
process = mp.Process(target=mytarget)
process.daemon = True
process.start()
But the daemon process doesn't appear. I know I can solve it using os.fork like this:
import os
from time import sleep
def mytarget():
while True:
print "yes"
sleep(1)
pid = os.fork()
if pid == 0:
mytarget()
But it's not supported in Windows. So I need a solution for multiprocessing module. Thanks!