retry
azure_bootstrap.retry
¶
Tenacity-backed retry wrappers with built-in counter bumps and logging.
The conventions baked in:
- Counters bumped at function ENTRY (
{namespace}.runs) — not just on success. Apps want to know "how many times was this function called?", not "how many retry-eligible failures occurred?" - Every retry attempt logs at WARNING via
before_sleep_log— silent retry is a debugging nightmare. - Default
reraise=True— apps that want tenacity's RetryError wrapping opt in explicitly. - Two presets covering the two dominant Azure use cases:
- :func:
retry_azure_transient: short bursts, 3 attempts, 2–10 s waits. - :func:
retry_ai_transient: storm-class, 7 attempts, 2–120 s waits.
Functions:
| Name | Description |
|---|---|
build_retry |
Build a tenacity |
retry_azure_transient |
Preset for Azure-SDK transient failures: NetworkError + RateLimitError. |
retry_ai_transient |
Preset for Azure OpenAI rate-limit storms — pair with |
build_retry
¶
build_retry(*, operation: str, retry_on: type[BaseException] | tuple[type[BaseException], ...] | Callable[[BaseException], bool], max_attempts: int = 5, wait_min_seconds: float = 1.0, wait_max_seconds: float = 60.0, counter_namespace: str | None = None, reraise: bool = True, rate_limit_callback: Callable[[BaseException], None] | None = None) -> Callable[[Callable[P, T]], Callable[P, T]]
Build a tenacity @retry decorator with v2 conventions baked in.
Source code in azure_bootstrap/retry/__init__.py
retry_azure_transient
¶
retry_azure_transient(*, operation: str, counter_namespace: str | None = None, max_attempts: int = 3, wait_min_seconds: float = 2.0, wait_max_seconds: float = 10.0) -> Callable[[Callable[P, T]], Callable[P, T]]
Preset for Azure-SDK transient failures: NetworkError + RateLimitError.
Source code in azure_bootstrap/retry/__init__.py
retry_ai_transient
¶
retry_ai_transient(*, operation: str, counter_namespace: str | None = None, max_attempts: int = 7, wait_min_seconds: float = 2.0, wait_max_seconds: float = 120.0) -> Callable[[Callable[P, T]], Callable[P, T]]
Preset for Azure OpenAI rate-limit storms — pair with AiUsageTracker.acquire.