feat(http): add jitter to retry backoff - #165
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review comments were supplied.
Pull request overview
Adds configurable full jitter to capped exponential HTTP retry backoff, with deterministic opt-out behavior.
Changes:
- Adds
retry_jitter, enabled by default. - Applies jitter across sync and async retry paths.
- Adds tests and documentation.
File summaries
| File | Summary |
|---|---|
tests/test_core/test_http.py |
Tests jitter bounds and sync retries. |
tests/test_core/test_config.py |
Tests jitter configuration. |
tests/test_core/test_async_http.py |
Tests async jittered retries. |
src/pyscrappy/core/http.py |
Implements capped full-jitter delays. |
src/pyscrappy/core/config.py |
Adds the retry jitter setting. |
README.md |
Documents the configuration option. |
CHANGELOG.md |
Records the retry behavior change. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Nice work, and welcome @k4its1t. I checked this out and it's exactly right: full jitter applied after the cap (correct order), in the shared backoff_delay so sync and async both get it, with a clean deterministic opt-out. Verified the spread (0..capped-delay over 1000 samples) and that retry_jitter=False keeps the old exact schedule. Full suite green (540 passed), lint clean, and it sits cleanly on top of 1.5.7. Server-set Retry-After values are correctly left untouched. Merging. Thanks for the thorough PR and validation notes. |
Summary
0..delayScraperConfig.retry_jitter=Truewith an opt-out that preserves the previous deterministic schedule and positional config compatibilityRetry-Aftervalues unchangedCloses #163
Validation
pytest tests/ -qon Python 3.9: 514 passed, 6 skipped, 19 deselectedruff check src/ tests/ruff format --check src/ tests/compileallforsrcandtestspython -m build(sdist and wheel)mypy src/pyscrappy/is not currently green on the unchanged project baseline: current mypy no longer accepts the repository's Python 3.9 target, and the suite also reports existing errors in unrelated code. The changed config file introduces no reported error; the reports inhttp.pyare on pre-existing stealth-response branches.AI assistance
OpenAI Codex assisted with issue screening, implementation, tests, and PR preparation. I reviewed the final diff and validation results.