Skip to content

Commit 3bf75c5

Browse files
committed
only make a metadata event if we don't know the partitions
1 parent 3d80a79 commit 3bf75c5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kafka/producer/kafka.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -443,12 +443,15 @@ def _wait_on_metadata(self, topic, max_wait):
443443
self._sender.add_topic(topic)
444444
begin = time.time()
445445
elapsed = 0.0
446-
metadata_event = threading.Event()
446+
metadata_event = None
447447
while True:
448448
partitions = self._metadata.partitions_for_topic(topic)
449449
if partitions is not None:
450450
return partitions
451451

452+
if not metadata_event:
453+
metadata_event = threading.Event()
454+
452455
log.debug("Requesting metadata update for topic %s", topic)
453456

454457
metadata_event.clear()

0 commit comments

Comments
 (0)