From b87e0107c4ea530bbc1a24377646bd10467653f6 Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 26 Jun 2020 15:01:23 +0100 Subject: [PATCH] Nicely stop async event loop for modguis Signed-off-by: falkTX --- source/frontend/modgui/webserver.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/frontend/modgui/webserver.py b/source/frontend/modgui/webserver.py index 00f31fc2a..a83ab69e8 100644 --- a/source/frontend/modgui/webserver.py +++ b/source/frontend/modgui/webserver.py @@ -203,12 +203,14 @@ class WebServerThread(QThread): debug=True) self.fPrepareWasCalled = False + self.fEventLoop = None def run(self): if not self.fPrepareWasCalled: self.fPrepareWasCalled = True if haveAsyncIO: - set_event_loop(new_event_loop()) + self.fEventLoop = new_event_loop() + set_event_loop(self.fEventLoop) self.fApplication.listen(PORT, address="0.0.0.0") if int(os.getenv("MOD_LOG", "0")): enable_pretty_logging() @@ -218,4 +220,6 @@ class WebServerThread(QThread): def stopWait(self): IOLoop.instance().stop() + if self.fEventLoop is not None: + self.fEventLoop.call_soon_threadsafe(self.fEventLoop.stop) return self.wait(5000)