Python Flask App Not Exiting With Sys Exit
I'd like to be able to terminate my flask app remotely with an http request like this: import flask import sys master = flask.Flask(__name__) @master.route('/shutdown') def shutd
Solution 1:
I think there's no bug.
As flask is probably catching all exceptions in order to do not stop the main process from serving the application.
As you mention, using os._exit(0) does the work.
As far as I've seen, it's catched by python2.7/SocketServer.py:
598try:
599 self.finish_request(request, client_address)
600 self.shutdown_request(request)
601except:
602 self.handle_error(request, client_address)
603 self.shutdown_request(request)
Which basically catches everything but handles an error.
BTW: Am I the only one who thinks that this could be refactored with a try/except/finally?
Post a Comment for "Python Flask App Not Exiting With Sys Exit"