Skip to main content

aiobreaker-redis

🛡 Distributed async circuit breaker for Python asyncio, httpx, and FastAPI with Redis state synchronization.

PyPI version License: MIT


💡 Features

  • ⚡️ Pure asyncio First: Zero blocking I/O, built natively for Python async/await applications.
  • 🌐 Distributed Redis State: Synchronize circuit breaker status (CLOSED, OPEN, HALF_OPEN) across multiple Gunicorn/Uvicorn worker processes and Kubernetes pods.
  • 🎯 Fast Fallbacks: Execute sync or async fallbacks instantly when circuits trip open.
  • 🚀 FastAPI & httpx Ready: Clean @breaker.wrap(fallback=...) decorator for API endpoints and HTTP client wrappers.

📦 Installation

pip install aiobreaker-redis

🚀 Quick Usage

import httpx
from aiobreaker_redis import CircuitBreaker, CircuitOpenError

breaker = CircuitBreaker(
    name="payment-gateway",
    failure_threshold=5,
    recovery_timeout=30.0,
    # Optional redis client:
    # redis_client=redis_client
)

async def payment_fallback():
    return {"status": "queued", "message": "Payment service temporarily unavailable"}

@breaker.wrap(fallback=payment_fallback)
async def charge_card(amount: float):
    async with httpx.AsyncClient() as client:
        response = await client.post("https://api.payments.com/charge", json={"amount": amount})
        response.raise_for_status()
        return response.json()

📄 License

MIT © Raj Dubey

Release files for aiobreaker-redis 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiobreaker-redis 0.1.0
File Size Uploaded
aiobreaker_redis-0.1.0.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiobreaker-redis 0.1.0
File Interpreter ABI Platform
aiobreaker_redis-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / aiobreaker_redis-0.1.0.tar.gz

Download URL aiobreaker_redis-0.1.0.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
22e3ec8fa3775e05d5cdb6681fb1ecc824c14f9d82860a72d405d2613f72cc9f
BLAKE2b-256 checksum
How to use checksums
43aa380fc11559a4852ea6196f29d5e2e30f53ad751d7307de2feb6b0d6a09c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / aiobreaker_redis-0.1.0-py3-none-any.whl

Download URL aiobreaker_redis-0.1.0-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d77aadcd19ea8fe77c97b5112eb42697e5314b8247f2f9b1a275ade2cadac08d
BLAKE2b-256 checksum
How to use checksums
ae46b4b77544aaa7c5d7f76b98f05f84c5f8dcacca67ee5f018bc4df70d60c2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release 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