code: def get_http_rtt(
          url: str,
          samples: int = 3,
          method: str = 'head',
          timeout: int = 1,
  ) -> Optional[float]:
      
      durations = []
      for _ in range(samples):
          try:
              durations.append(
                  requests.request(method, url, timeout=timeout).elapsed.total_seconds(),
              )
          except (RequestException, OSError):
              return None
          except Exception as ex:
              print(ex)
              return None
          # Slight delay to avoid overloading
          sleep(.125)
      return sum(durations) / samples
docs: Determine the average HTTP RTT to `url` over the number of `samples`.
      Returns `None` if the server is unreachable.