def wait(self, timeout):
    """Waits for the condition for at most the given timeout and returns True if the condition triggered.

    Generally called in a loop until the condition triggers.
    """

    with self._condition:
      previous_iteration = self._iteration
      self._condition.wait(timeout)
      return previous_iteration != self._iteration
Waits for the condition for at most the given timeout and returns True if the condition triggered.

    Generally called in a loop until the condition triggers.