From d5c9a11a574f06a1c9dd7ac4a98d0dc30452480c Mon Sep 17 00:00:00 2001 From: Dana Powers Date: Sun, 5 Apr 2015 19:38:18 -0700 Subject: clean local metadata before requesting refresh in load_metadata_for_topics() --- kafka/client.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'kafka/client.py') diff --git a/kafka/client.py b/kafka/client.py index a966f92..f01c1c5 100644 --- a/kafka/client.py +++ b/kafka/client.py @@ -311,6 +311,13 @@ class KafkaClient(object): (a single partition w/o a leader, for example) """ topics = [kafka_bytestring(t) for t in topics] + + if topics: + for topic in topics: + self.reset_topic_metadata(topic) + else: + self.reset_all_metadata() + resp = self.send_metadata_request(topics) log.debug("Broker metadata: %s", resp.brokers) @@ -323,8 +330,6 @@ class KafkaClient(object): topic = topic_metadata.topic partitions = topic_metadata.partitions - self.reset_topic_metadata(topic) - # Errors expected for new topics try: kafka.common.check_error(topic_metadata) -- cgit v1.2.1