Fixed regression where zombie caused stuff to die permanently.
@@ -746,6 +746,7 @@ class GatewayShardImpl(shard.GatewayShard):
initial_increment=_BACKOFF_INCREMENT_START,
)
+ try:
while True:
if date.monotonic() - last_started_at < _BACKOFF_WINDOW:
time = next(backoff)
@@ -761,9 +762,13 @@ class GatewayShardImpl(shard.GatewayShard):
try:
last_started_at = date.monotonic()
- # TODO: should I be using the result of this still, or is it dead code? Is it a bug I created?
- await self._run_once()
+ should_die = await self._run_once()
+
+ if not should_die:
+ continue
+
self._logger.info("shard has disconnected and shut down normally")
+ return
except errors.GatewayConnectionError as ex:
self._logger.error(
@@ -793,7 +798,6 @@ class GatewayShardImpl(shard.GatewayShard):
except Exception as ex:
self._logger.error("encountered some unhandled error", exc_info=ex)
raise
-
finally:
self._closed.set()
