def load_metadata_for_topics(self, *topics):
topics = [kafka_bytestring(t) for t in topics]<EOL>if topics:<EOL><INDENT>for topic in topics:<EOL><INDENT>self.reset_topic_metadata(topic)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.reset_all_metadata()<EOL><DEDENT>resp = self.send_metadata_request(topics)<EOL>log.debug('<STR_LIT>', resp.brokers)<EOL>log.debug('<STR_LIT>', resp.topics)<EOL>self.brokers = dict([(broker.nodeId, broker)<EOL>for broker in resp.brokers])<EOL>for topic_metadata in resp.topics:<EOL><INDENT>topic = topic_metadata.topic<EOL>partitions = topic_metadata.partitions<EOL>try:<EOL><INDENT>kafka_common.check_error(topic_metadata)<EOL><DEDENT>except (UnknownTopicOrPartitionError, LeaderNotAvailableError) as e:<EOL><INDENT>if topic in topics:<EOL><INDENT>raise<EOL><DEDENT>log.error('<STR_LIT>', topic, type(e))<EOL>continue<EOL><DEDENT>self.topic_partitions[topic] = {}<EOL>for partition_metadata in partitions:<EOL><INDENT>partition = partition_metadata.partition<EOL>leader = partition_metadata.leader<EOL>self.topic_partitions[topic][partition] = partition_metadata<EOL>topic_part = TopicAndPartition(topic, partition)<EOL>try:<EOL><INDENT>kafka_common.check_error(partition_metadata)<EOL><DEDENT>except LeaderNotAvailableError:<EOL><INDENT>log.error('<STR_LIT>', topic, partition)<EOL>self.topics_to_brokers[topic_part] = None<EOL>continue<EOL><DEDENT>except ReplicaNotAvailableError:<EOL><INDENT>log.debug('<STR_LIT>',<EOL>topic, partition)<EOL><DEDENT>if leader in self.brokers:<EOL><INDENT>self.topics_to_brokers[topic_part] = self.brokers[leader]<EOL><DEDENT>else:<EOL><INDENT>self.topics_to_brokers[topic_part] = BrokerMetadata(<EOL>leader, None, None<EOL>)<EOL><DEDENT><DEDENT><DEDENT>
Fetch broker and topic-partition metadata from the server,
and update internal data:
broker list, topic/partition list, and topic/parition -> broker map

This method should be called after receiving any error

Arguments:
    *topics (optional): If a list of topics is provided,
        the metadata refresh will be limited to the specified topics only.

Exceptions:
----------
If the broker is configured to not auto-create topics,
expect UnknownTopicOrPartitionError for topics that don't exist

If the broker is configured to auto-create topics,
expect LeaderNotAvailableError for new topics
until partitions have been initialized.

Exceptions *will not* be raised in a full refresh (i.e. no topic list)
In this case, error codes will be logged as errors

Partition-level errors will also not be raised here
(a single partition w/o a leader, for example)