Repository navigation
fix(crawl): retry a stop on 429, 502 and 504 - #37
Closed
StefanoGuerrini wants to merge 1 commit into
Closed
StefanoGuerrini wants to merge 1 commit into
StefanoGuerrini wants to merge 1 commit into
Conversation
A stop is safe to repeat, but it is a POST without an Idempotency-Key, so the shared transport never retries it. stop() retried only a 503 crawl_busy, and a 429, 502 or 504 reached the caller at once. stop() now retries 429, 502, 503 (any code) and 504 up to `retries` times, waiting the server's Retry-After capped at 30 s, or 1 s when it is missing or unusable. The transport's rule for POST is unchanged.
Contributor
Author
|
Folded into #31, which now carries this change, so the Crawl client ships as one pull request. Generated by Claude Code |
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.
Stacked on #36. Merge that first; this PR's base is its branch.
What changed
ZenRowsCrawlClient.stop()now retries a stop answered 429, 502, 503 (any problem code,crawl_busyincluded) or 504. It uses the same retry count as before (retries) and the same wait: the server'sRetry-After, capped at 30 s, or 1 s when the header is missing or unusable. After the last retry it raises the lastCrawlAPIError.Other statuses (for example 500 or 4xx) are still raised at once. Network errors on stop are not retried, as before. The shared transport's rule for POST is unchanged; the retry stays inside
stop().The
stopand constructor docstrings now describe this.Why
Stopping a crawl is safe to repeat: stopping a crawl that already ended answers 200 with its status. But stop is a POST without an
Idempotency-Key, so the shared transport never retries it, andstop()itself retried only a 503crawl_busy. A 429, 502 or 504 went straight to the caller, who had to write their own retry loop for a call the SDK already knows is safe to repeat.Tests
crawl_busy) or 504 once, then 200, succeeds after one wait of theRetry-Aftervalue.retries=3raises the 502 after three 1 s waits.Retry-Aftercap test now covers 429 as well as 503crawl_busy: 3600 waits 30 s, -1 and nan wait 1 s, 2 waits 2 s.crawl_busyretry tests pass unchanged.Result on Python 3.12:
229 passed, 1 deselected; ty, ruff check and ruff format all pass.Generated by Claude Code