Fixed logger to be deterministic
@@ -495,7 +495,8 @@ class GatewayConnection:
"""Run the gateway and attempt to keep it alive for as long as possible using restarts and resumes if needed."""
kwargs = {"loop": self.loop, "uri": self.uri, "compression": None}
- while not self.closed_event.is_set():
+ while not self.closed_event.is_set()
+ try:
async with websockets.connect(**kwargs) as self.ws:
try:
await self._recv_hello()
@@ -515,7 +516,7 @@ class GatewayConnection:
await asyncio.sleep(2)
# Other errors should propagate with a 1011 INTERNAL ERROR (websockets does this for us).
-
+ finally:
self._logger.info("Shard %s: gateway client shutting down", self.shard_id)
async def close(self, block=True) -> None:
