Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should listener.failure be called when the circuit is closed and a call fails? #16

Closed
sj175 opened this issue Jun 1, 2017 · 10 comments · Fixed by #17
Closed

Should listener.failure be called when the circuit is closed and a call fails? #16

sj175 opened this issue Jun 1, 2017 · 10 comments · Fixed by #17

Comments

@sj175
Copy link

sj175 commented Jun 1, 2017

When the circuit breaker's state is closed and the call to the wrapped function fails the listener.failure function is not called because an exception is thrown in CircuitClosedState.on_failure. Is this behaviour intentional?

The block below is from the CircuitBreakerState class:

    def _handle_error(self, exc):
        """
        Handles a failed call to the guarded operation.
        """
        if self._breaker.is_system_error(exc):
            self._breaker._inc_counter()
            self.on_failure(exc)
            for listener in self._breaker.listeners:
                listener.failure(self._breaker, exc)
        else:
            self._handle_success()
        raise exc
@danielfm
Copy link
Owner

danielfm commented Jun 1, 2017

Good catch.

AFAIK this behavior is not intentional, seems more like a bug to me.

@danielfm
Copy link
Owner

danielfm commented Jun 1, 2017

Just pushed a new version, that hopefully fixes this issue, can you take some time to test it?

@sj175
Copy link
Author

sj175 commented Jun 1, 2017

Sure, all my tests pass at the moment but it's still fairly early in my development process.

@sj175
Copy link
Author

sj175 commented Jun 1, 2017

Actually, it looks like Redis is now a dependency, it wasn't before. If that was intentional, that's fine. Otherwise, my tests are now broken.

@danielfm
Copy link
Owner

danielfm commented Jun 1, 2017

Redis is an optional dependency, in case you enable the Redis backing. You should be able to use it without it though.

@sj175
Copy link
Author

sj175 commented Jun 1, 2017

I get ImportError: CircuitRedisStorage can only be used if the required dependencies exist as soon as I import pybreaker, using Python 3.6.

@danielfm
Copy link
Owner

danielfm commented Jun 1, 2017

This is a bug; redis should not be required to use pybreaker.

I'll see what I can do. /cc @phillbaker

@phillbaker
Copy link
Contributor

Ouch. Sorry about that. I'll take a look tonight.

@danielfm
Copy link
Owner

danielfm commented Jun 2, 2017

@sj175 can you please try 0.3.3 to see if the last PR fixes the issue? Feel free to reopen this in case it didn't.

@sj175
Copy link
Author

sj175 commented Jun 3, 2017

That's fixed. Brilliant, thank you!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants