maple.utils.retry.retry_call

maple.utils.retry.retry_call(func: ~typing.Callable[[...], ~maple.utils.retry.T], args: tuple = (), kwargs: dict = None, max_attempts: int = 3, delay: float = 1.0, backoff: float = 2.0, exceptions: ~typing.Tuple[~typing.Type[Exception], ...] = (<class 'Exception'>,)) T

Functional interface for retrying a callable with arguments.

Provides a non-decorator way to add retry logic to a function call. Useful when you can’t or don’t want to use the decorator syntax, or when retry behavior needs to be determined at call time.

This function is particularly useful for: - One-off retries without modifying function definitions - Dynamic retry configuration based on runtime conditions - Retrying lambda functions or other callables - Testing retry behavior

Parameters:
  • func – The callable to execute with retry logic.

  • args – Positional arguments to pass to func. Default is empty tuple.

  • kwargs – Keyword arguments to pass to func. Default is empty dict.

  • max_attempts – Maximum number of execution attempts. Must be >= 1.

  • delay – Initial delay between retries in seconds.

  • backoff – Exponential backoff multiplier applied after each failure.

  • exceptions – Tuple of exception types to catch and retry on. Default is (Exception,) which catches all exceptions.

Returns:

The return value from successful function execution.