Skip to content

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

Description

@dokson

Is your feature request related to a problem? Please describe.
RetryStrategy retries only on RequestException. A response with a retryable status (429, 5xx) completes the round-trip and is returned as-is — never retried. That's the main case people actually want retried, and urllib3/requests already cover it via Retry(status_forcelist=...).

Describe the solution you'd like
Add an opt-in field, empty by default (no behavior change):

@dataclass
class RetryStrategy:
    ...
    status_forcelist: tuple[int, ...] = ()

When resp.status_code in status_forcelist, retry under the same count/delay/backoff. Honouring Retry-After would be a natural follow-up.

Describe alternatives you've considered
Per-call retry wrappers downstream — duplicated everywhere and ignore Retry-After.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions