ovok_sdk.http.retry

When and how long to wait before retrying a request.

  • Stable unknown
  • Release candidate since 0.1.0-rc.4
  • Development since 0.1.0-dev.25+2ba84b0

When and how long to wait before retrying a request.

RetryPolicy

RetryPolicy(max_retries: int, sleep: Sleep = time.sleep)

Retries safe requests on network failures and 429, 502, 503 and 504, with backoff.

Parameters

NameTypeDefaultDescription
max_retriesintRetries allowed after the first attempt.
sleepSleeptime.sleepWaits the given number of seconds.

allows()

allows(request: HttpRequest, attempt: int) -> bool

Whether request may be retried after failed attempt number attempt (0-based).

is_retryable_status()

is_retryable_status(status: int) -> bool

Whether a response with status is worth retrying.

pause()

pause(attempt: int, retry_after_ms: int | None) -> None

Wait before the next attempt: retry_after_ms if given, else exponential backoff, at most 5 s.

retry_after_ms()

retry_after_ms(header: str | None) -> int | None

Reads Retry-After as seconds or an HTTP date; a past moment means now.

Returns

  • int | None: The delay in milliseconds, or None when the header is absent or unreadable.

Last updated on

On this page