aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorMiguel Jacq <mig@mig5.net>2023-05-31 15:38:52 +1000
committerMiguel Jacq <mig@mig5.net>2023-05-31 15:38:52 +1000
commit4439838ee7d115e9a3f7eda212fb053649b44319 (patch)
treec336627834865723382b63dcb0813bb7954f91a8 /cli
parentdd55e78d6345061ae9317231b9d831132636f1fc (diff)
downloadonionshare-4439838ee7d115e9a3f7eda212fb053649b44319.tar.gz
onionshare-4439838ee7d115e9a3f7eda212fb053649b44319.zip
Raise a Waitress exception into the UI with a modal dialog and reset the share if it occurs
Diffstat (limited to 'cli')
-rw-r--r--cli/onionshare_cli/web/web.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/cli/onionshare_cli/web/web.py b/cli/onionshare_cli/web/web.py
index 7da05509..a6ccbeb0 100644
--- a/cli/onionshare_cli/web/web.py
+++ b/cli/onionshare_cli/web/web.py
@@ -57,6 +57,12 @@ except Exception:
pass
+class WaitressException(Exception):
+ """
+ There was a problem starting the waitress web server.
+ """
+
+
class Web:
"""
The Web object is the OnionShare web server, powered by flask
@@ -349,14 +355,17 @@ class Web:
if self.mode == "chat":
self.socketio.run(self.app, host=host, port=port)
else:
- self.waitress = create_server(
- self.app,
- host=host,
- port=port,
- clear_untrusted_proxy_headers=True,
- ident="OnionShare",
- )
- self.waitress.run()
+ try:
+ self.waitress = create_server(
+ self.app,
+ host=host,
+ port=port,
+ clear_untrusted_proxy_headers=True,
+ ident="OnionShare",
+ )
+ self.waitress.run()
+ except Exception as e:
+ raise WaitressException(f"Error starting Waitress: {e}")
def stop(self, port):
"""
@@ -389,7 +398,6 @@ class Web:
def waitress_custom_shutdown(self):
"""Shutdown the Waitress server immediately"""
# Code borrowed from https://github.com/Pylons/webtest/blob/4b8a3ebf984185ff4fefb31b4d0cf82682e1fcf7/webtest/http.py#L93-L104
- self.waitress.was_shutdown = True
while self.waitress._map:
triggers = list(self.waitress._map.values())
for trigger in triggers: