Wraps any method which throws exceptions. Retries calls when exceptions are thrown. Available on PyPI and installable via pip. Don't forget to star the project!
- Check the unit tests for usage.
- Build and run tests locally:
tox
- Publish to test pypi:
tox -e clean && tox -e build && tox -e publish
- Publish to pypi:
git tag MAJOR.MINOR[.PATCH]
tox -e clean && tox -e build
tox -e publish -- --repository pypi
Example usage:
@exception_with_retry(n_retry=3, sleep_time_s=1.5)
def wrapped_method(number_1: int, number_2: int = 0, calls: List = []):
calls.append(1)
if number_1 < 0:
raise Exception("Not going to happen")
else:
return number_1 + number_2
This project uses pre-commit, please make sure to install it before making any changes::
pip install pre-commit
cd exception-with-retry
pre-commit install
It is a good idea to update the hooks to the latest version::
pre-commit autoupdate
Don't forget to tell your contributors to also install and use pre-commit.
This project has been set up using PyScaffold 4.0.2. For details and usage information on PyScaffold see https://pyscaffold.org/.