https://github.com/samarthj/pylib-helpers
Helpers for logging, sleeping, and other common functional work done across projects
https://github.com/samarthj/pylib-helpers
logging python3 retry-pattern
Last synced: about 1 month ago
JSON representation
Helpers for logging, sleeping, and other common functional work done across projects
- Host: GitHub
- URL: https://github.com/samarthj/pylib-helpers
- Owner: samarthj
- License: lgpl-3.0
- Created: 2021-08-09T18:19:58.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-09-27T03:51:16.000Z (almost 3 years ago)
- Last Synced: 2025-12-16T18:23:55.828Z (7 months ago)
- Topics: logging, python3, retry-pattern
- Language: Python
- Homepage:
- Size: 634 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# pylib-helpers
Helpers for logging, sleeping, and other common functional work done across projects
[](https://github.com/samarthj/pylib-helpers/actions/workflows/release.yml)
[](https://github.com/samarthj/pylib-helpers/releases)
[](https://pypi.org/project/pylib-helpers/)
[](https://github.com/samarthj/pylib-helpers/actions/workflows/build_matrix.yml)
[](https://lgtm.com/projects/g/samarthj/pylib-helpers/alerts/)
[](https://lgtm.com/projects/g/samarthj/pylib-helpers/context:python)
[](https://conventionalcommits.org)
## RetryHandler
Samples can be found here in the [tests](https://github.com/samarthj/pylib-helpers/blob/main/tests/test_retry_handler.py)
Example usage:
```python
from somelib import ClientError
from helpers import Logger, RetryHandler, Sleeper
LOGGER = Logger()
SLEEPER = Sleeper()
def _client_error(err_obj):
err_msg = str(err_obj)
if "Recoverable" not in err_msg:
raise err_obj
else:
LOGGER.print_error(err_msg)
SLEEPER.normal_sleep()
@RetryHandler(
(ClientError),
max_retries=10,
wait_time=0,
err_callbacks={"ClientError": (_client_error, {})},
).wrap
def do_the_thing(data):
pass
```