skillfed

circuitbreaker

Python Circuit Breaker pattern implementation

circuitbreaker v2.1.3 10.8M downloads/30d#1,433 on PyPI522
Permissive license BSD-3-Clause AGING released

What it is and what it does

CircuitBreaker is a Python decorator that implements the Circuit Breaker pattern to protect distributed systems from cascading failures. When you decorate a function with @circuit, the decorator monitors execution, counts failures, and stops calling the function after a configurable threshold (default: 5 failures) is reached. After a recovery timeout (default: 30 seconds), it enters a half-open state to test whether the integration point has recovered.

The decorator supports both synchronous and asynchronous functions, and you can customize which exceptions trigger the circuit to open, set different failure thresholds and recovery timeouts, and provide fallback functions to execute when the circuit is open. It also integrates with a CircuitBreakerMonitor to track the health and state of all active circuit breakers in your application.

Use it for:

  • Protect HTTP clients from repeatedly calling unavailable external APIs by opening the circuit after connection failures.
  • Prevent database connection pools from exhausting resources when a database is temporarily down.
  • Implement graceful degradation in microservices by using fallback functions when downstream services are unavailable.
  • Monitor the health of multiple integration points across your application via CircuitBreakerMonitor.
  • Rate-limit or fail fast on specific HTTP errors (e.g., 429 Too Many Requests) using custom exception logic.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A Python decorator that implements the Circuit Breaker pattern to prevent cascading failures in distributed systems by monitoring function calls, counting failures, and stopping execution after a threshold is reached.

Yes. CircuitBreaker is a straightforward, dependency-free implementation of a well-established resilience pattern. It works with both sync and async code, has no install friction, and carries a permissive license. The aging maintenance status (last release 501 days ago) is a minor concern for a stable, narrowly-scoped library, but verify that its feature set and behavior match your needs before adopting it in production.

Install

circuitbreaker on PyPI

pip

pip install circuitbreaker

uv

uv add circuitbreaker

poetry

poetry add circuitbreaker

Installing circuitbreaker

Before you install

Low install friction with no runtime dependencies. Maintenance is aging—last commit was 2025-03-31 and the project has not released since then, though the repository remains active and not archived.

License in practice

BSD-3-Clause is a permissive license, allowing broad use, modification, and distribution with minimal restrictions.

Quickstart

from circuitbreaker import circuit

@circuit
def external_call():
    pass

# Or with configuration:
@circuit(failure_threshold=10, expected_exception=ConnectionError)
def external_call():
    pass

Verify before relying

  • Whether the aging maintenance status (501 days since last release) affects stability or security for production use.
  • Performance characteristics under high-concurrency or high-failure-rate scenarios.
  • Compatibility with modern async frameworks beyond basic async/await support.

Package facts

License BSD-3-Clause (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance aging — 501 days since the last release
Last repo commit
First released
Downloads 10,803,044/month — #1,433 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: circuitbreaker-2.1.3-py3-none-any.whl

Intended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: MacOSOperating System :: POSIXOperating System :: UnixProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

circuit breaker patternfault tolerance decoratorprevent cascading failuresdistributed system resiliencefailure threshold monitoringasync function protectionintegration point protection
resiliencefault-tolerancedistributed-systems

More Monitoring packages

tqdm

Wraps any iterable to display a real-time…

copyleft · top 100 on PyPI

opentelemetry-semantic-conventions

Provides generated Python code for…

permissive · top 100 on PyPI

opentelemetry-sdk

Provides the reference implementation of the…

permissive · top 100 on PyPI

opentelemetry-api

Provides the abstract API and interfaces for…

permissive · top 100 on PyPI

opentelemetry-exporter-otlp-proto-http

Exports OpenTelemetry observability data to an…

permissive · top 1,000 on PyPI

opentelemetry-instrumentation

Provides automatic instrumentation commands and…

permissive · top 1,000 on PyPI

aiobreaker

Implements the Circuit Breaker pattern for…

permissive · top 15,000 on PyPI

purgatory

Purgatory implements the circuit breaker…

permissive · top 15,000 on PyPI

pybreaker

PyBreaker wraps function calls with a circuit…

permissive · top 1,000 on PyPI

metaflow-checkpoint

Provides decorators for Metaflow workflows to…

unclear · top 15,000 on PyPI

retry2

Provides a decorator and function wrapper to…

permissive · top 5,000 on PyPI

singleton-decorator

Provides a decorator that enforces singleton…

copyleft · top 15,000 on PyPI

multimethod

Multimethod provides a decorator for adding…

permissive · top 5,000 on PyPI

python-backoff

Provides function decorators for retrying…

permissive · top 5,000 on PyPI

pytest-check

A pytest plugin that allows tests to continue…

unclear · top 5,000 on PyPI

delayed-assert

Collects multiple assertion failures in a test…

unclear · top 15,000 on PyPI