Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kafka/consumer/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ def set_topic_partitions(self, *topics):
# Reset message iterator in case we were in the middle of one
self._reset_message_iterator()

def close(self):
"""Close this consumer's underlying client."""
self._client.close()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything else we would need to reset on close()? Not sure, but perhaps partition offset?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it, close is meant to be a way to deallocate IO resources associated with a consumer. You can't re-open a consumer once it's closed, so I don't think it's necessary to worry about the internal state of a closed consumer, only resources the consumer is leaking/holding onto.

Edit: offsets are stored in OffsetsStruct, which is just a named tuple of ints. Nothing to close/deallocate in there.

def next(self):
"""Return the next available message

Expand Down