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

fix(handlers): make AsyncResult call all registered callbacks instantly if the handler has stopped running #549

Merged
merged 2 commits into from
Jan 15, 2019

Conversation

laura-surcel
Copy link
Contributor

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) from AsyncResult: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 if AsyncResult: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 custom AyncResult 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.

@laura-surcel laura-surcel changed the title fix(handlers): make AsyncResult call all registered callbacks instantly if the handler has stoppped running fix(handlers): make AsyncResult call all registered callbacks instantly if the handler has stopped running Jan 7, 2019
Copy link
Member

@StephenSorriaux StephenSorriaux left a 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):
Copy link
Member

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.

Copy link
Contributor Author

@laura-surcel laura-surcel Jan 15, 2019

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.

Copy link
Contributor Author

@laura-surcel laura-surcel Jan 15, 2019

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.

Copy link
Member

@StephenSorriaux StephenSorriaux left a 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.

@StephenSorriaux StephenSorriaux merged commit d9e0e72 into python-zk:master Jan 15, 2019
@StephenSorriaux
Copy link
Member

Merged to master.

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 this pull request may close these issues.

2 participants