code: def wait_for_response(client, timeout, path='/', expected_status_code=None):
      
      # We want time.monotonic on Pythons that have it, otherwise time.time will
      # have to do.
      get_time = getattr(time, 'monotonic', time.time)
  
      deadline = get_time() + timeout
      while True:
          try:
              # Don't care what the response is, as long as we get one
              time_left = deadline - get_time()
              response = client.get(
                  path, timeout=max(time_left, 0.001), allow_redirects=False)
  
              if (expected_status_code is None
                      or response.status_code == expected_status_code):
                  return
          except requests.exceptions.Timeout:
              # Requests timed out, our time must be up
              break
          except Exception:
              # Ignore other exceptions
              pass
  
          if get_time() >= deadline:
              break
          time.sleep(0.1)
  
      raise TimeoutError('Timeout waiting for HTTP response.')
docs: Try make a GET request with an HTTP client against a certain path and
      return once any response has been received, ignoring any errors.
  
      :param ContainerHttpClient client:
          The HTTP client to use to connect to the container.
      :param timeout:
          Timeout value in seconds.
      :param path:
          HTTP path to request.
      :param int expected_status_code:
          If set, wait until a response with this status code is received. If not
          set, the status code will not be checked.
      :raises TimeoutError:
          If a request fails to be made within the timeout period.