mokr.waiters.event
Classes
Class to wait for an event to be emitted and then run a callback |
Module Contents
- class mokr.waiters.event.EventWaiter(emitter: pyee.EventEmitter, event_name: str, predicate: Callable, timeout: float, loop: asyncio.AbstractEventLoop)
Class to wait for an event to be emitted and then run a callback
predicatewhen it is. If the callback resolves to a truthy value, the timer is cancelled. Otherwise, amokr.exceptions.MokrTimeoutErroris raised.- Parameters:
emitter (EventEmitter) – Emitter to listen to.
event_name (str) – Event name to listen for.
predicate (Callable) – Callback to run when event is emitted.
timeout (float) – Time in milliseconds to wait for event.
loop (asyncio.AbstractEventLoop) – Running asyncio loop.
- listener = None
- promise
- wait() Awaitable
Wait for the target event to be emitted and then run the target predicate when it is. If that resolves to a truthy value, cancel the timer, otherwise, raise a
mokr.exceptions.MokrTimeoutErrorexception.- Returns:
Awaitable that yields result of the target callback.
- Return type:
Awaitable