Fix deadlock issue when joining large guilds.
This commit is contained in:
		| @@ -378,8 +378,6 @@ class Client: | |||||||
|             log.info('Unhandled event {}'.format(event)) |             log.info('Unhandled event {}'.format(event)) | ||||||
|         else: |         else: | ||||||
|             result = func(data) |             result = func(data) | ||||||
|             if asyncio.iscoroutine(result): |  | ||||||
|                yield from result |  | ||||||
|  |  | ||||||
|     @asyncio.coroutine |     @asyncio.coroutine | ||||||
|     def _make_websocket(self, initial=True): |     def _make_websocket(self, initial=True): | ||||||
|   | |||||||
| @@ -338,6 +338,17 @@ class ConnectionState: | |||||||
|         return self._add_server_from_data(data) |         return self._add_server_from_data(data) | ||||||
|  |  | ||||||
|     @asyncio.coroutine |     @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): |     def parse_guild_create(self, data): | ||||||
|         unavailable = data.get('unavailable') |         unavailable = data.get('unavailable') | ||||||
|         if unavailable == True: |         if unavailable == True: | ||||||
| @@ -367,11 +378,8 @@ class ConnectionState: | |||||||
|  |  | ||||||
|             # since we're not waiting for 'useful' READY we'll just |             # since we're not waiting for 'useful' READY we'll just | ||||||
|             # do the chunk request here |             # do the chunk request here | ||||||
|             yield from self.chunker(server) |             utils.create_task(self._chunk_and_dispatch(server, unavailable), loop=self.loop) | ||||||
|             chunks = list(self.chunks_needed(server)) |             return | ||||||
|             if chunks: |  | ||||||
|                 yield from asyncio.wait(chunks) |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         # Dispatch available if newly available |         # Dispatch available if newly available | ||||||
|         if unavailable == False: |         if unavailable == False: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user