From 1fdfb5299ef121031c5d1a504181c19d2401197c Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Thu, 15 Jul 2021 06:57:54 -0400 Subject: [PATCH] moonraker: create a new asyncio event loop on restart This should guarantee that no dangliing callbacks are leftover on a soft restart. Signed-off-by: Eric Callahan --- moonraker/moonraker.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/moonraker/moonraker.py b/moonraker/moonraker.py index cbd6be7..c86a768 100755 --- a/moonraker/moonraker.py +++ b/moonraker/moonraker.py @@ -7,6 +7,7 @@ from __future__ import annotations import argparse +from asyncio.events import new_event_loop import sys import importlib import os @@ -765,10 +766,13 @@ def main() -> None: break if server.exit_reason == "terminate": break + event_loop.close() # Since we are running outside of the the server # it is ok to use a blocking sleep here time.sleep(.5) logging.info("Attempting Server Restart...") + asyncio.set_event_loop(asyncio.new_event_loop()) + event_loop = EventLoop() event_loop.close() logging.info("Server Shutdown") ql.stop()