WaitEvent#
- class wattson.util.events.wait_event.WaitEvent(timeout: float = 0, event: Event | None = None)#
Bases:
Event
Triggers the internal event after the given timeout (in seconds). Allows to manually set, wait and check the internal event.
Methods
Cancels the waiting immediately which does NOT fire the internal event
Reset the internal flag to false.
Cancels the waiting immediately and fires the internal event.
Return true if and only if the internal flag is true.
is_waiting
Set the internal flag to true.
Starts the timer.
timed_out
Block until the internal flag is true.
- __init__(timeout: float = 0, event: Event | None = None)#
- cancel()#
Cancels the waiting immediately which does NOT fire the internal event
- clear()#
Reset the internal flag to false.
Subsequently, threads calling wait() will block until set() is called to set the internal flag to true again.
- complete()#
Cancels the waiting immediately and fires the internal event.
- is_set()#
Return true if and only if the internal flag is true.
- set()#
Set the internal flag to true.
All threads waiting for it to become true are awakened. Threads that call wait() once the flag is true will not block at all.
- start(timeout: float | None = None)#
Starts the timer.
- Parameters:
timeout (Optional[float], optional) – Optionally overrides the initially given timeout (Default value = None)
- wait(timeout: float | None = None) bool #
Block until the internal flag is true.
If the internal flag is true on entry, return immediately. Otherwise, block until another thread calls set() to set the flag to true, or until the optional timeout occurs.
When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof).
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.