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:
parent
a5c49e8742
commit
47f0437973
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue