Repolode
danielfm

danielfm/pybreaker

A Python implementation of the Circuit Breaker pattern that stops calls to failing dependencies to protect the rest of a system.

Stars
700
Forks
96
Open issues
28
Last commit
last month

What is it?

PyBreaker wraps calls to unreliable integration points such as databases, queues or external services. After a configured number of consecutive failures, the circuit opens and subsequent calls fail immediately instead of waiting on a broken dependency. After a reset timeout, the next call is let through to test whether the dependency has recovered.

A circuit breaker can be applied as a decorator, through a direct call method, or as a context manager. It supports excluding business exceptions from failure counting, multiple event listeners, and guarding generator functions. State can be inspected and changed at runtime through properties and methods.

State can be kept in memory or stored in Redis, with a separate namespace per breaker. Optional support for asynchronous Tornado coroutines is also included. The library requires Python 3.10 or later.

Key features

  • 01Configurable failure threshold and reset timeout
  • 02Excludes business exceptions from failure counting by type or callable
  • 03Multiple event listeners per circuit breaker
  • 04Can guard generator functions
  • 05Optional Redis-backed state storage
  • 06Optional support for asynchronous Tornado calls

Use cases

  • Protecting database calls from cascading failures when the database is unavailable
  • Failing fast on calls to a flaky third-party HTTP API
  • Logging or alerting on circuit state changes in production services

Quick start

  1. 1

    Install PyBreaker from PyPI

    pip install pybreaker
  2. 2

    Create a CircuitBreaker and guard a function with it

Things to know

  • Requires Python 3.10 or newer.

In collections

Topics

#circuit-breaker#resilience#fault-tolerance#python#redis#microservices

FAQ

What is pybreaker?
A Python implementation of the Circuit Breaker pattern that stops calls to failing dependencies to protect the rest of a system. PyBreaker wraps calls to unreliable integration points such as databases, queues or external services. After a configured number of consecutive failures, the circuit opens and subsequent calls fail immediately instead of waiting on a broken dependency. After a reset timeout, the next call is let through to test whether the dependency has recovered.
Is pybreaker free to use? What license does it have?
pybreaker is open source under the BSD-3-Clause license. Check the license terms before using it in commercial products.
Is pybreaker still maintained?
Updated within 6 months. The last commit to pybreaker was on Sep 25, 2026.
What can I use pybreaker for?
Protecting database calls from cascading failures when the database is unavailable Failing fast on calls to a flaky third-party HTTP API Logging or alerting on circuit state changes in production services
How do I install pybreaker?
Install PyBreaker from PyPI: pip install pybreaker Create a CircuitBreaker and guard a function with it
Where can I get pybreaker?
The source code and installation instructions are on GitHub: https://github.com/danielfm/pybreaker

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects

A lightweight Java fault tolerance library offering circuit breaker, rate limiter, retry, bulkhead and time limiter decorators for functional code.

Backend & APIs#java#fault-tolerance#circuit-breaker
10.8K+2 this week1.5KJavaApache-2.0Updated 8 days ago