Closed gst closed 5 years ago
I answer to myself :
given a circuit breaker is associated with a thread lock and that the lock is taken whenever a call is done on/with the circuit breaker then yes it's safe to use the same breaker instance with multiple threads, concurrently running.
But then any combination of threads using the same circuit will be limited by this : only one "call" at a time will be processed given this lock.
But what if we don't want this behavior but still want to use/share the same breaker between multiple threads ?
I'm thinking : there could simply be a lock-less version of the circuit breaker.. which could be the "base" one, and the lock version of the circuit breaker would simply subclass the lock-less version and add the lock and use it..
wdyt?
Yes, I think that's a great idea!
On Mon, Jul 20, 2015, 10:58 AM Grégory Starck notifications@github.com wrote:
I answer to myself :
given a circuit breaker is associated with a thread lock and that the lock is taken whenever a call is done on/with the circuit breaker then yes it's safe to use the same breaker instance with multiple threads, concurrently running.
But then any combination of threads using the same circuit will be limited by this : only one "call" at a time will be processed given this lock.
But what if we don't want this behavior but still want to use/share the same breaker between multiple threads ?
I'm thinking : there could simply be a lock-less version of the circuit breaker.. which could be the "base" one, and the lock version of the circuit breaker would simply subclass the lock-less version and add the lock and use it..
wdyt?
— Reply to this email directly or view it on GitHub https://github.com/danielfm/pybreaker/issues/3#issuecomment-122893931.
I've think again about it : probably the lock should still be more than necessary (for the circuit breaker failure count), but it's not necessary to have it locked while you actually call/execute the "wrapped" function..
the next step would be to propose a PR I guess ;)
That would be nice! :smile:
@gst @danielfm did this get any further?
not on my side sorry. not anymore user of pybreaker.
Hi,
not an issue but a question:
is it safe to use the same breaker instance (CircuitBreaker) by multiple threads, possibly concurrently (modulo GIL ofcourse) ?
thx for the lib :)