prioritize interactive requests over background checks in shared Lichess-token queue
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 15s

/today, /yesterday, /week were queuing behind the entire periodic-check
backlog on the same rate-limited LICHESS_APP_TOKEN (observed ~2min wait on
prod for a single command). Add a two-tier priority queue to SharedTokenGate:
interactive on-demand requests jump ahead of background periodic checks,
which still drain normally when nothing interactive is waiting. Verified
locally end-to-end (isolated queue unit tests, live request with priority
correctly reaching Lichess, and a real successful accuracy fetch rendered
through StatsFormatter).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-07-26 10:25:34 +00:00
parent 0dbd0c400b
commit d4eb61f994
6 changed files with 76 additions and 25 deletions

View file

@ -1119,7 +1119,8 @@ class LichessBot:
int(since_dt.timestamp() * 1000),
int(until_dt.timestamp() * 1000),
rated_only=True,
include_games=want_rows
include_games=want_rows,
priority="interactive"
)
except Exception as e:
logger.warning(f"⚠️ Supplementary accuracy fetch failed for {username}/{period}: {e}")