libgs.utils.wait_loop¶
-
libgs.utils.
wait_loop
(events_or_callables=[], timeout=None, dt=0.1)[source]¶ Generic waiting loop. It will wait for any event (of type threading.Event) to be set, or for any callable to return True
Example:
>>> ev = wait_loop([fn, event], timeout=10) >>> if ev is None: >>> print("Timeout") >>> elif fn in ev: >>> print("fn callable returned true) >>> elif event in ev: >>> print("threading event became true)
Parameters: - events_or_callables (list(callable or threading.Event)) – A list of events or callables to monitor. If any return true the wait loop will be broken
- timeout (int) – Maximum number of seconds to wait until breaking regardless
- dt (float) – The internal sleep interval between checking events (default = 0.1 sec)
Returns: A list of the events that have returned true. In case of timeout returns None. An exception will be raised if the global abort_event has been set.