aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2020-08-01 19:26:49 -0400
committerRapptz <[email protected]>2020-08-01 19:26:49 -0400
commit50f4c31d31eaab00e0d872e28ee43aa43e38b192 (patch)
treebb4d0ce0e4fc486bad9a51a13f277c338e738bb3
parentFix typo when creating a guild via template (diff)
downloaddiscord.py-50f4c31d31eaab00e0d872e28ee43aa43e38b192.tar.xz
discord.py-50f4c31d31eaab00e0d872e28ee43aa43e38b192.zip
Terminate shard processing queue when a clean close is encountered.
Fix #5180
-rw-r--r--discord/shard.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/discord/shard.py b/discord/shard.py
index 97a9164c..1f0ec730 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|