Retry Utilities¶
Retry decorators and utilities.
Quick Example¶
from mamba_agents.errors import create_retry_decorator
@create_retry_decorator(max_attempts=3, base_wait=1.0)
async def call_api():
response = await httpx.get(url)
return response.json()
Retry Levels¶
| Level | Max Retries | Base Wait | Description |
|---|---|---|---|
| 1 | 2 | 1.0s | Conservative |
| 2 | 3 | 1.0s | Balanced (default) |
| 3 | 5 | 0.5s | Aggressive |
Configuration¶
from mamba_agents.config import ErrorRecoveryConfig
config = ErrorRecoveryConfig(
retry_level=2,
max_retries=3,
base_wait=1.0,
max_wait=30.0,
exponential_base=2.0,
jitter=True,
)
API Reference¶
create_retry_decorator
¶
create_retry_decorator(
config: ErrorRecoveryConfig | None = None,
*,
max_attempts: int | None = None,
base_wait: float | None = None,
max_wait: float | None = None,
retry_exceptions: tuple[type[Exception], ...]
| None = None,
) -> Callable[[Callable[..., T]], Callable[..., T]]
Create a retry decorator with the given configuration.
| PARAMETER | DESCRIPTION |
|---|---|
config
|
Error recovery configuration.
TYPE:
|
max_attempts
|
Override max retry attempts.
TYPE:
|
base_wait
|
Override base wait time in seconds.
TYPE:
|
max_wait
|
Override max wait time in seconds.
TYPE:
|
retry_exceptions
|
Override exceptions to retry on.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Callable[[Callable[..., T]], Callable[..., T]]
|
Retry decorator. |