def _WaitForCondition(condition_callback, timeout=None):
  """Waits until the specified callback returns a value that evaluates True.

  Similar to the threading.Condition.wait method that is the basis of most
  threading class wait routines. Polls the condition, starting with frequent
  checks but extending the delay between checks upon each failure.

  Args:
    condition_callback: Callable that returns a value that evaluates True to end
        the wait or evaluates False to continue the wait.
    timeout: Optional float. Number of seconds to wait before giving up. If
        provided, the condition is still checked at least once before giving up.
        If not provided, the wait does not time out.

  Returns:
    True if condition_callback returned a value that evaluated True. False if
    condition_callback did not return a value that evaluated True before the
    timeout.
  """
  deadline = None if timeout is None else time.time() + timeout
  delay = _WAIT_MIN_RECHECK_DELAY
  while True:
    if condition_callback():
      return True
    remaining_time = (_WAIT_MAX_RECHECK_DELAY if deadline is None
                      else time.time() - deadline)
    if remaining_time <= 0:
      return False
    time.sleep(delay)
    delay = min(delay * 2, remaining_time, _WAIT_MAX_RECHECK_DELAY)
dataset/ETHPy150Open GoogleCloudPlatform/PerfKitBenchmarker/perfkitbenchmarker/background_tasks.py/_WaitForCondition/swapped operands of `-`