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.1.tar.gz (102.7 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.1-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: asyncbreaker-2.1.1.tar.gz
  • Upload date:
  • Size: 102.7 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.1.tar.gz
Algorithm Hash digest
SHA256 edac3a40166b5fb90d35b481e5f39197e05c3374a34435cc8948c8e49fc76fdb
MD5 6e93a971a307a5e2419c03b32061b2be
BLAKE2b-256 dd6e773a6e181682117b0a78992d99aadae75b5ddf20e4656b72d70cb786ff42

See more details on using hashes here.

Provenance

The following attestation bundles were made for asyncbreaker-2.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: asyncbreaker-2.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 606d1021b16f62beca9b51f71d0838c1341e7ee077bb4673dab5e2ef6ad311bc
MD5 270681bd7deb7e96d75dc9c706c30368
BLAKE2b-256 d76e503034ea4b855d4665204c3590f72d218b41ff5c0d5014f2049b2bbc9bf1

See more details on using hashes here.

Provenance

The following attestation bundles were made for asyncbreaker-2.1.1-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

This release

2.1.1 This release

2 files

2.1.0

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