Catches SystemExit #2113
-
@socketio.event
def stop():
import os, sys
#quit(166)
#exit(166)
#sys.exit(166)
#os._exit(166) The first three stop the function call but don't exit the program. Only I have determined it must be flask_socketio catching the SystemExit exception. I have looked through the SocketIO class and think it's to do with this bare except in
When I start working with files in this program, it needs to clean up properly, hence why Is there anything I can do to fix this in my code, or would it need to be something changed by FSIO? Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Stopping is something that is supported by the web server. What web server are you using? |
Beta Was this translation helpful? Give feedback.
But this is a web application, you can't just exit and expect everything will be gracefully cleaned up. As I said, each web server offers their own solution for shutting down.
For web servers started with
socketio.run()
you can stop the web server by callingsocketio.stop()
from inside a Socket.IO event handler. But this is currently not working when using the Flask web server, because this server used to support a clean exit, but this functionality was removed (see pallets/werkzeug#2363).