Skip to main content

Resilience AOP for the Pico ecosystem: @retryable, @circuit_breaker and @timeout method interceptors.

Project description

📦 pico-resilience

PyPI Ask DeepWiki License: MIT CI (tox matrix) codecov Quality Gate Status Duplicated Lines (%) Maintainability Rating PyPI Downloads Docs Interactive Lab

Spring-style resilience annotations for the Pico ecosystem, built on pico-ioc method interception and auto-discovered by pico-boot. Zero-config.

Decorator Policy
@retryable(max_attempts, backoff_seconds, retry_on) Exponential-backoff retry (sync + async)
@circuit_breaker(failure_threshold, reset_timeout_seconds) Per-method circuit: closed → open → half-open
@timeout(seconds) Async time budget via asyncio.timeout

Install

pip install pico-resilience

Use

from pico_ioc import component
from pico_resilience import retryable, circuit_breaker, timeout

@component
class PaymentGateway:
    @retryable(max_attempts=3, backoff_seconds=0.2, retry_on=(ConnectionError,))
    @circuit_breaker(failure_threshold=5, reset_timeout_seconds=30)
    def charge(self, order): ...

    @timeout(2.0)
    async def query_partner(self, q): ...

Failures raise RetryExhaustedError / CircuitOpenError / TimeoutError with the method name. resilience.enabled: false in application.yaml bypasses every policy (handy in tests).

Chain rule: put @retryable at the top when combining decorators (it runs innermost); @circuit_breaker/@cacheable below it then wrap the whole retry loop — the circuit counts exhausted retries and the cache stores the final result. @timeout rejects sync methods at import time: a thread cannot be cancelled, and a timeout that lies is worse than none.

Documentation

Full docs at dperezcabrera.github.io/pico-resilience.

License

MIT

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

pico_resilience-0.1.0.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pico_resilience-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file pico_resilience-0.1.0.tar.gz.

File metadata

  • Download URL: pico_resilience-0.1.0.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pico_resilience-0.1.0.tar.gz
Algorithm Hash digest
SHA256 96f3cfdefbd9e880f01ae4a43387649f5707850c268871f61ab8d86fa8e59a42
MD5 4c55b382756e81453756c6c60209ac5f
BLAKE2b-256 feb9e43d6207c00bdde04dc5a090473a5a9b4a2e09d605980e29baefec14866e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pico_resilience-0.1.0.tar.gz:

Publisher: publish-to-pypi.yml on dperezcabrera/pico-resilience

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pico_resilience-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pico_resilience-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da553f6db6799d6cfa79dd16a370ef856aca2867bcccb8e5dcda9943e27eb128
MD5 4be8c6180ac2f2d18d2c771566fc17c2
BLAKE2b-256 2d69b485f1af4fbed679300bf4aac27a63d404b32630a6d9588cc50b450dfe8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pico_resilience-0.1.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on dperezcabrera/pico-resilience

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