askui.retry.Retry

class Retry(ABC)

Abstract base class for implementing retry mechanisms.

This abstract class defines the interface for retry mechanisms. Concrete implementations should define how the retry logic works by implementing the abstract attempt method.

Example:

class MyRetry(Retry):
    def attempt(self, func: Callable[..., R]) -> R:
        # Custom retry implementation
        return func()

retry = MyRetry()
result = retry.attempt(some_function)

attempt

def attempt(func: Callable[..., R]) -> R

Attempt to execute a function with retry logic.

Arguments:

  • func - The function to execute with retry logic

Returns:

The result of the function execution

Raises:

  • Exception - Any exception that occurs during execution after all retry attempts are exhausted

askui.retry.ConfigurableRetry

class ConfigurableRetry(Retry)

A configurable retry implementation with different strategies.

This class provides a flexible way to retry operations that may fail temporarily, supporting different retry strategies (Exponential, Fixed, Linear) and configurable parameters for delay and retry count.

Arguments:

  • on_exception_types Tuple[Type[Exception]] - Tuple of exception types that should trigger a retry
  • strategy Literal[“Exponential”, “Fixed”, “Linear”] - The retry strategy to use:
    • "Exponential": Delay increases exponentially between retries
    • "Fixed": Constant delay between retries
    • "Linear": Delay increases linearly between retries
  • base_delay int, optional - Base delay in milliseconds between retries.
  • retry_count int, optional - Maximum number of retry attempts.

Example:

retry = ConfigurableRetry(
    on_exception_types=(ConnectionError, TimeoutError),
    strategy="Exponential",
    base_delay=1000,
    retry_count=3
)
result = retry.attempt(some_function)