eventloop: add a reset method

Rather than instantiate a new version of the event loop wrapper
we can simply reset the internal event loop.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-02-04 18:14:46 -05:00
parent a5c49e8742
commit 47f0437973
2 changed files with 4 additions and 1 deletions

View File

@ -27,6 +27,9 @@ if TYPE_CHECKING:
class EventLoop:
TimeoutError = asyncio.TimeoutError
def __init__(self) -> None:
self.reset()
def reset(self) -> None:
self.aioloop = asyncio.get_event_loop()
self.add_signal_handler = self.aioloop.add_signal_handler
self.remove_signal_handler = self.aioloop.remove_signal_handler

View File

@ -952,7 +952,7 @@ def main() -> None:
else:
raise RuntimeError("Unable to create new open eventloop")
asyncio.set_event_loop(new_loop)
event_loop = EventLoop()
event_loop.reset()
event_loop.close()
logging.info("Server Shutdown")
ql.stop()