aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2020-04-11 19:06:22 -0400
committerRapptz <[email protected]>2020-07-25 09:59:39 -0400
commit80cc5b5edbda6fe925d4bf63f51b276a3fd5c27e (patch)
tree14f22deb0267f5e4a9b632425024d4c51859e32d
parentMake every shard maintain its own reconnect loop (diff)
downloaddiscord.py-80cc5b5edbda6fe925d4bf63f51b276a3fd5c27e.tar.xz
discord.py-80cc5b5edbda6fe925d4bf63f51b276a3fd5c27e.zip
Handle connection errors during reidentify flow.
-rw-r--r--discord/shard.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/discord/shard.py b/discord/shard.py
index 31777816..0b037398 100644
--- a/discord/shard.py
+++ b/discord/shard.py
@@ -135,12 +135,16 @@ class Shard:
async def reidentify(self, exc):
self._cancel_task()
- log.info('Got a request to %s the websocket at Shard ID %s.', exc.op, self.id)
- coro = DiscordWebSocket.from_client(self._client, resume=exc.resume, shard_id=self.id,
- session=self.ws.session_id, sequence=self.ws.sequence)
self._dispatch('disconnect')
- self.ws = await asyncio.wait_for(coro, timeout=180.0)
- self.launch()
+ log.info('Got a request to %s the websocket at Shard ID %s.', exc.op, self.id)
+ try:
+ coro = DiscordWebSocket.from_client(self._client, resume=exc.resume, shard_id=self.id,
+ session=self.ws.session_id, sequence=self.ws.sequence)
+ self.ws = await asyncio.wait_for(coro, timeout=180.0)
+ except self._handled_exceptions as e:
+ await self._handle_disconnect(e)
+ else:
+ self.launch()
async def reconnect(self):
self._cancel_task()