api: properly close the event loop

Close the event loop when the context is exited, which will clear
the internal queues and shut down the executor of the event loop.
Not doing this will create a warning when the object is garbage
collected.
This commit is contained in:
Christian Kellner 2020-07-13 20:41:16 +02:00
parent e9c4075bb3
commit 4c6ca0b4a0

View file

@ -70,3 +70,4 @@ class API:
def __exit__(self, *args):
self.event_loop.call_soon_threadsafe(self.event_loop.stop)
self.thread.join()
self.event_loop.close()