From 082cda6a7235df15d38102556f7bfe09e43b39fa Mon Sep 17 00:00:00 2001 From: Dana Powers Date: Mon, 2 Mar 2015 09:34:06 -0800 Subject: [PATCH] Avoid topic_partitions KeyError in KafkaClient --- kafka/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kafka/client.py b/kafka/client.py index 3c2a727..53b6ad0 100644 --- a/kafka/client.py +++ b/kafka/client.py @@ -86,7 +86,7 @@ class KafkaClient(object): self.load_metadata_for_topics(topic) # If the partition doesn't actually exist, raise - if partition not in self.topic_partitions[topic]: + if partition not in self.topic_partitions.get(topic, []): raise UnknownTopicOrPartitionError(key) # If there's no leader for the partition, raise