code: def _get_peer_connection(self, blacklist=None):
          
  
          blacklist = blacklist or set()
  
          peer = None
          connection = None
  
          while connection is None:
              peer = self._choose(blacklist)
  
              if not peer:
                  raise NoAvailablePeerError(
                      "Can't find an available peer for '%s'" % self.service
                  )
  
              try:
                  connection = yield peer.connect()
              except NetworkError as e:
                  log.info(
                      'Failed to connect to %s. Trying a different host.',
                      peer.hostport,
                      exc_info=e,
                  )
                  connection = None
                  blacklist.add(peer.hostport)
  
          raise gen.Return((peer, connection))
docs: Find a peer and connect to it.
  
          Returns a ``(peer, connection)`` tuple.
  
          Raises ``NoAvailablePeerError`` if no healthy peers are found.
  
          :param blacklist:
              If given, a set of hostports for peers that we must not try.