wait

BetterEvent.wait(timeout: Optional[Union[int, float]] = None, fail=False)bool[source]

Multi-purpose wait method which works similarly to threading.Event.wait() but with some extra features.

This method’s behaviour will vary depending on what the wait_on setting is set to:

  • 'set' - the default - works like threading.Event, wait() only triggers when the event is in the “set” state, i.e. _flag is True

  • 'clear' - opposite of the default - works opposite to threading.Event, wait() only triggers when the event is in the “clear” state, i.e. _flag is False

  • 'both' - In the both setting, wait() will simply wait until _flag is changed, whether from set to clear, or clear to set. This wait_on setting only works as long as notify_set and notify_clear are set to True

Parameters
  • fail (bool) – If True, raise EventWaitTimeout if timeout was reached while waiting for the event to change.

  • timeout (float) – Maximum amount of time to wait before giving up (None to disable timeout)

Return bool signal

This method returns the internal flag on exit, so it will always return True except if a timeout is given and the operation times out.