Skip to content

Update consumer.py #142

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

Closed
wants to merge 3 commits into from
Closed
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
23 changes: 12 additions & 11 deletions kafka/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,18 @@ def get_or_init_offset_callback(resp):
"partition=%d failed with errorcode=%s" % (
resp.topic, resp.partition, resp.error))

# Uncomment for 0.8.1
#
#for partition in partitions:
# req = OffsetFetchRequest(topic, partition)
# (offset,) = self.client.send_offset_fetch_request(group, [req],
# callback=get_or_init_offset_callback,
# fail_on_error=False)
# self.offsets[partition] = offset

for partition in partitions:
self.offsets[partition] = 0
# TODO add in check for testing which version kafka from the broker

try:
for partition in partitions:
req = OffsetFetchRequest(topic, partition)
(offset,) = self.client.send_offset_fetch_request(group, [req],
callback=get_or_init_offset_callback,
fail_on_error=False)
self.offsets[partition] = offset
except:
for partition in partitions:
self.offsets[partition] = 0

def commit(self, partitions=None):
"""
Expand Down