def loop_until_timeout_or_true(timeout_s, function, sleep_s=1):  # pylint: disable=invalid-name
  """Loops until the specified function returns True or a timeout is reached.

  Note: The function may return anything which evaluates to implicit True.  This
  function will loop calling it as long as it continues to return something
  which evaluates to False.  We ensure this method is called at least once
  regardless of timeout.

  Args:
    timeout_s: The number of seconds to wait until a timeout condition is
        reached. As a convenience, this accepts None to mean never timeout.  Can
        also be passed a PolledTimeout object instead of an integer.
    function: The function to call each iteration.
    sleep_s: The number of seconds to wait after calling the function.

  Returns:
    Whatever the function returned last.
  """
  return loop_until_timeout_or_valid(timeout_s, function, lambda x: x, sleep_s)