fix: wait on token refresh cooldown instead of failing fast
Some checks failed
CI / test (pull_request) Has been cancelled

This commit is contained in:
agentson
2026-02-18 00:03:42 +09:00
parent d0bbdb5dc1
commit aeed881d85

View File

@@ -104,12 +104,14 @@ class KISBroker:
time_since_last_attempt = now - self._last_refresh_attempt time_since_last_attempt = now - self._last_refresh_attempt
if time_since_last_attempt < self._refresh_cooldown: if time_since_last_attempt < self._refresh_cooldown:
remaining = self._refresh_cooldown - time_since_last_attempt remaining = self._refresh_cooldown - time_since_last_attempt
error_msg = ( # Do not fail fast here. If token is unavailable, upstream calls
f"Token refresh on cooldown. " # will all fail for up to a minute and scanning returns no trades.
f"Retry in {remaining:.1f}s (KIS allows 1/minute)" logger.warning(
"Token refresh on cooldown. Waiting %.1fs before retry (KIS allows 1/minute)",
remaining,
) )
logger.warning(error_msg) await asyncio.sleep(remaining)
raise ConnectionError(error_msg) now = asyncio.get_event_loop().time()
logger.info("Refreshing KIS access token") logger.info("Refreshing KIS access token")
self._last_refresh_attempt = now self._last_refresh_attempt = now