diff options
| author | Khazhismel <[email protected]> | 2016-04-11 11:53:54 -0400 |
|---|---|---|
| committer | Khazhismel <[email protected]> | 2016-04-11 11:53:54 -0400 |
| commit | 84f1342b858366f9f65d528756125a0407c2beda (patch) | |
| tree | 97e5a24ddc7f0f815b691750cdb567dd9c810553 | |
| parent | Proper chunking for unavailable guilds. (diff) | |
| download | discord.py-84f1342b858366f9f65d528756125a0407c2beda.tar.xz discord.py-84f1342b858366f9f65d528756125a0407c2beda.zip | |
Fix chunk requests not actually being batched.
| -rw-r--r-- | discord/state.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/discord/state.py b/discord/state.py index 4baab8b6..3b36225b 100644 --- a/discord/state.py +++ b/discord/state.py @@ -46,7 +46,7 @@ class ListenerType(enum.Enum): Listener = namedtuple('Listener', ('type', 'future', 'predicate')) log = logging.getLogger(__name__) -ReadyState = namedtuple('ReadyState', ('launch', 'chunks')) +ReadyState = namedtuple('ReadyState', ('launch', 'chunks', 'servers')) class ConnectionState: def __init__(self, dispatch, chunker, max_messages, *, loop): @@ -154,6 +154,7 @@ class ConnectionState: # get all the chunks chunks = [f for f in self._ready_state.chunks if not f.done()] if chunks: + yield from self.chunker(self._ready_state.servers) yield from asyncio.wait(chunks) # remove the state @@ -163,7 +164,7 @@ class ConnectionState: self.dispatch('ready') def parse_ready(self, data): - self._ready_state = ReadyState(launch=asyncio.Event(), chunks=[]) + self._ready_state = ReadyState(launch=asyncio.Event(), chunks=[], servers=[]) self.user = User(**data['user']) guilds = data.get('guilds') @@ -337,7 +338,6 @@ class ConnectionState: # check if it requires chunking if server.large: - yield from self.chunker(server) chunks = list(self.chunks_needed(server)) if unavailable == False: @@ -350,6 +350,7 @@ class ConnectionState: state = self._ready_state state.launch.clear() if chunks: + state.servers.append(server) state.chunks.extend(chunks) except AttributeError: # the _ready_state attribute is only there during @@ -360,6 +361,7 @@ class ConnectionState: # since we're not waiting for 'useful' READY we'll just # do the chunk request here + yield from self.chunker(server) if chunks: yield from asyncio.wait(chunks) |