KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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 dostuff(self): print "haha", self.exit a = testM() a.start() time.sleep(3) a.shutdown() time.sleep(3) print a.is_alive() a.dostuff() exit() 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)
Tags (comma-separated)
Save Edits
Cancel