python - Unable to kill Flask server launched by Popen on Ubuntu -
What I'm trying to achieve is the lesser requirement. and the actual server script. > > > > > > > > > > > > > > > < On order (): see DEF (): make_response ("") return if __name__ == "__main__": app.run (host = "localhost", port = 1234) line i is still hanging there. I have to hit it with the command line In fact, the last line of I tried to kill with Normally What options do I have? Strangely, my script works perfectly well on Mac OSX (I'm on 10.8.5, Mountain Lion). So far, I have tested on two Ubuntu 12.04 machines and they have the same behavior. I'm running Python 2.7.3 on my Mac OSX and Python 2.7.2 on both Mac OSX. Correction : I have only one option to use. But I do not want to and yes, I have to launch one using Popen. How to verify this? Try # run PYE import requests import time from subprocess import Popen, PIPE server = popon ("./exp.py", stdout = PIPE, stderr = PIPE, shell = True) Time.sleep (1) res = requests.get ("http: // localhost: 1234 /") res.status_code == 200 server.kill () server.terminate () res = requests.get ("http: // Localhost: 1234 / ") Print
python run.py Run From Shell:
(t) Khushon @ Fubini: / tmp $ ps aux | Grep app Khushan 21452 0.6 0.4 16416 9992 points / 2s 03:50 0:00 dragon ./app.py Yeukhon 21471 0.0 0.0 4384 804 points / 2s + 03:51 0:00 grep --color = auto app
run.py Tells that the server was still alive (200 was returned)
os.kill (server) .pid, signal.SIGTERM) and
os.kill (server.pid, signal.SIGKILL) < / Code> but none works
kill will work, but I do not really know why it can not get the signal. I'm sure somehow refuses to shut down the flask.
shell = true
, the command is run by subshell.
server = popon ("./exp.py", stdout = PIPE, stderr = PIPE, shell = true)
server Terminate will kill subsealand, but the web server will not be killed.
print server.pid after the
PP call, and compare it with
ps output.
Comments
Post a Comment