larzretry
Retry & circuit breaker.
Real apps call things that fail intermittently - networks blip, services hiccup. larzretry makes them resilient: retry a failing call with optional exponential backoff, or wrap a troublesome dependency in a circuit breaker that stops hammering it once it's clearly down.
larzscript pkg install retry
What you get
- retry() decorator + call()
- Exponential backoff
- CircuitBreaker fail-fast
- Sleep + clock injectable
Try it
import "retry" as retry
let attempts = []
fn no_sleep(secs) { attempts.push(secs) }
let tries = 0
let result = retry.call(fn() {
tries = tries + 1
if tries < 3 { throw {"type": "LarzRuntimeError", "message": "flaky"} }
return "ok on try " + str(tries)
}, {"max_attempts": 5, "sleep_fn": no_sleep})
print(result)
print("backoff delays:", attempts)Output
ok on try 3 backoff delays: [1, 2]
Why it's in the Larz Stack
larzretry is a real Larzscript package (larzscript pkg install retry) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.