Skip to content

wikidata_stats: wait up to 10 minutes for Wikidata's lag, not 5 tries - #115

Merged
forzagreen merged 1 commit into
mainfrom
fix/wikidata-stats-maxlag-wait
Oct 7, 2026
Merged

forzagreen merged 1 commit into
mainfrom
fix/wikidata-stats-maxlag-wait

Conversation

@forzagreen

Copy link
Copy Markdown
Owner

After the import of #114, wikidata-stats failed twice (run 37618698260, attempts 1 and 2) with RuntimeError: Wikidata is lagging, giving up. The second attempt waited until the lag had dropped below 4 s, then still failed on its first read. The query service's lag hovers around the maxlag of 5 s (Waiting for wdqs1014: 6.75 seconds lagged.), and 5 attempts × Retry-After: 5 gave up within half a minute.

Change

  • wikidata() waits out maxlag for up to MAXLAG_WAIT (600 s) per call instead of 5 attempts, as Wikimedia asks of bots. When it does give up, the error says how long it waited and what lagged.
  • Two tests: one where the first 20 requests answer maxlag, which the sync waits out, and one where Wikidata never stops lagging, where it gives up after exactly MAXLAG_WAIT. time.sleep is monkeypatched, so the tests take no time.

make check passes and make test gives 162 passed.

After merging

The push runs deploy-code but not wikidata-stats, since the dump is unchanged. Use "Run workflow" on CI to copy the new counts (604,417 terms, 88 dictionaries) to Q133800945.

🤖 Generated with Claude Code

https://claude.ai/code/session_01P46G3NWFFqPMVwDmVo4vLJ


Generated by Claude Code

After the import of #114, wikidata-stats failed twice with "Wikidata is
lagging, giving up": the query service's lag hovered around the maxlag of
5 s, and 5 attempts of Retry-After (5 s) gave up within half a minute.

Wait out maxlag for up to MAXLAG_WAIT (600 s) per call instead, and say
how long it waited and what lagged when it does give up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P46G3NWFFqPMVwDmVo4vLJ
@forzagreen
forzagreen merged commit ce14181 into main Oct 7, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants