WebHost: properly stop worker threads (#3340)

* WebHost: properly stop worker threads

* Less jank

* Forgot the try-catch around the while true
This commit is contained in:
black-sliver
2024-05-19 20:40:36 +02:00
committed by GitHub
parent 019dfb8242
commit e978109410
2 changed files with 27 additions and 11 deletions

View File

@@ -117,7 +117,7 @@ if __name__ == "__main__":
logging.basicConfig(format='[%(asctime)s] %(message)s', level=logging.INFO)
from WebHostLib.lttpsprites import update_sprites_lttp
from WebHostLib.autolauncher import autohost, autogen
from WebHostLib.autolauncher import autohost, autogen, stop
from WebHostLib.options import create as create_options_files
try:
@@ -138,3 +138,11 @@ if __name__ == "__main__":
else:
from waitress import serve
serve(app, port=app.config["PORT"], threads=app.config["WAITRESS_THREADS"])
else:
from time import sleep
try:
while True:
sleep(1) # wait for process to be killed
except (SystemExit, KeyboardInterrupt):
pass
stop() # stop worker threads