Skip to contents

Retrying

Call a function again when it fails.

Caching

Remember a function’s results.

lru_cache() cache() disk_cache()
Cache function results
async_lru_cache() async_cache() async_disk_cache()
Cache the results of asynchronous functions

Circuit breaking

Stop calling a function that keeps failing.

circuit_breaker()
Stop calling a function that keeps failing
async_circuit_breaker()
Stop calling an asynchronous function that keeps failing

Timeouts

Bound how long a single call can run.

timeout_r() timeout() timeout_remaining()
Bound how long a call can run
timeout_base() timeout_fn()
Write your own timeout method
async_timeout() async_timeout_base() async_timeout_fn() async_timeout_later()
Bound how long an asynchronous call can take

Rate limiting

Limit how often a function can be called.

rate_limit()
Limit how often a function can be called
async_rate_limit()
Limit how often an asynchronous function can be called

Fallbacks

Return a default instead of failing.

fallback()
Return a default when a function fails
async_fallback()
Return a default when an asynchronous function fails

Observability

Log calls.

log_call()
Log the calls to a function
async_log_call()
Log the calls to an asynchronous function
log_levels()
The level of each event log_call() logs
logger_base() logger_fn() logger_message()
Loggers
extending_log
Use a logging package with log_call()

Running once

Do setup a single time.

once()
Run a function only once
async_once()
Run an asynchronous function only once

Validation

Check arguments and return values.

validate_args() validate_return()
Validate arguments and return values
async_validate_return()
Validate the value an asynchronous function resolves to

Context managers

Write setup and teardown once.

contextmanager() teardown()
Write setup and teardown once
with_context()
Run code inside a context
as_decorator()
Use a context manager as a decorator

Re-exports

reexports := %@%
Objects exported from other packages