Retry utilities reference¶
wait_for ¶
wait_for(
condition: Callable[[], Any],
*,
timeout: float = 60,
interval: float | None = None,
**kwargs: Any,
) -> Any
Wait for a condition to be met. The following exceptions influence the retry logic:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
condition | Callable[[], Any] | A callable responsible for checking the condition. A condition is considered satisfied if it does not raise an exception. | required |
timeout | float | The maximum time to wait for the condition to be met. | 60 |
interval | float | None | The interval between retries. This is equivalent to setting both | None |
Returns:
Type | Description |
---|---|
Any | The result of the condition. |
Other Parameters:
Name | Type | Description |
---|---|---|
**kwargs | Any | Additional keyword arguments to pass to |
Raises:
Type | Description |
---|---|
Exception | The final exception is re-raised if a timeout occurs or the maximum number of attempts is reached. |
FailFastError ¶
An exception indicating that the operation should not be retried.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cause | Exception | The cause of the failure. | required |
DelayedError ¶
backoff_delays ¶
backoff_delays(
*,
max_retries: int | None = None,
max_delay: float = 30,
min_delay: float = 1,
factor: float = 3,
) -> Iterator[float]
Generate a sequence of delays using truncated exponential backoff with "decorrelated jitter".
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_retries | int | None | The maximum number of retries. | None |
max_delay | float | The maximum delay. | 30 |
min_delay | float | The minimum delay. | 1 |
factor | float | The growth factor of the delay range. | 3 |