Skip to main content

asyncbreaker

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 Listener 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 changelog.md for the full API story (listeners, storage, open / close / half_open, exclusion rules). A MkDocs site will be added later.

Development

This project uses uv:

uv sync
uv run pytest test

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).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asyncbreaker-2.1.0.tar.gz (102.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asyncbreaker-2.1.0-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file asyncbreaker-2.1.0.tar.gz.

File metadata

  • Download URL: asyncbreaker-2.1.0.tar.gz
  • Upload date:
  • Size: 102.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for asyncbreaker-2.1.0.tar.gz
Algorithm Hash digest
SHA256 ba390916431656ab16ed71f88822a4f6850ac81203b423c908bb2f86dc5d368d
MD5 e86e468feca24917cdc2ae90f63048a2
BLAKE2b-256 f0921d35a42a7ad1bb1b5e9f5cfedb7c78f1155401beef509f3636ba0a89ab5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for asyncbreaker-2.1.0.tar.gz:

Publisher: publish.yml on freemspwnz/asyncbreaker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asyncbreaker-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: asyncbreaker-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for asyncbreaker-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f89b8bde4216b896a9cee24096e18f10924dc4488c4e5b6ad2a311b7f1c5b264
MD5 dc3343e1159d405986700f6aa9684c79
BLAKE2b-256 33724d6810071a1d1abeaf41baac04eaa7edea9f31a10d1f0cfd42fec252a004

See more details on using hashes here.

Provenance

The following attestation bundles were made for asyncbreaker-2.1.0-py3-none-any.whl:

Publisher: publish.yml on freemspwnz/asyncbreaker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

2.1.1

2 files

This release

2.1.0 This release

2 files

2.0.1

2 files

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