danielfm / pybreaker

Python implementation of the Circuit Breaker pattern.
BSD 3-Clause "New" or "Revised" License
508 stars 74 forks source link

Contextmanager / `with` API? #85

Closed martijnthe closed 7 months ago

martijnthe commented 8 months ago

Would you be open to accepting a PR to make CircuitBreaker also possible to use like so:

with circuit_breaker:
   do_the_thing_that_can_fail()

I think this is slightly nicer than the .call(...) API.

Thanks for creating & maintaining this library!

danielfm commented 8 months ago

Sure, as long as we don't break compatibility with current features!

Also, if the README is updated to cover the improvements, that's even better.

martijnthe commented 8 months ago

Sure, as long as we don't break compatibility with current features!

Also, if the README is updated to cover the improvements, that's even better.

OK, great.

I took a stab at it here: https://github.com/danielfm/pybreaker/pull/87