rhxddlmZmZmZmZmZddlmZmZm Z m Z m Z m Z m Z ddlmZeZdgZGddeZdS))AbstractEventLoop ensure_futureFuture iscoroutinewait)AnyCallablecastDictOptionalSetTuple) EventEmitterAsyncIOEventEmitterc eZdZdZddedeeddffd Zdedede d e de f fd Z ded e de e d fd eee fddf d ZdeddfdZdeddfdZedede fdZxZS)ra(An event emitter class which can run asyncio coroutines in addition to synchronous blocking functions. For example: ```py @ee.on('event') async def async_handler(*args, **kwargs): await returns_a_future() ``` On emit, the event emitter will automatically schedule the coroutine using `asyncio.ensure_future` and the configured event loop (defaults to `asyncio.get_event_loop()`). Unlike the case with the EventEmitter, all exceptions raised by event handlers are automatically emitted on the `error` event. This is important for asyncio coroutines specifically but is also handled for synchronous functions for consistency. When `loop` is specified, the supplied event loop will be used when scheduling work with `ensure_future`. Otherwise, the default asyncio event loop is used. For asyncio coroutine event handlers, calling emit is non-blocking. In other words, you do not have to await any results from emit, and the coroutine is scheduled in a fire-and-forget fashion. Nselfloopreturnctt|||_t |_dSN)superr__init___loopset_waiting)rr __class__s X/var/lib/jenkins/jobs/Dev/workspace/my-venv/lib/python3.11/site-packages/pyee/asyncio.pyrzAsyncIOEventEmitter.__init__)s6 !4((1133326 %(UU eventargskwargsc>tj|g|Ri|S)aEmit `event`, passing `*args` and `**kwargs` to each attached function or coroutine. Returns `True` if any functions are attached to `event`; otherwise returns `False`. Example: ```py ee.emit('data', '00101001') ``` Assuming `data` is an attached function, this will call `data('00101001')'`. When executing coroutine handlers, their respective futures will be stored in a "waiting" state. These futures may be waited on or canceled with `wait_for_complete` and `cancel`, respectively; and their status may be checked via the `complete` property. )remit)rrr r!rs rr#zAsyncIOEventEmitter.emit.s+0uww|E3D333F333rf.c ||i|}t|rTjr*ttt|j}nPttt|}n-t |t rtt|}ndSdt ddffd }||j |dS#t$r!} d|Yd}~dSd}~wwxYw)N)rr$rcj||rdS|}|rd|dSdS)Nerror)rdiscard cancelled exceptionr#)r$excrs rcallbackz/AsyncIOEventEmitter._emit_run..callbackasg %%a(((;;==F/0{{}},IIgs+++++,,rr') rrrr r isinstanceradd_done_callbackradd Exceptionr#)rr$r r!corofutr,r+s` r _emit_runzAsyncIOEventEmitter._emit_runHs:  #4*6**D4  :9 -T#t__4:NNNCC'S$88CCD&)) 3oo ,F ,t , , , , , ,  ! !( + + + M  c " " " " "9 $ $ $ IIgs # # # # # # # # # $sC D%DDcPK|jrt|jd{VdSdS)aWaits for all pending tasks to complete. For example: ```py @ee.on('event') async def async_handler(*args, **kwargs): await returns_a_future() # Triggers execution of async_handler ee.emit('data', '00101001') await ee.wait_for_complete() # async_handler has completed execution ``` This is useful if you're attempting a graceful shutdown of your application and want to ensure all coroutines have completed execution beforehand. N)rrrs rwait_for_completez%AsyncIOEventEmitter.wait_for_completensD( = &t}%% % % % % % % % % % & &rc|jD]>}|s(|s|?|jdS)aCancel all pending tasks. For example: ```py @ee.on('event') async def async_handler(*args, **kwargs): await returns_a_future() # Triggers execution of async_handler ee.emit('data', '00101001') ee.cancel() # async_handler execution has been canceled ``` This is useful if you're attempting to shut down your application and attempts at a graceful shutdown via `wait_for_complete` have failed. N)rdoner)cancelclear)rr2s rr9zAsyncIOEventEmitter.cancels\&=  C88:: cmmoo   rc|j S)aWhen true, there are no pending tasks, and execution is complete. For example: ```py @ee.on('event') async def async_handler(*args, **kwargs): await returns_a_future() # Triggers execution of async_handler ee.emit('data', '00101001') # async_handler is still running, so this prints False print(ee.complete) await ee.wait_for_complete() # async_handler has completed execution, so this prints True print(ee.complete) ``` )rr5s rcompletezAsyncIOEventEmitter.completes,=  rr)__name__ __module__ __qualname____doc__Selfr rrstrrboolr#r rr r3r6r9propertyr< __classcell__)rs@rrr sx6++t+8,=#>+$++++++ 4444 4  4444444$#$# $#CHo$#S#X $#  $#$#$#$#L&d&t&&&&.Td0!t!!!!X!!!!!rN)asynciorrrrrtypingrr r r r r r pyee.baserrA__all__rrrrKsPOOOOOOOOOOOOOBBBBBBBBBBBBBBBBBB""""""  !f!f!f!f!f!,f!f!f!f!f!r