aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2016-12-16 21:27:47 -0500
committerRapptz <[email protected]>2016-12-16 21:28:12 -0500
commita0f4ad36eb0e4c82162c1ee571543c13b9a74bfd (patch)
tree88e6c785f0fa156ed2568b845f2d16ad8044bac5
parentDiscard null sequences in the gateway. (diff)
downloaddiscord.py-a0f4ad36eb0e4c82162c1ee571543c13b9a74bfd.tar.xz
discord.py-a0f4ad36eb0e4c82162c1ee571543c13b9a74bfd.zip
Timeout waiting for chunking.
Sometimes the bot would keep waiting for chunks that somehow finished before getting to the `wait` call. This is more so a temporary fix rather than a fully correct one.
-rw-r--r--discord/state.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/discord/state.py b/discord/state.py
index d089a5ed..aed5a746 100644
--- a/discord/state.py
+++ b/discord/state.py
@@ -186,10 +186,16 @@ class ConnectionState:
# wait for the chunks
if chunks:
- yield from asyncio.wait(chunks)
+ try:
+ yield from asyncio.wait(chunks, timeout=len(chunks))
+ except asyncio.TimeoutError:
+ log.info('Somehow timed out waiting for chunks.')
# remove the state
- del self._ready_state
+ try:
+ del self._ready_state
+ except AttributeError:
+ pass # already been deleted somehow
# call GUILD_SYNC after we're done chunking
if not self.is_bot:
@@ -206,7 +212,7 @@ class ConnectionState:
servers = self._ready_state.servers
for guild in guilds:
server = self._add_server_from_data(guild)
- if server.large or not self.is_bot:
+ if not self.is_bot and server.large:
servers.append(server)
for pm in data.get('private_channels'):
@@ -291,7 +297,7 @@ class ConnectionState:
if not reaction:
log.warning("Unexpected reaction remove {}".format(data))
return
-
+
reaction.count -= 1
if data['user_id'] == self.user.id:
reaction.me = False