Circuitbreaker pattern for gevent apps
Project description
gevent-breaker
==============
[![Build Status](https://travis-ci.org/daroot/gevent-breaker.svg?branch=1.0.0)](https://travis-ci.org/daroot/gevent-breaker)
Circuit Breaker pattern for gevent apps.
Install
-------
$ pip install gevent-breaker
Usage
-----
```python
from gevent_breaker import circuit_breaker, CircuitBroken
while True:
try:
# After enough errors (5 by default), raise a CircuitBroken
with circuit_breaker("breaker1"):
1/0
except ZeroDivisionError:
print("Got an exception!")
except CircuitBroken:
print("Too many errors!")
break
try:
# Don't raise a CircuitBroken, instead just wait for a period
# of time (default 60s) before trying again.
with circuit_breaker("breaker2", block=True):
1/0
except ZeroDivisionError:
print("Got an exception")
```
==============
[![Build Status](https://travis-ci.org/daroot/gevent-breaker.svg?branch=1.0.0)](https://travis-ci.org/daroot/gevent-breaker)
Circuit Breaker pattern for gevent apps.
Install
-------
$ pip install gevent-breaker
Usage
-----
```python
from gevent_breaker import circuit_breaker, CircuitBroken
while True:
try:
# After enough errors (5 by default), raise a CircuitBroken
with circuit_breaker("breaker1"):
1/0
except ZeroDivisionError:
print("Got an exception!")
except CircuitBroken:
print("Too many errors!")
break
try:
# Don't raise a CircuitBroken, instead just wait for a period
# of time (default 60s) before trying again.
with circuit_breaker("breaker2", block=True):
1/0
except ZeroDivisionError:
print("Got an exception")
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gevent-breaker-1.0.0.tar.gz
(4.3 kB
view details)
Built Distribution
File details
Details for the file gevent-breaker-1.0.0.tar.gz
.
File metadata
- Download URL: gevent-breaker-1.0.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 400423211bdd0117f1184671bc31fc271b3893a4795f9982f543bc2ce76d6d26 |
|
MD5 | 05584d7c44e4480d97ebefef6c45e941 |
|
BLAKE2b-256 | cd3d130aedf20945128821071cbfa0342a7a79124603bce91b54aae3a0a0e000 |
File details
Details for the file gevent_breaker-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: gevent_breaker-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae1e0694b1324b69ba16812058bc260b1dd3e4a71b6feefe02f36583dea597f3 |
|
MD5 | 0159c224cba62ba5fdb9c3d80fad4859 |
|
BLAKE2b-256 | ae72b237b68ac096811e5aac8d6afa721f1a584735bb2ea1c84fc4824ad5e267 |