mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-16 18:59:09 +00:00
Terminate shard processing queue when a clean close is encountered.
Fix #5180
This commit is contained in:
parent
b2065c92df
commit
50f4c31d31
@ -46,6 +46,7 @@ class EventType:
|
|||||||
resume = 2
|
resume = 2
|
||||||
identify = 3
|
identify = 3
|
||||||
terminate = 4
|
terminate = 4
|
||||||
|
clean_close = 5
|
||||||
|
|
||||||
class EventItem:
|
class EventItem:
|
||||||
__slots__ = ('type', 'shard', 'error')
|
__slots__ = ('type', 'shard', 'error')
|
||||||
@ -411,6 +412,8 @@ class AutoShardedClient(Client):
|
|||||||
elif item.type == EventType.terminate:
|
elif item.type == EventType.terminate:
|
||||||
await self.close()
|
await self.close()
|
||||||
raise item.error
|
raise item.error
|
||||||
|
elif item.type == EventType.clean_close:
|
||||||
|
return
|
||||||
|
|
||||||
async def close(self):
|
async def close(self):
|
||||||
"""|coro|
|
"""|coro|
|
||||||
@ -433,6 +436,7 @@ class AutoShardedClient(Client):
|
|||||||
await asyncio.wait(to_close)
|
await asyncio.wait(to_close)
|
||||||
|
|
||||||
await self.http.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):
|
async def change_presence(self, *, activity=None, status=None, afk=False, shard_id=None):
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user