Skip to content

Implement rate-limit handling #11

@codebestia

Description

@codebestia

Description

When the API returns HTTP 429, the SDK should parse the Retry-After header (seconds) and either automatically wait and retry (if within max_retries) or raise RateLimitError with the wait time attached. The caller should never need to implement their own 429 backoff.

Proposed Steps

  • In the response parser, detect HTTP 429 before raising a generic error.
  • Parse Retry-After header (integer seconds) and attach it to the RateLimitError.
  • If auto-retry is enabled and max_retries is not exhausted, sleep for retry_after seconds then retry.
  • In the async client, use asyncio.sleep instead of time.sleep.

Acceptance Criteria

  • A 429 response raises RateLimitError with a retry_after attribute.
  • When retrying, the client waits at least Retry-After seconds before the next attempt.
  • If Retry-After is absent, the client falls back to exponential backoff.
  • Async client uses non-blocking sleep.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions