Repository navigation
feat: retry unprocessed requests in batch_add_requests - #1244
cobanfurkanx wants to merge 6 commits into
Conversation
RequestQueueClient.batch_add_requests
apify-factory
left a comment
There was a problem hiding this comment.
Looks good, nothing blocking.
🏭 Factory review — ℹ️ not auto-approved
This change was reviewed but cannot be auto-approved: a gate failed, so the review cannot end in an approval.
| check | result |
|---|---|
| Static gates | ❌ 12/16 — author-allowed, same-repo, max-lines, no-risky-content |
| Review findings | ✅ none |
| Reviewer escalation | ❌ Adds new parameters to the public batch_add_requests signature and changes default runtime behavior (3 retries with sleeps of several seconds by default), which a maintainer should sign off on. |
Juror 1 — claude-sonnet-5-5, adversarial |
⏭️ skipped — a gate failed |
Why it was not auto-approved
Failed gates:
author-allowed: cobanfurkanx: not a member of apify/product-engineeringsame-repo: head repo is cobanfurkanx/apify-client-pythonmax-lines: 363 changed lines: over the limit 200 (+304/-59)no-risky-content: src/apify_client/_resource_clients/request_queue.py: network call (network-call)
The comments above are the review itself; this section only explains the approval decision. Push a change and request @apify-factory again to re-run it, or ask a human to review.
Reviewed 867e5e0bd · Review details on the dashboard · workflow run
|
Thanks for the detailed review @vdusek! Addressed all feedback in
|
RequestQueueClient.batch_add_requestsbatch_add_requests
vdusek
left a comment
There was a problem hiding this comment.
LGTM, could you @Pijukatel check it as well?
Pijukatel
left a comment
There was a problem hiding this comment.
Thanks for PR, change makes sense on its own. But we have to discuss where to place these retries in the context of Crawlee, SDK and client.
Currently:
Both versions of Python Crawlee are doing the retries in RQ:
JS since v4.x is doing it only in client.
So we could merge this PR and remove the retries from Crawlee Python to align with JS.
But!!! JS tooling does not have any other storage back-ends where this makes sense. In Python the SQL storage client does not have own retries here, so it could theoretically also benefit from the Crawlee based retires if some transaction fails. Not sure how real scenario is that.
Let me block the change until we internally discuss where it belongs.
|
Sounds good @Pijukatel — makes complete sense to align on whether retries should live in the client or Crawlee Python first. Happy to adjust or rebase once you decide internally! |
Summary
DEFAULT_UNPROCESSED_RETRIES_BATCH_ADD_REQUESTS = 3andDEFAULT_MIN_DELAY_BETWEEN_UNPROCESSED_REQUESTS_RETRIES = timedelta(milliseconds=500)insrc/apify_client/_consts.py.RequestQueueClient.batch_add_requests()and asyncRequestQueueClientAsync.batch_add_requests()(along with_batch_add_requests_worker,_serialize_requests,_compute_retry_delay_seconds, and_remaining_batch_items) insrc/apify_client/_resource_clients/request_queue.pyto retryunprocessed_requestswith exponential backoff (3 retries by default, setmax_unprocessed_requests_retries=0to disable them) and record rate-limit rounds viaself._http_client.stats.add_rate_limit_error(attempt + 1).test_batch_processed_partially_{async,sync}and addtest_batch_add_requests_retries_unprocessed_requests_{async,sync}intests/unit/test_client_request_queue.py.docs/02_concepts/05_retries.mdx.Closes: #1134
Verification
pytest tests/unit/test_client_request_queue.py tests/unit/test_statistics.py: 63 passed ([impit]and[httpx2])poe lint(ruff format --check && ruff check): 249 files formatted, all checks passedty check src tests/unit/test_client_request_queue.py&ty check --python-platform linux: all checks passedpoe check-docstrings: async and sync method docstrings are in sync