A simple util library for creating applications which needs to keep running, despite abnormalities
Project description
About
A simple util library for creating applications which needs to keep running, despite abnormalities
Installing
pip install pyrobustness
Usage
Timeout example:
from robust.tools import timeout @timeout(5) def very_long_job(): import time while True: print("Zzz") time.sleep(1) very_long_job()
Retry example:
from robust.tools import retry @retry(5) def very_broken_method(): print(".") raise RuntimeError("Something is broken...") while True: very_broken_method()
Circuit Breaker example:
import time from robust.tools import breaker counter = 0 @breaker(limit=5, revive=5) def very_broken_method(): nonlocal counter if counter <= 5: counter += 1 raise RuntimeError("Something is broken...") else: print("We've made it!") while True: try: very_broken_method() except RuntimeError: pass except Exception: break time.sleep(5) very_broken_method()
Version History
- 1.1:
- Additional type for alarm - threading to support Windows OS, or certain cases when signal is not working as supposed
- CircuitBreaker pattern, inspired by speech by Daniel Riti @Pycon 2016
- 1.0: Initial version
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
pyrobustness-1.1.2.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for pyrobustness-1.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce74daa3e528e65fe083170e3672f53482f9cfe5dabc41485eb1351382ac0e8e |
|
MD5 | ced517c899982454a7ce8386c8faec77 |
|
BLAKE2-256 | 27899d487e513136bde56e70ab436a4edbc207a0b5d28340dd85cb96d328e152 |