From 72b4a5a43b21a8c2f96947114e7ccf3626a2647c Mon Sep 17 00:00:00 2001 From: alemidev Date: Mon, 22 Nov 2021 15:25:41 +0100 Subject: [PATCH] finish processing packets upon disconnect --- aiocraft/dispatcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiocraft/dispatcher.py b/aiocraft/dispatcher.py index fd06ac7..0f79248 100644 --- a/aiocraft/dispatcher.py +++ b/aiocraft/dispatcher.py @@ -71,7 +71,7 @@ class Dispatcher: return self._outgoing.qsize() async def packets(self, timeout=1) -> AsyncIterator[Packet]: - while self.connected: + while self.connected or self._incoming.qsize(): # Finish processing packets on disconnect try: # TODO replace this timed busy-wait with an event which resolves upon disconnection, and await both packet = await asyncio.wait_for(self._incoming.get(), timeout=timeout) try: