/retry_module

Primary LanguagePythonMIT LicenseMIT

Retry Module

Documentation Status Updates

A simple decorator for implementing retry mechanishm

Installation and Usage

  • Install it using pip
pip install retry_module
  • Use the retry decorator to retry functions on exception.
from retry_module.decorators import retry
from random import random

@retry(SomeError, max_retries=10)
def func():
    random_num = random()
    if random_num < 0.6:
        return "Yaay!"
    else:
        raise SomeError("There you go!")

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Special thanks to u/Ran4 for reviewing the code.