Skip to main content

Retry package for Python

Project description

Python Retry

License-MIT Documentation Status GitHub Actions Badge PyPi

Features

  1. Generic Decorator

  2. Specify stop condition (i.e. limit by number of attempts)

  3. Specify wait condition (i.e. exponential backoff sleeping between attempts)

  4. Customize retrying on Exceptions

Read the docs for further information.

Installation

Install using pip:

pip install python-retry

Example

>>> from python_retry import retry
>>> import pytest
>>>
>>> @retry()
... def div(num: int, den: int):
...     return num/den
>>>
>>> div(1, 0)

Advanced use

>>> import logging
>>> logger = logging.getLogger("foo")
>>>
>>> @retry(
...     retry_on=(ZeroDivisionError,),
...     max_retries=2,
...     backoff_factor=1,
...     supress_exception=True,
...     retry_logger=logger
... )
... def div(num: int, den: int):
...     return num / den
>>>
>>> div(1, 0)

Documentation

You can find here at Read the docs the complete documentation.

Changelog

0.0.1 (2022-03-09)

  • Initial project structure.

  • Test suite.

  • Examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

python_retry-0.0.1-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page