Skip to content

feat: add status_forcelist to RetryStrategy - #782

Open
dokson wants to merge 2 commits into
lexiforest:mainfrom
dokson:feat/retry-status-forcelist
Open

feat: add status_forcelist to RetryStrategy#782
dokson wants to merge 2 commits into
lexiforest:mainfrom
dokson:feat/retry-status-forcelist

Conversation

@dokson

@dokson dokson commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Retry on retryable HTTP status codes (429, 5xx) in addition to transport errors. Opt-in via RetryStrategy(status_forcelist=...), empty by default so existing behavior is unchanged. Honours Retry-After (seconds form) when present, otherwise the configured backoff. Works for both Session and AsyncSession; the response is released before each retry so no handle/stream leaks.

Closes #781

  • I have manually reviewed the changes and fully understand the code.

Retry on retryable HTTP status codes (e.g. 429, 5xx) in addition to
transport errors. Opt-in via RetryStrategy(status_forcelist=...), empty
by default so behavior is unchanged. Honours the Retry-After header
(seconds form) when present, otherwise uses the configured backoff.
Applies to both Session and AsyncSession; the response is released
before each retry to avoid leaking a handle/stream.

Closes lexiforest#781
@dokson
dokson force-pushed the feat/retry-status-forcelist branch from 267da2c to feb07c4 Compare July 20, 2026 15:02
float() happily parses "inf", which would make the retry sleep forever.
Only honour finite delta-seconds, anything else falls back to backoff.

Also cover the stream=True + status_forcelist path in tests, sync and
async (async on max_clients=1 so a leaked handle would hang).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RetryStrategy: support retrying on HTTP status codes (429, 5xx)

1 participant