Adds exception for ConnectionError in chat mode during shutdown

The way flask-socketio stops a connection when running using
eventlet is by raising SystemExit to abort all the processes.
Hence the connections are closed and no response is returned
So I am just catching the ConnectionError to check if it was
chat mode, in which case it's okay.
This commit is contained in:
Saptak S 2021-09-02 18:57:16 +05:30
parent ede47aaf48
commit 5a7ab3c12e
No known key found for this signature in database
GPG Key ID: 2D9B32E54C68A3FB

View File

@ -372,9 +372,18 @@ class Web:
# To stop flask, load http://shutdown:[shutdown_password]@127.0.0.1/[shutdown_password]/shutdown # To stop flask, load http://shutdown:[shutdown_password]@127.0.0.1/[shutdown_password]/shutdown
# (We're putting the shutdown_password in the path as well to make routing simpler) # (We're putting the shutdown_password in the path as well to make routing simpler)
if self.running: if self.running:
try:
requests.get( requests.get(
f"http://127.0.0.1:{port}/{self.shutdown_password}/shutdown" f"http://127.0.0.1:{port}/{self.shutdown_password}/shutdown"
) )
except requests.exceptions.ConnectionError as e:
# The way flask-socketio stops a connection when running using
# eventlet is by raising SystemExit to abort all the processes.
# Hence the connections are closed and no response is returned
# to the above request. So I am just catching the ConnectionError
# to check if it was chat mode, in which case it's okay
if self.mode != "chat":
raise e
def cleanup(self): def cleanup(self):
""" """