peyk.transport.retry

Generic retry wrapper for transport operations.

Retries only the exception types explicitly listed in retryable. HTTPStatusError is never in the default set and must never be retried: a non-2xx application-level response is not a transient transport condition.

Functions

run_with_retry(operation, policy[, ...])

Performs the run with retry operation for the transport client.

Classes

RetryPolicy([max_attempts, base_backoff_seconds])

Configuration for run_with_retry.

class peyk.transport.retry.RetryPolicy(max_attempts: int = 3, base_backoff_seconds: float = 0.5)[source]

Bases: object

Configuration for run_with_retry.

Variables:
  • max_attempts (int) – Total number of attempts (including the first), not the number of retries.

  • base_backoff_seconds (float) – Base delay for exponential backoff between attempts, used when the raised error doesn’t carry its own hint (e.g. RateLimitedError.retry_after_seconds).

max_attempts: int = 3
base_backoff_seconds: float = 0.5
async peyk.transport.retry.run_with_retry(operation: Callable[[], Awaitable[T]], policy: RetryPolicy, retryable: Tuple[Type[TransportError], ...] = DEFAULT_RETRYABLE, logger: TransportLogger | None = None) T[source]

Performs the run with retry operation for the transport client.

Parameters:
  • operation – Value used by this operation.

  • policy – Value used by this operation.

  • retryable – Value used by this operation.

  • logger – Value used by this operation.

Returns:

Result produced by the transport operation.