finish processing packets upon disconnect

This commit is contained in:
əlemi 2021-11-22 15:25:41 +01:00
parent ce22e26458
commit 72b4a5a43b

View file

@ -71,7 +71,7 @@ class Dispatcher:
return self._outgoing.qsize() return self._outgoing.qsize()
async def packets(self, timeout=1) -> AsyncIterator[Packet]: 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 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) packet = await asyncio.wait_for(self._incoming.get(), timeout=timeout)
try: try: