Asyncio Circuit Breaker pattern with optional Redis storage.
Project description
asyncbreaker is an asyncio-first Python implementation of the Circuit Breaker pattern from Michael T. Nygard’s book Release It!.
Circuit breakers let one subsystem fail without taking down the whole application: you wrap risky calls (often I/O or integration boundaries) so that repeated failures trip the breaker, subsequent calls fail fast for a reset timeout, then a single trial call may close the circuit again.
Lineage
pybreaker (Daniel Fernandes Martins) — original design.
aiobreaker fork (Alexander Lyon) — asyncio instead of Tornado, packaging experiments.
Current line — maintained by Sergey Turbinov; substantial rewrite toward a pure async API, async storage, and async listeners. Contact: @freems on Telegram.
Features
Async CircuitBreaker — use await breaker.call(...)
Configurable failure threshold (fail_max) and reset window (timeout_duration)
Excluded exceptions and predicate callables (business vs system errors)
Multiple async CircuitBreakerListener instances
Pluggable async storage: in-process memory or Redis via redis.asyncio
Optional redis extra for Redis-backed storage
Requirements
Python 3.10+ (async patterns and typing used throughout).
Installation
pip install asyncbreaker
With Redis support (redis package):
pip install asyncbreaker[redis]
Usage
Create a breaker per integration point. Only async callables are supported; the decorator rejects ordinary def functions.
from datetime import timedelta
from asyncbreaker import CircuitBreaker
api_breaker = CircuitBreaker(fail_max=5, timeout_duration=timedelta(seconds=60))
@api_breaker
async def fetch_remote():
...
# or explicitly:
await api_breaker.call(fetch_remote)
See the Usage chapter in the full documentation (docs/) for listeners, storage, manual open / close / half_open, and exclusion rules.
Documentation
Build locally:
pip install -e '.[docs]'
sphinx-build docs/source docs/build
The HTML entry point is docs/build/index.html.
License
BSD 3-Clause; see license.md. This project bundles copyright from the pybreaker lineage; additional copyright applies to the asyncio rewrite (see license.md).
Project details
Release history Release notifications | RSS feed
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 asyncbreaker-2.0.1.tar.gz.
File metadata
- Download URL: asyncbreaker-2.0.1.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35164f745246318c527301d9973abf7261353a2d162fd1f1441604191b112656
|
|
| MD5 |
3b3365bb5676ed3441b9ccd5813a3e1c
|
|
| BLAKE2b-256 |
9616337e5d498947c324c59be2283c97af3c51a9701c4a690ee1838a90f1b770
|
Provenance
The following attestation bundles were made for asyncbreaker-2.0.1.tar.gz:
Publisher:
publish.yml on freemspwnz/asyncbreaker
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asyncbreaker-2.0.1.tar.gz -
Subject digest:
35164f745246318c527301d9973abf7261353a2d162fd1f1441604191b112656 - Sigstore transparency entry: 1247016582
- Sigstore integration time:
-
Permalink:
freemspwnz/asyncbreaker@f2759c09241c7ea1f737c5acf507bf0c950fa7eb -
Branch / Tag:
refs/tags/v2.0.1 - Owner: https://github.com/freemspwnz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f2759c09241c7ea1f737c5acf507bf0c950fa7eb -
Trigger Event:
push
-
Statement type:
File details
Details for the file asyncbreaker-2.0.1-py3-none-any.whl.
File metadata
- Download URL: asyncbreaker-2.0.1-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4ee009b39d9f6be68bccbc96569727502c0ee6b71dc6fcb2c7a931e2f9911bd
|
|
| MD5 |
1ce1f3ac2b4a8d1073336e6f352a74fe
|
|
| BLAKE2b-256 |
ad847c05afe09a0a884c4cb21f85186b51a1284e5c5f6214c3061c51b9b79205
|
Provenance
The following attestation bundles were made for asyncbreaker-2.0.1-py3-none-any.whl:
Publisher:
publish.yml on freemspwnz/asyncbreaker
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
asyncbreaker-2.0.1-py3-none-any.whl -
Subject digest:
c4ee009b39d9f6be68bccbc96569727502c0ee6b71dc6fcb2c7a931e2f9911bd - Sigstore transparency entry: 1247016586
- Sigstore integration time:
-
Permalink:
freemspwnz/asyncbreaker@f2759c09241c7ea1f737c5acf507bf0c950fa7eb -
Branch / Tag:
refs/tags/v2.0.1 - Owner: https://github.com/freemspwnz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f2759c09241c7ea1f737c5acf507bf0c950fa7eb -
Trigger Event:
push
-
Statement type: