diff options
author | Micah Lee <micah@micahflee.com> | 2021-09-03 13:23:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-03 13:23:43 -0700 |
commit | aac8020c3ece54004009eddd04daf751a98aa305 (patch) | |
tree | e1efe0b395d9045bc12348f4ad88aae50e268468 | |
parent | 46b3c01e82a87c5e283bbc6cb073b218bd9bdb57 (diff) | |
parent | 5a7ab3c12e97e5ca340eebd61c5c01633eb89e36 (diff) | |
download | onionshare-aac8020c3ece54004009eddd04daf751a98aa305.tar.gz onionshare-aac8020c3ece54004009eddd04daf751a98aa305.zip |
Merge pull request #1416 from SaptakS/fix-chat-shutdown
Adds exception for ConnectionError in chat mode during shutdown
-rw-r--r-- | cli/onionshare_cli/web/web.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/cli/onionshare_cli/web/web.py b/cli/onionshare_cli/web/web.py index 3ba27ef7..e12fccc7 100644 --- a/cli/onionshare_cli/web/web.py +++ b/cli/onionshare_cli/web/web.py @@ -361,9 +361,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): """ |