Skip to content

daroot/gevent-breaker

Repository files navigation

gevent-breaker

Build Status

Circuit Breaker pattern for gevent apps.

Install

$ pip install gevent-breaker

Usage

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")

About

Circuit Breaker Pattern for gevent apps.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages