code: def _get_leader_for_partition(self, topic, partition):
          
  
          key = TopicAndPartition(topic, partition)
          # reload metadata whether the partition is not available
          # or has no leader (broker is None)
          if self.topics_to_brokers.get(key) is None:
              yield self.load_metadata_for_topics(topic)
  
          if key not in self.topics_to_brokers:
              raise PartitionUnavailableError("%s not available" % str(key))
  
          returnValue(self.topics_to_brokers[key])
docs: Returns the leader for a partition or None if the partition exists
          but has no leader.
  
          PartitionUnavailableError will be raised if the topic or partition
          is not part of the metadata.