Skip to main content

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


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.0.1.tar.gz (19.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.0.1-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

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

Hashes for asyncbreaker-2.0.1.tar.gz
Algorithm Hash digest
SHA256 35164f745246318c527301d9973abf7261353a2d162fd1f1441604191b112656
MD5 3b3365bb5676ed3441b9ccd5813a3e1c
BLAKE2b-256 9616337e5d498947c324c59be2283c97af3c51a9701c4a690ee1838a90f1b770

See more details on using hashes here.

Provenance

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

Hashes for asyncbreaker-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c4ee009b39d9f6be68bccbc96569727502c0ee6b71dc6fcb2c7a931e2f9911bd
MD5 1ce1f3ac2b4a8d1073336e6f352a74fe
BLAKE2b-256 ad847c05afe09a0a884c4cb21f85186b51a1284e5c5f6214c3061c51b9b79205

See more details on using hashes here.

Provenance

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page