Skip to content

Commit d5c9a11

Browse files
author
Dana Powers
committed
clean local metadata before requesting refresh in load_metadata_for_topics()
1 parent fbc242f commit d5c9a11

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

kafka/client.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,13 @@ def load_metadata_for_topics(self, *topics):
311311
(a single partition w/o a leader, for example)
312312
"""
313313
topics = [kafka_bytestring(t) for t in topics]
314+
315+
if topics:
316+
for topic in topics:
317+
self.reset_topic_metadata(topic)
318+
else:
319+
self.reset_all_metadata()
320+
314321
resp = self.send_metadata_request(topics)
315322

316323
log.debug("Broker metadata: %s", resp.brokers)
@@ -323,8 +330,6 @@ def load_metadata_for_topics(self, *topics):
323330
topic = topic_metadata.topic
324331
partitions = topic_metadata.partitions
325332

326-
self.reset_topic_metadata(topic)
327-
328333
# Errors expected for new topics
329334
try:
330335
kafka.common.check_error(topic_metadata)

0 commit comments

Comments
 (0)