def select_best_url(self):
    """Select `best` url.

    Since urls are pre-sorted w.r.t. their ping times, we simply return the first element
    from the list. And we always return the same url unless we observe greater than max
    allowed number of consecutive failures. In this case, we would return the next `best`
    url, and append the previous best one to the end of list (essentially rotate to the left
    by one element).
    """

    best_url = self.parsed_urls[0]
    try:
      yield best_url
    except Exception:
      self.unsuccessful_calls[best_url] += 1

      # Not thread-safe but pool used by cache is based on subprocesses, therefore no race.
      if self.unsuccessful_calls[best_url] > self.max_failures:
        self.parsed_urls.rotate(-1)
        self.unsuccessful_calls[best_url] = 0
      raise
    else:
      self.unsuccessful_calls[best_url] = 0
Select `best` url.

    Since urls are pre-sorted w.r.t. their ping times, we simply return the first element
    from the list. And we always return the same url unless we observe greater than max
    allowed number of consecutive failures. In this case, we would return the next `best`
    url, and append the previous best one to the end of list (essentially rotate to the left
    by one element).