Pace Classic Quiz report polling instead of hammering - #407
Open
dbosk wants to merge 1 commit into
Open
Conversation
The Classic Quiz report path looped 30 times around poll_progress(report, max_attempts=1). With a single attempt the poller's sleep guard (attempt < max_attempts - 1) never fires, so all 30 API requests went out back-to-back with no backoff. Hand poll_progress the whole attempt budget in one call instead. Since QuizReport objects are static snapshots (no query() method), add an optional refresh callback so the poller can re-fetch the report between attempts, and treat a report's generated file attachment as the completion signal so the fresh snapshot is returned for URL extraction. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pb27a9hf6eNoetEWryx2fj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Classic Quiz report path looped 30 times around
poll_progress(report, max_attempts=1). With a single attempt, the sleepguard inside
poll_progress(attempt < max_attempts - 1) never fires, soall 30 API calls went out back-to-back with no backoff.
The caller now hands
poll_progressits full attempt budget in one call.That required one addition to
poll_progressitself: ClassicQuizReportobjects are static snapshots with no
query()method (the refresh previouslylived in the outer loop as
quiz.get_quiz_report), sopoll_progressgainedan optional
refreshcallback invoked before each check, and treats anon-empty
fileattachment as completion — the signal the caller's successpath actually relies on. The fresh snapshot is returned so the download-URL
extraction sees the completed report, not a stale one. New Quiz behavior is
unchanged (Progress objects self-refresh via
query).Two regression tests (refresh-per-attempt with growing backoff sleeps;
already-finished report completes without sleeping), both proven load-bearing
against the pre-fix tangled code. Full suite: 471 passed (baseline 469).
🤖 Generated with Claude Code
https://claude.ai/code/session_01Pb27a9hf6eNoetEWryx2fj