Retry & Transports Reference¶
HTTP transport middleware with automatic exponential backoff and jitter.
RetryTransport ¶
RetryTransport(transport: BaseTransport, max_retries: int = DEFAULT_MAX_RETRIES, backoff_factor: float = DEFAULT_BACKOFF_FACTOR)
Bases: BaseTransport
Synchronous HTTP transport middleware with exponential backoff and jitter.
Retries transient 5xx server errors, connection timeouts, and short-duration transient 429 rate limit responses.
Initialize the retry transport wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transport
|
BaseTransport
|
The underlying HTTP transport to delegate requests to. |
required |
max_retries
|
int
|
Maximum number of retry attempts before raising. |
DEFAULT_MAX_RETRIES
|
backoff_factor
|
float
|
Multiplier for exponential backoff calculations. |
DEFAULT_BACKOFF_FACTOR
|
Source code in src/cotbias/retry.py
handle_request ¶
Send the request through the inner transport with automatic retry on transient failure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The outgoing HTTP request. |
required |
Returns:
| Type | Description |
|---|---|
Response
|
The HTTP response received from the server. |
Source code in src/cotbias/retry.py
AsyncRetryTransport ¶
AsyncRetryTransport(transport: AsyncBaseTransport, max_retries: int = DEFAULT_MAX_RETRIES, backoff_factor: float = DEFAULT_BACKOFF_FACTOR)
Bases: AsyncBaseTransport
Asynchronous HTTP transport middleware with exponential backoff and jitter.
Retries transient 5xx server errors, connection timeouts, and short-duration transient 429 rate limit responses asynchronously.
Initialize the async retry transport wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transport
|
AsyncBaseTransport
|
The underlying async HTTP transport to delegate requests to. |
required |
max_retries
|
int
|
Maximum number of retry attempts before raising. |
DEFAULT_MAX_RETRIES
|
backoff_factor
|
float
|
Multiplier for exponential backoff calculations. |
DEFAULT_BACKOFF_FACTOR
|
Source code in src/cotbias/retry.py
handle_async_request
async
¶
Send the async request through the inner transport with automatic retry on transient failure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The outgoing HTTP request. |
required |
Returns:
| Type | Description |
|---|---|
Response
|
The HTTP response received from the server. |