§
    §	Êj£  ã                   ó„   — d dl mZ d dlmZmZmZmZmZmZ d dl	m
Z
mZ d dlmZ d dlmZmZ eZdgZ G d„ de¦  «        ZdS )	é    )Úiscoroutine)ÚAnyÚCallableÚcastÚDictÚOptionalÚTuple)ÚDeferredÚensureDeferred)ÚFailure)ÚEventEmitterÚ	PyeeErrorÚTwistedEventEmitterc            
       ó„   ‡ — e Zd ZdZdeddfˆ fd„Zdededeedf         d	e	e
ef         ddf
d
„Zdede
deddfˆ fd„Zˆ xZS )r   a¨  An event emitter class which can run twisted coroutines and handle
    returned Deferreds, in addition to synchronous blocking functions. For
    example:

    ```py
    @ee.on('event')
    @inlineCallbacks
    def async_handler(*args, **kwargs):
        yield returns_a_deferred()
    ```

    or:

    ```py
    @ee.on('event')
    async def async_handler(*args, **kwargs):
        await returns_a_deferred()
    ```


    When async handlers fail, Failures are first emitted on the `failure`
    event. If there are no `failure` handlers, the Failure's associated
    exception is then emitted on the `error` event. If there are no `error`
    handlers, the exception is raised. For consistency, when handlers raise
    errors synchronously, they're captured, wrapped in a Failure and treated
    as an async failure. This is unlike the behavior of EventEmitter,
    which have no special error handling.

    For twisted 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.

    Similar behavior occurs for "sync" functions which return Deferreds.
    ÚselfÚreturnNc                 óV   •— t          t          | ¦  «                             ¦   «          d S )N)Úsuperr   Ú__init__)r   Ú	__class__s    €ú<C:\Projects\Muse2API\.venv\Lib\site-packages\pyee/twisted.pyr   zTwistedEventEmitter.__init__5   s&   ø€ ÝÕ! 4Ñ(Ô(×1Ò1Ñ3Ô3Ð3Ð3Ð3ó    ÚfÚargs.Úkwargsc                 óB  ‡ — d }	  ||i |¤Ž}t          |¦  «        rt          |¦  «        }nt          |t          ¦  «        r|}n|sd S dt          dd fˆ fd„}|                     |¦  «         d S # t          $ r& ‰                      dt	          ¦   «         ¦  «         Y d S w xY w)NÚfailurer   c                 ó<   •— | r‰                      d| ¦  «         d S d S )Nr   )Úemit)r   r   s    €r   Úerrbackz.TwistedEventEmitter._emit_run.<locals>.errbackK   s/   ø€ Øð 2Ø—I’I˜i¨Ñ1Ô1Ð1Ð1Ð1ð2ð 2r   )r   r   Ú
isinstancer
   r   Ú
addErrbackÚ	Exceptionr   )r   r   r   r   ÚdÚresultr    s   `      r   Ú	_emit_runzTwistedEventEmitter._emit_run8   sî   ø€ ð &*ˆð	"Ø�Q˜Ð' Ð'Ð'ˆFõ ˜6Ñ"Ô"ð Ý" 6Ñ*Ô*��Ý˜F¥HÑ-Ô-ð Ø��Øð Ø�ð2¥ð 2¨Tð 2ð 2ð 2ð 2ð 2ð 2ð �LŠL˜Ñ!Ô!Ð!Ð!Ð!øõ ð 	,ð 	,ð 	,Ø�IŠI�i¥¡¤Ñ+Ô+Ð+Ð+Ð+Ð+ð	,øøøs   …A. Á.,BÂBÚeventÚerrorc                 óê  •— |dk    r¯t          |t          ¦  «        rE	 |                     ¦   «          d S # t          $ r!}|                      d|¦  «         Y d }~d S d }~ww xY wt          |t          ¦  «        r|                      d|¦  «         d S |                      dt          d|› �¦  «        ¦  «         d S t          t          t          t          | ¦  «        ¦  «         
                    ||¦  «         d S )Nr   r(   zUnexpected failure object: )r!   r   ÚraiseExceptionr#   r   r   r   r   r   r   Ú_emit_handle_potential_error)r   r'   r(   Úexcr   s       €r   r+   z0TwistedEventEmitter._emit_handle_potential_errorQ   s  ø€ Ø�IÒÐÝ˜%¥Ñ)Ô)ð Uð,Ø×(Ò(Ñ*Ô*Ð*Ð*Ð*øÝ ð ,ð ,ð ,Ø—I’I˜g sÑ+Ô+Ð+Ð+Ð+Ð+Ð+Ð+Ð+øøøøð,øøøå˜E¥9Ñ-Ô-ð UØ—	’	˜' 5Ñ)Ô)Ð)Ð)Ð)à—	’	˜'¥9Ð-RÈ5Ð-RÐ-RÑ#SÔ#SÑTÔTÐTÐTÐTå••eÕ/°Ñ6Ô6Ñ7Ô7×TÒTØ�uñô ð ð ð s   ž4 ´
A¾AÁA)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚSelfr   r   r	   r   r   Ústrr&   r+   Ú__classcell__)r   s   @r   r   r      sâ   ø€ € € € € ð!ð !ðF4�tð 4 ð 4ð 4ð 4ð 4ð 4ð 4ð"Øð"àð"ð �C˜�HŒoð"ð �S˜#�X”ð	"ð
 
ð"ð "ð "ð "ð2¨4ð ¸ð ÀCð ÈDð ð ð ð ð ð ð ð ð ð r   N)Úasyncior   Útypingr   r   r   r   r   r	   Útwisted.internet.deferr
   r   Útwisted.python.failurer   Ú	pyee.baser   r   r1   Ú__all__r   © r   r   ú<module>r;      sØ   ðð  Ð Ð Ð Ð Ð Ø =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =à ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø *Ð *Ð *Ð *Ð *Ð *à -Ð -Ð -Ð -Ð -Ð -Ð -Ð -à
€ð !Ð
!€ðNð Nð Nð Nð N˜,ñ Nô Nð Nð Nð Nr   