I want to launch this command from python in a background thread while keeping the main program thread running using envoy:
envoy.run('python -m SimpleHTTPServer 9999')
This works but hangs, it doesn’t run threaded as it should do, so that I can’t kill it afterwards when I’m done. I tried to wrap it into a Thread:
class FileServerThread(Thread):
def __init__(self):
Thread.__init__(self)
self.process = None
def run(self):
self.process = envoy.run('python -m SimpleHTTPServer 9999')
def kill(self):
self.process.kill
but again, this doesn’t work because self.process is never assigned (since envoy.run doesn’t end and never returns).
Any help?
I am afraid that you can’t do it with
run, but you can do it byconnect.however, after
kill(), I found that the process became a zombie,p.block()will solve it.