diff options
| author | Rapptz <[email protected]> | 2016-04-15 23:26:33 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2016-04-15 23:27:23 -0400 |
| commit | 8d7dd79673a35c4977c285324b36738e1e6c82f7 (patch) | |
| tree | 429d946d87b92e4ee979e6f3620b4facb3c30473 | |
| parent | Typo fix (diff) | |
| download | discord.py-8d7dd79673a35c4977c285324b36738e1e6c82f7.tar.xz discord.py-8d7dd79673a35c4977c285324b36738e1e6c82f7.zip | |
Fix deadlock issue when joining large guilds.
| -rw-r--r-- | discord/client.py | 2 | ||||
| -rw-r--r-- | discord/state.py | 18 |
2 files changed, 13 insertions, 7 deletions
diff --git a/discord/client.py b/discord/client.py index c359509a..2d17c62b 100644 --- a/discord/client.py +++ b/discord/client.py @@ -378,8 +378,6 @@ class Client: log.info('Unhandled event {}'.format(event)) else: result = func(data) - if asyncio.iscoroutine(result): - yield from result @asyncio.coroutine def _make_websocket(self, initial=True): diff --git a/discord/state.py b/discord/state.py index ac6ea064..fc62927c 100644 --- a/discord/state.py +++ b/discord/state.py @@ -338,6 +338,17 @@ class ConnectionState: return self._add_server_from_data(data) @asyncio.coroutine + def _chunk_and_dispatch(self, server, unavailable): + yield from self.chunker(server) + chunks = list(self.chunks_needed(server)) + if chunks: + yield from asyncio.wait(chunks) + + if unavailable == False: + self.dispatch('server_available', server) + else: + self.dispatch('server_join', server) + def parse_guild_create(self, data): unavailable = data.get('unavailable') if unavailable == True: @@ -367,11 +378,8 @@ class ConnectionState: # since we're not waiting for 'useful' READY we'll just # do the chunk request here - yield from self.chunker(server) - chunks = list(self.chunks_needed(server)) - if chunks: - yield from asyncio.wait(chunks) - + utils.create_task(self._chunk_and_dispatch(server, unavailable), loop=self.loop) + return # Dispatch available if newly available if unavailable == False: |