diff options
author | Dana Powers <dana.powers@gmail.com> | 2015-06-08 18:20:53 -0700 |
---|---|---|
committer | Dana Powers <dana.powers@gmail.com> | 2015-06-08 18:20:53 -0700 |
commit | 3d4d98ed78414af0c4330f056a3ae6bcf79ed11c (patch) | |
tree | 05829b2d8aaa974b31eba32965d77b0c4e8f3d3e | |
parent | 00c6b8635bca62e4facca105d33fdd250a2d5eb4 (diff) | |
parent | 82aae4f00a94ebf5d2c34be5cc24e50fc3e16701 (diff) | |
download | kafka-python-3d4d98ed78414af0c4330f056a3ae6bcf79ed11c.tar.gz |
Merge pull request #389 from dpkp/task_done_key_error
KafkaConsumer.task_done: warn and skip unrecognized topic-partitions
-rw-r--r-- | kafka/consumer/kafka.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/kafka/consumer/kafka.py b/kafka/consumer/kafka.py index 60f1a0b..7ba83cb 100644 --- a/kafka/consumer/kafka.py +++ b/kafka/consumer/kafka.py @@ -448,10 +448,16 @@ class KafkaConsumer(object): 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 @@ -476,6 +482,8 @@ class KafkaConsumer(object): 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. |