larzretry
Resilience for flaky operations — retry with backoff, and a circuit breaker.
Real apps call things that fail intermittently: networks blip, services hiccup, databases briefly stall. larzretry makes those operations resilient — retry a failing call a few times (with optional exponential backoff), or wrap a troublesome dependency in a circuit breaker that stops hammering it once it's clearly down. Sleep and clock are injectable, so it's fully testable. Zero dependencies.
Install
pip install larzretry
Use
from larzretry import retry, call, CircuitBreaker
@retry(times=3, backoff=0.1)
def fetch():
return risky_network_call()
call(fetch, times=5, exceptions=(ConnectionError,))
breaker = CircuitBreaker(threshold=3, reset_after=30)
breaker.call(fetch) # fails fast once the dependency is clearly down
Learn to code with Larz
Part of the learn-to-code toolkit in the Larz stack — see the Learn to Code platform. A building block for reliable production apps.
Tests
python -m unittest discover -s tests -v # 7 tests
License
MIT (c) larz-scripter
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file larzretry-0.1.0.tar.gz.
File metadata
- Download URL: larzretry-0.1.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff111861b85f3e7bf5249dc51c75ad3eef06903ce775827510a97319bf690e22
|
|
| MD5 |
48cd977d2770ec4cf37710ad112756ed
|
|
| BLAKE2b-256 |
d35cc28cbfe9fc99966104ad01181a2b448ee994aeecee7c7774b4ef488a677b
|
File details
Details for the file larzretry-0.1.0-py3-none-any.whl.
File metadata
- Download URL: larzretry-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd53203a1cb02a22ab70b24bd9ccc51237c85add0309dd8eb6a1a09efb1a43c2
|
|
| MD5 |
7c16eec7a44495f4bd32f02125482163
|
|
| BLAKE2b-256 |
b5a491b5291aa577e6f4d2395ba296b2c110e81d23b2447fbf685f6f44ef84f5
|