A dependency-free Python sample demonstrating bounded retries, Retry-After handling, deterministic tests, and atomic output replacement for scheduled API collectors.
- HTTP
429, selected5xx, timeouts, transport failures, and malformed JSON can be retried. - Non-transient
4xxfailures are raised immediately. - Exponential backoff is capped and supports bounded jitter.
- Numeric
Retry-Aftertakes precedence over calculated backoff. - The previous output file survives an interrupted replacement.
- Tests never call the network or actually sleep.
python3 -m unittest discover -vExpected result: eight tests pass.
import json
from src import JsonHttpClient, atomic_write_text
client = JsonHttpClient()
data = client.get_json("https://api.example.test/data")
atomic_write_text("daily.txt", json.dumps(data, indent=2))See DELIVERY_REPORT.md for the verification and handoff format. A ready-to-copy GitHub Actions workflow is included at ci/python-tests.yml.example.
This repository is a public capability sample, not customer code. Fixed-scope API reliability, CI, and QA engagements are available through LaborX escrow.