{"id":28072,"library":"purgatory","title":"Purgatory","description":"A circuit breaker implementation for asyncio. Current version 3.0.1, requires Python >=3.9. Releases are sporadic.","status":"active","version":"3.0.1","language":"python","source_language":"en","source_url":"https://github.com/mardiros/purgatory.git","tags":["circuit-breaker","asyncio","resilience"],"install":[{"cmd":"pip install purgatory","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"In older versions (pre-3.0) the class was in a submodule. Since 3.0, it's re-exported from the top-level package.","wrong":"from purgatory.circuit_breaker import CircuitBreaker","symbol":"CircuitBreaker","correct":"from purgatory import CircuitBreaker"}],"quickstart":{"code":"import asyncio\nfrom purgatory import CircuitBreaker\n\nasync def main():\n    breaker = CircuitBreaker(\n        failure_threshold=5,\n        recovery_timeout=30,\n        half_open_max_calls=1\n    )\n\n    for _ in range(10):\n        async with breaker:\n            print(\"Call succeeded\")\n\nasyncio.run(main())","lang":"python","description":"Basic usage of Purgatory's CircuitBreaker context manager."},"warnings":[{"fix":"Change imports from `from purgatory.circuit_breaker import CircuitBreaker` to `from purgatory import CircuitBreaker`.","message":"Version 3.0 changed the import path: CircuitBreaker is now directly importable from `purgatory` instead of `purgatory.circuit_breaker`.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Wrap the `async with breaker:` block in a try/except and implement exponential backoff retries.","message":"The `CircuitBreaker` context manager does NOT automatically retry. If the breaker is open, it raises `CircuitBreakerOpenError` immediately. You must implement retry logic yourself.","severity":"gotcha","affected_versions":"all"},{"fix":"Be aware of the reset behavior; adjust threshold accordingly.","message":"The `failure_threshold` counts consecutive failures. A single success resets the counter. This differs from some other circuit breaker implementations (e.g., Hystrix) that use a sliding window.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use `from purgatory import CircuitBreaker` instead.","cause":"Importing from old submodule path after upgrading to v3.0+.","error":"ModuleNotFoundError: No module named 'purgatory.circuit_breaker'"},{"fix":"Wait for recovery_timeout seconds before retrying, or implement a retry mechanism with backoff.","cause":"Circuit breaker is open; too many failures occurred.","error":"purgatory.exceptions.CircuitBreakerOpenError"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}