Clean stop of Python bottle webserver when started from subprocess
Posted
by luc
on Stack Overflow
See other posts from Stack Overflow
or by luc
Published on 2010-04-15T07:48:02Z
Indexed on
2010/04/15
7:53 UTC
Read the original article
Hit count: 474
Hello all,
I would like to embed the great Bottle web framework into a small application (1st target is Windows OS). This app starts the bottle webserver thanks to the subprocess module.
import subprocess
p = subprocess.Popen('python websrv.py')
The bottle app is quite simple
@route("/")
def index():
return template('index')
run(reloader=True)
It starts the default webserver into a Windows console.
All seems Ok except the fact that I must press Ctrl-C to close the bottle webserver. I would like that the master app terminates the webserver when it shutdowns. I can't find a way to do that (p.terminate() doesn't work in this case unfortunately)
Any idea?
Thanks in advance
© Stack Overflow or respective owner