mokr.waiters.event ================== .. py:module:: mokr.waiters.event Classes ------- .. autoapisummary:: mokr.waiters.event.EventWaiter Module Contents --------------- .. py:class:: 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 `predicate` when it is. If the callback resolves to a truthy value, the timer is cancelled. Otherwise, a `mokr.exceptions.MokrTimeoutError` is raised. :param emitter: Emitter to listen to. :type emitter: EventEmitter :param event_name: Event name to listen for. :type event_name: str :param predicate: Callback to run when event is emitted. :type predicate: Callable :param timeout: Time in milliseconds to wait for event. :type timeout: float :param loop: Running asyncio loop. :type loop: asyncio.AbstractEventLoop .. py:attribute:: listener :value: None .. py:attribute:: promise .. py:method:: 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.MokrTimeoutError` exception. :returns: Awaitable that yields result of the target callback. :rtype: Awaitable