-
Notifications
You must be signed in to change notification settings - Fork 387
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
fix(handlers): make AsyncResult call all registered callbacks instantly if the handler has stopped running #549
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank a lot for this PR that I would like to merge.
Do you think it is possible to easily implement a test for this behaviour?
@@ -122,6 +113,18 @@ def unlink(self, callback): | |||
if callback in self._callbacks: | |||
self._callbacks.remove(callback) | |||
|
|||
def _do_callbacks(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a little description to this method? Just to help make the read straightforward for any newcomer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I'll add one. I'll also look into adding a test for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. It's some simple test but it showcases what was happening in my case. It's more complicated to do a functional test that can actually reproduce the situation when a response is received just after stop was called, But this test will fail without my changes and pass with them.
…ly if the handler has stoppped running
eb1ef5d
to
c244320
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the new commit, I am going to merge this.
Merged to master. |
Hi!
I'm using kazoo in a work-related project and sometimes our tests are leaving zombie threads that are blocked in
self._condition.wait(timeout)
fromAsyncResult:get
.After some digging it looks like the problem occurs when we start a KazooClient, try to make an operation on it like a path creation and then stop it fast. In this case, the callbacks of the
AsyncResult
may not be called ifAsyncResult:set
/AsyncResult:set_exception
are called just after the client is stopped. As I said it might not happen too often for most people but for us it's like in 10% of the test runs and it's slows down our development pipeline. I've made a customAyncResult
class in our project that modifies a bit the behavior and seems to fix the issue for us but maybe you guys would also consider this solution for the official version.If you have other suggestions or concerns let me know.