Skip to content

Commit

Permalink
Merge pull request #389 from dpkp/task_done_key_error
Browse files Browse the repository at this point in the history
KafkaConsumer.task_done: warn and skip unrecognized topic-partitions
  • Loading branch information
dpkp committed Jun 9, 2015
2 parents 00c6b86 + 82aae4f commit 3d4d98e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions kafka/consumer/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,16 @@ def task_done(self, message):
message (KafkaMessage): the message to mark as complete
Returns:
Nothing
True, unless the topic-partition for this message has not
been configured for the consumer. In normal operation, this
should not happen. But see github issue 364.
"""
topic_partition = (message.topic, message.partition)
if topic_partition not in self._topics:
logger.warning('Unrecognized topic/partition in task_done message: '
'{0}:{1}'.format(*topic_partition))
return False

offset = message.offset

# Warn on non-contiguous offsets
Expand All @@ -476,6 +482,8 @@ def task_done(self, message):
if self._should_auto_commit():
self.commit()

return True

def commit(self):
"""Store consumed message offsets (marked via task_done())
to kafka cluster for this consumer_group.
Expand Down

0 comments on commit 3d4d98e

Please sign in to comment.