Repository navigation
Conversation
Channel.close() now calls the superclass close first, then stops and closes the Kazoo client and clears self._client. Nested try/finally still closes the client if stop() fails, and the handle is only cleared after close() succeeds so a later close can retry. Close does not create a client if none exists, and a second successful close does not stop it again. Fixes celery#2830
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2846 +/- ##
==========================================
+ Coverage 85.77% 85.78% +0.01%
==========================================
Files 80 80
Lines 11595 11604 +9
Branches 1403 1404 +1
==========================================
+ Hits 9946 9955 +9
Misses 1428 1428
Partials 221 221 ☔ View full report in Codecov by Harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Closing a ZooKeeper channel or connection leaves the Kazoo client running, so ZooKeeper sessions and background threads keep going after the caller has already shut the channel down. A later close of the same channel also does not clean that leftover client up.
Channel never overrode close(), so the lazily created Kazoo client was never stopped or closed. Superclass close() still restored unacked messages, but self._client stayed alive.
What this changes
Channel.close() now calls the superclass close first, then stops and closes the Kazoo client and clears self._client. Nested try/finally still closes the client if stop() fails, and the handle is only cleared after close() succeeds so a later close can retry. Close does not create a client if none exists, and a second successful close does not stop it again.
Reproduction
Fixes #2830