How to use the circuitbreaker.CircuitBreaker function in circuitbreaker

To help you get started, we’ve selected a few circuitbreaker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cuker / django-patchboard / patchboard / tests.py View on Github external
def test_breaker(self):
        class MyBreaker(CircuitBreaker):
            def run(self):
                assert not getattr(self, 'fail', False)
        
        breaker = MyBreaker(4, 600)
        self.assertTrue(breaker.is_ready())
        breaker()
        self.assertFalse(breaker.failures)
        breaker.open_circuit()
        self.assertFalse(breaker.is_ready())
        breaker.error_expiration = datetime.datetime.now()
        breaker()
        self.assertTrue(breaker.is_ready())
        breaker.fail = True
        for i in range(3):
            try:
                breaker()

circuitbreaker

Python Circuit Breaker pattern implementation

BSD-3-Clause
Latest version published 1 year ago

Package Health Score

61 / 100
Full package analysis