aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--discord/client.py3
-rw-r--r--discord/shard.py3
2 files changed, 5 insertions, 1 deletions
diff --git a/discord/client.py b/discord/client.py
index 8ba5b7b3..e9f5a8ff 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -399,6 +399,9 @@ class Client:
yield from self.close()
raise
+ if self.is_closed():
+ return
+
# We should only get this when an unhandled close code happens,
# such as a clean disconnect (1000) or a bad state (bad token, no sharding, etc)
# sometimes, discord sends us 1000 for unknown reasons so we should reconnect
diff --git a/discord/shard.py b/discord/shard.py
index ab0ca31f..8fad51e9 100644
--- a/discord/shard.py
+++ b/discord/shard.py
@@ -234,11 +234,12 @@ class AutoShardedClient(Client):
if self.is_closed():
return
+ self._closed.set()
+
for shard in self.shards.values():
yield from shard.ws.close()
yield from self.http.close()
- self._closed.set()
@asyncio.coroutine
def change_presence(self, *, game=None, status=None, afk=False, shard_id=None):