From 50f4c31d31eaab00e0d872e28ee43aa43e38b192 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 1 Aug 2020 19:26:49 -0400 Subject: [PATCH] Terminate shard processing queue when a clean close is encountered. Fix #5180 --- discord/shard.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/discord/shard.py b/discord/shard.py index 97a9164ca..1f0ec730e 100644 --- a/discord/shard.py +++ b/discord/shard.py @@ -46,6 +46,7 @@ class EventType: resume = 2 identify = 3 terminate = 4 + clean_close = 5 class EventItem: __slots__ = ('type', 'shard', 'error') @@ -411,6 +412,8 @@ class AutoShardedClient(Client): elif item.type == EventType.terminate: await self.close() raise item.error + elif item.type == EventType.clean_close: + return async def close(self): """|coro| @@ -433,6 +436,7 @@ class AutoShardedClient(Client): await asyncio.wait(to_close) await self.http.close() + self.__queue.put_nowait(EventItem(EventType.clean_close, None, None)) async def change_presence(self, *, activity=None, status=None, afk=False, shard_id=None): """|coro|