From 20041ea756305f20c86a621232639932c50f107c Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 7 Jan 2017 21:55:47 -0500 Subject: Implement AutoShardedClient for transparent sharding. This allows people to run their >2,500 guild bot in a single process without the headaches of IPC/RPC or much difficulty. --- discord/client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'discord/client.py') diff --git a/discord/client.py b/discord/client.py index 2e0696c9..f8f45870 100644 --- a/discord/client.py +++ b/discord/client.py @@ -142,6 +142,7 @@ class Client: self.connection = ConnectionState(dispatch=self.dispatch, chunker=self.request_offline_members, syncer=self._syncer, http=self.http, loop=self.loop, **options) + self.connection.shard_count = self.shard_count self._closed = asyncio.Event(loop=self.loop) self._is_logged_in = asyncio.Event(loop=self.loop) self._is_ready = asyncio.Event(loop=self.loop) @@ -405,11 +406,14 @@ class Client: while not self.is_closed: try: - yield from self.ws.poll_event() + yield from ws.poll_event() except (ReconnectWebSocket, ResumeWebSocket) as e: resume = type(e) is ResumeWebSocket log.info('Got ' + type(e).__name__) - self.ws = yield from DiscordWebSocket.from_client(self, resume=resume) + self.ws = yield from DiscordWebSocket.from_client(self, shard_id=self.shard_id, + session=self.ws.session_id, + sequence=self.ws.sequence, + resume=resume) except ConnectionClosed as e: yield from self.close() if e.code != 1000: -- cgit v1.2.3