Skip to main content

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

Metadata

Release files for larzretry 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for larzretry 0.1.0
File Size Uploaded Provenance
larzretry-0.1.0.tar.gz 7.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for larzretry 0.1.0
File Interpreter ABI Platform
larzretry-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.9 kB

Release files / larzretry-0.1.0.tar.gz

Download URL larzretry-0.1.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ff111861b85f3e7bf5249dc51c75ad3eef06903ce775827510a97319bf690e22
BLAKE2b-256 checksum
How to use checksums
d35cc28cbfe9fc99966104ad01181a2b448ee994aeecee7c7774b4ef488a677b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / larzretry-0.1.0-py3-none-any.whl

Download URL larzretry-0.1.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd53203a1cb02a22ab70b24bd9ccc51237c85add0309dd8eb6a1a09efb1a43c2
BLAKE2b-256 checksum
How to use checksums
b5a491b5291aa577e6f4d2395ba296b2c110e81d23b2447fbf685f6f44ef84f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for larzretry 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page