mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-10 03:37:28 -03:00
Stop Waitress immediately rather than waiting
This commit is contained in:
parent
9a19c47185
commit
e434c0463c
1 changed files with 13 additions and 1 deletions
|
@ -372,7 +372,7 @@ class Web:
|
|||
self.socketio.stop()
|
||||
|
||||
if self.waitress:
|
||||
self.waitress.close()
|
||||
self.waitress_custom_shutdown()
|
||||
|
||||
def cleanup(self):
|
||||
"""
|
||||
|
@ -385,3 +385,15 @@ class Web:
|
|||
dir.cleanup()
|
||||
|
||||
self.cleanup_tempdirs = []
|
||||
|
||||
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:
|
||||
trigger.handle_close()
|
||||
self.waitress.maintenance(0)
|
||||
self.waitress.task_dispatcher.shutdown()
|
||||
return True
|
||||
|
|
Loading…
Reference in a new issue