import multiprocessing
import time
class testM(multiprocessing.Process):
def __init__(self):
multiprocessing.Process.__init__(self)
self.exit = False
def run(self):
while not self.exit:
pass
print "You exited!"
return
def shutdown(self):
self.exit = True
print "SHUTDOWN initiated"
def doshit(self):
print "haha", self.exit
a = testM()
a.start()
time.sleep(3)
a.shutdown()
time.sleep(3)
print a.is_alive()
a.doshit()
exit()
Hey everyone, I am just wondering how come the code above doesn't really print "you exited". What am I doing wrong? if so, may someone point me out the correct way to exit gracefully? ( I am not referring to process.terminate or kill)