Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add drenv.retry module #1547

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Add drenv.retry module #1547

wants to merge 1 commit into from

Conversation

nirs
Copy link
Member

@nirs nirs commented Sep 9, 2024

The module provides the on_error() utility, for retrying function calls up to number of retries with exponential backoff.

Example usage:

# Retry 5 times. The wait between the retries is doubled on every
# retry (1, 2, 4, 8, 16).
retry.on_error(func)

# Retry 10 times with up to 30 seconds between retries
# (1, 2, 4, 8, 16, 30, 30, 30, 30, 30).
retry.on_error(func, count=10)

# Retry 10 times, waiting 2 seconds between attempts.
retry.on_error(func, count=10, duration=2.0, factor=1.0)

# Retry only if raised error is an instance of foo.Error.
retry.on_error(func, count=3, error=foo.Error)

The module provides the on_error() utility, for retrying function calls
up to number of retries with exponential backoff.

Example usage:

    # Retry 5 times. The wait between the retries is doubled on every
    # retry (1, 2, 4, 8, 16).
    retry.on_error(func)

    # Retry 10 times with up to 30 seconds between retries
    # (1, 2, 4, 8, 16, 30, 30, 30, 30, 30).
    retry.on_error(func, count=10)

    # Retry 10 times, waiting 2 seconds between attempts.
    retry.on_error(func, count=10, duration=2.0, factor=1.0)

    # Retry only if raised error is an instance of foo.Error.
    retry.on_error(func, count=3, error=foo.Error)

Signed-off-by: Nir Soffer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant