babylon.utils.retry
Retry decorator for transient failure handling.
In the material world, systems fail. Networks drop. Databases timeout. The revolutionary must persevere.
Functions
|
Decorator that retries a function on specified exceptions. |
- babylon.utils.retry.retry_on_exception(max_retries=3, delay=1.0, backoff=2.0, exceptions=Exception, logger=None)[source]
Decorator that retries a function on specified exceptions.
Uses exponential backoff to avoid hammering failing resources. This is a materialist approach: we respect the physical constraints of the systems we depend on.
- Parameters:
- Return type:
Callable[[TypeVar(F, bound=Callable[...,Any])],TypeVar(F, bound=Callable[...,Any])]- Returns:
Decorated function with retry logic
Example
@retry_on_exception(max_retries=3, delay=1.0, exceptions=(ConnectionError,)) def fetch_data():
return requests.get(”https://api.example.com”)