PyFaultTolerance
Um microframework Python para tolerância a falhas assíncrona, inspirado no SmallRye Fault Tolerance.
Ideal para sistemas resilientes que utilizamasyncioouFastAPI.
✨ Funcionalidades
- ✅
@timeout_async: interrompe execução que exceder o tempo limite - 🔁
@retry_async: reexecuta em caso de falha, com controle de tentativas - 🧱
@bulkhead: limita concorrência simultânea (isolamento de chamadas) - 🔌
@fallback: define alternativa automática em caso de falha - 🚧
CircuitBreaker: previne chamadas para funções que falharam repetidamente - 📦 Exceções personalizadas com logs estruturados
📦 Instalação
Você pode instalar a biblioteca diretamente do PyPI:
pip install pyfaulttolerance
🚀 Uso
Timeout
from pyfaulttolerance.timeout import timeout, TimeoutException
@timeout(seconds=2)
def funcao_lenta():
# código que pode demorar
pass
Retry
from pyfaulttolerance.retry_async import retry_async
@retry_async(max_attempts=3, delay=1)
async def funcao_instavel():
# código que pode falhar
pass
Fallback
from pyfaulttolerance.fallback import fallback
async def alternativa():
return "valor alternativo"
@fallback(alternativa)
async def funcao_principal():
# código que pode falhar
pass
Bulkhead
from pyfaulttolerance.bulkhead import bulkhead
@bulkhead(max_concurrent_calls=2)
async def tarefa():
# código que deve ser limitado em concorrência
pass
Circuit Breaker
from pyfaulttolerance.circuit_breaker import CircuitBreaker
cb = CircuitBreaker(failure_threshold=3, recovery_timeout=10)
@cb
async def funcao():
# código que pode falhar
pass
📄 Licença
Este projeto está licenciado sob a Licença MIT. Consulte o arquivo LICENSE para mais detalhes.
Para mais informações, visite o repositório oficial: https://github.com/gomesrocha/pyfaulttolerance
Release files for pyfaulttolerance 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyfaulttolerance-0.1.3.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyfaulttolerance-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.0 kB
Release files / pyfaulttolerance-0.1.3.tar.gz
| Download URL | pyfaulttolerance-0.1.3.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c510d116dbc02fb3453bb8f22726f0d090454c3c7e09b472effcee2d6b4ce41b
|
|
BLAKE2b-256 checksum How to use checksums |
3c0866613b84bab09e5e67892805468e10aa98324b32a75111ff4718b47b0065
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 13, 2025.
Transparency logRelease files / pyfaulttolerance-0.1.3-py3-none-any.whl
| Download URL | pyfaulttolerance-0.1.3-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
38272bd8f93c4e0f357449a0c1fc57dc578d076710b7e9655f74a97f8b130a9f
|
|
BLAKE2b-256 checksum How to use checksums |
1dd43dbaef30ba3033f10f5ef58103fbdbebc35ea34e3d896374664197989723
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 13, 2025.
Transparency log