Repository navigation
Conversation
wait_for_review slept min(interval, remaining) between reads, so once the backed-off interval outgrew the time left, the last sleep ended at the deadline and the wait returned TIMED_OUT without reading again. With the default 300 s timeout the last read was at 255 s, so a review completing at 260 s was reported as timed out. Move a read the deadline would skip to 5 s before the deadline, unless that is under 5 s after the previous read. A wait that does not settle still ends at its deadline.
…stays The wait_for_review docstring said only reads the deadline would skip move to five seconds before it. _poll_delay also moves a read that would land in the last five seconds, and leaves a read in place when moving it would come under five seconds after the previous one. Match the README wording.
This branch has not been deployed
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.
Problem
wait_for_reviewsleepsmin(interval, remaining)between reads, with the interval doubling from 5 s up to 60 s. Once the next interval is longer than the time left, that sleep ends exactly at the deadline. The loop then exits, becauseremaining() > 0is false, and returnsTIMED_OUTwithout another read. The last interval of every wait that doesn't settle earlier is slept out unobserved.With the default
timeout=300, the reads are at 0, 5, 15, 35, 75, 135, 195 and 255 s, followed by 45 s of sleep. A review that completes at 260 s is reported asTIMED_OUT, although it finished inside the window the caller asked for. Withtimeout=30, the blind tail is 15 of the 30 s.TIMED_OUTis what CI jobs branch on, so this turns a finished review into a failed or retried job.AsyncProoflineClient.wait_for_reviewhas the same loop.Fix
One helper,
_poll_delay(interval, budget), now picks each sleep for both clients:min(interval, budget)unchanged.Notes on the choices:
limit_timeoutcaps it at the remaining budget and it usually reconnects after a sleep longer than the 5 s keep-alive. A read at the deadline itself can't start. A moved read that doesn't finish ends exactly as before.min(interval, budget). Short waits,timeout=0, and the Retry-After-at-deadline paths are unchanged.timeout=260back-off test passes unmodified: its final gap is 5 s, so the read stays where it was.The README's waiting section and the
wait_for_reviewdocstring describe the new last read.Verification
Tests
test_wait_reads_again_before_the_deadline_instead_of_sleeping_it_out(sync and async): the review completes at 260 s into the default 300 s wait. Before:TIMED_OUT. After:COMPLETEDat 295 s, with sleeps[5, 10, 20, 40, 60, 60, 60, 40]and 9 requests.test_wait_still_lasts_its_timeout_after_the_last_read(sync and async): an unfinished review withtimeout=120is read at 0, 5, 15, 35, 75 and 115 s and returnsTIMED_OUTat exactly 120 s with the latest record.test_poll_delay_moves_only_a_read_the_deadline_would_skip: six interval/budget cases covering each branch and its boundaries.The two wait tests fail on
mainand pass on this branch.End to end, real time
A loopback HTTP server answers
RUNNINGuntil 20 s, thenCOMPLETED.ProoflineClient.wait_for_review(..., timeout=30)runs against it with real time and the real transport:Script to reproduce
Run from the repository root with the dev dependencies installed (
python demo_wait.py):Checks
python scripts/check.pyruns in this PR's CI on Linux.Locally on Windows 11 (Python 3.13.12, pinned dev dependencies):
ruff check,ruff format --check,mypy proofline scripts,scripts/contracts.pyandpytest(244 passed) all pass.scripts/generate.py --checkfails on Windows onmainas well (#87); CI runs it on Linux.Follow-up
The TypeScript SDK's
waitForReviewuses the samesleep(min(interval, deadline - now))pattern and has the same blind tail.