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 <arksine.code@gmail.com>
This commit is contained in:
parent
0d1431395e
commit
1fdfb5299e
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import argparse
|
import argparse
|
||||||
|
from asyncio.events import new_event_loop
|
||||||
import sys
|
import sys
|
||||||
import importlib
|
import importlib
|
||||||
import os
|
import os
|
||||||
|
@ -765,10 +766,13 @@ def main() -> None:
|
||||||
break
|
break
|
||||||
if server.exit_reason == "terminate":
|
if server.exit_reason == "terminate":
|
||||||
break
|
break
|
||||||
|
event_loop.close()
|
||||||
# Since we are running outside of the the server
|
# Since we are running outside of the the server
|
||||||
# it is ok to use a blocking sleep here
|
# it is ok to use a blocking sleep here
|
||||||
time.sleep(.5)
|
time.sleep(.5)
|
||||||
logging.info("Attempting Server Restart...")
|
logging.info("Attempting Server Restart...")
|
||||||
|
asyncio.set_event_loop(asyncio.new_event_loop())
|
||||||
|
event_loop = EventLoop()
|
||||||
event_loop.close()
|
event_loop.close()
|
||||||
logging.info("Server Shutdown")
|
logging.info("Server Shutdown")
|
||||||
ql.stop()
|
ql.stop()
|
||||||
|
|
Loading…
Reference in New Issue