summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaptak S <saptak013@gmail.com>2021-09-02 18:57:16 +0530
committerSaptak S <saptak013@gmail.com>2021-09-02 18:57:21 +0530
commit5a7ab3c12e97e5ca340eebd61c5c01633eb89e36 (patch)
tree15c9d142346ec6675634b36ea079afde7ce8913e
parentede47aaf48a0e83d6253da085b3360248bf2525d (diff)
downloadonionshare-5a7ab3c12e97e5ca340eebd61c5c01633eb89e36.tar.gz
onionshare-5a7ab3c12e97e5ca340eebd61c5c01633eb89e36.zip
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.
-rw-r--r--cli/onionshare_cli/web/web.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/cli/onionshare_cli/web/web.py b/cli/onionshare_cli/web/web.py
index 0f2dfe7e..04632184 100644
--- a/cli/onionshare_cli/web/web.py
+++ b/cli/onionshare_cli/web/web.py
@@ -372,9 +372,18 @@ class Web:
# 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)
if self.running:
- requests.get(
- f"http://127.0.0.1:{port}/{self.shutdown_password}/shutdown"
- )
+ try:
+ requests.get(
+ 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):
"""