Helper for retrying code when exception occur
Project description
Retry Helper
Helper tool fro retrying code when soem exceptions occur
Usage
RetryManager
Retry manager is context manager for retrying block of code. In fact its double layer context manager in first context you will create context manager and use while retry object is true. And the run you code in context of retry.attempt.
- max_attempts - maximum count of attempts, default 1
- wait_seconds - How many second it should wait before next retry, default 0
- exceptions - exception class or tuple of exceptions classes which cause retry, if None all exceptions cause retry default None
- reset_func - function to be run before each retry (it is not call on first try)
with RetryManager(max_attempts=20, wait_seconds=1, exceptions=(TypeError,KeyError)) as retry:
while retry:
with retry.attempt:
# code raising exception if fail
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
retry_helper-0.0.4.tar.gz
(3.4 kB
view details)
File details
Details for the file retry_helper-0.0.4.tar.gz
.
File metadata
- Download URL: retry_helper-0.0.4.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d76c1fcff4719e0916f452fc30f9828a98c64150904a5fafd6a2a37a7190d3b |
|
MD5 | 85708ed32d6578d9d2fcf3a68b066ee1 |
|
BLAKE2b-256 | d9c812be74c0b0715f552bc417c7a50fd4763b2f30d93cba84333a8a3601fe0f |