fastcfg.backoff package

Submodules

fastcfg.backoff.policies module

This module defines pre-configured backoff policies for use with the exponential backoff mechanism.

fastcfg.backoff.policies.BASIC_BACKOFF_POLICY

A basic backoff policy configuration

Type:

BackoffPolicy

with the following settings
  • max_retries: 6 (Maximum number of retry attempts)

  • base_delay: 0.5 seconds (Initial delay between retries)

  • max_delay: 32 seconds (Maximum delay between retries)

  • factor: 2 (Delay is doubled each time)

  • jitter: True (Random jitter is added to the delay to reduce collision)

Module contents

This module provides an implementation of an exponential backoff mechanism.

Classes:

BackoffPolicy: Configuration class for the exponential backoff mechanism.

Functions:

exponential_backoff: Decorator function to apply exponential backoff retries to a function.

Exceptions:

MaxRetriesExceededError: Raised when the maximum number of retries is exceeded.

class fastcfg.backoff.BackoffPolicy(max_retries: int, base_delay: float, max_delay: float, factor: float, jitter: bool)[source]

Bases: object

Configuration for the exponential backoff mechanism.

max_retries

Maximum number of retry attempts.

Type:

int

base_delay

Initial delay between retries in seconds.

Type:

float

max_delay

Maximum delay between retries in seconds.

Type:

float

factor

Multiplicative factor for delay growth.

Type:

float

jitter

If True, adds a random jitter to the delay.

Type:

bool

base_delay: float
factor: float
jitter: bool
max_delay: float
max_retries: int
fastcfg.backoff.exponential_backoff(backoff_policy: BackoffPolicy)[source]

Decorator for exponential backoff retries.

Parameters:

backoff_policy (BackoffPolicy) – Configuration object containing: - max_retries (int): Maximum number of retry attempts. - base_delay (float): Initial delay between retries in seconds. - max_delay (float): Maximum delay between retries in seconds. - factor (float): Multiplicative factor for delay growth. - jitter (bool): If True, adds a random jitter to the delay.

Returns:

Wrapped function with retry mechanism.

Return type:

function