Ë
    v¹1h£  ã                   ó|   — 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y)	é    )Úiscoroutine)ÚAnyÚCallableÚcastÚDictÚOptionalÚTuple)ÚDeferredÚensureDeferred)ÚFailure)ÚEventEmitterÚ	PyeeErrorÚTwistedEventEmitterc            
       óx   ‡ — 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                 ó*   •— t         t        | �  «        y )N)Úsuperr   Ú__init__)r   Ú	__class__s    €úJ/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/pyee/twisted.pyr   zTwistedEventEmitter.__init__5   s   ø€ ÜÔ! 4Ñ1Õ3ó    ÚfÚargs.Úkwargsc                 ó  ‡ — d }	  ||i |¤Ž}t        |«      rt        |«      }nt        |t        «      r|}n|sy dt        dd fˆ fd„}|j                  |«       y # t        $ r ‰ j                  dt	        «       «       Y y w xY w)NÚfailurer   c                 ó0   •— | r‰j                  d| «       y y )Nr   )Úemit)r   r   s    €r   Úerrbackz.TwistedEventEmitter._emit_run.<locals>.errbackK   s   ø€ ÙØ—I‘I˜i¨Õ1ð r   )r   r   Ú
isinstancer
   r   Ú
addErrbackÚ	Exceptionr   )r   r   r   r   ÚdÚresultr    s   `      r   Ú	_emit_runzTwistedEventEmitter._emit_run8   s‰   ø€ ð &*ˆð	"Ù˜Ð' Ñ'ˆFô ˜6Ô"Ü" 6Ó*‘Ü˜F¤HÔ-Ø‘ÙØð2¤ð 2¨Tõ 2ð �L‰L˜Õ!øô ò 	,Ø�I‰I�i¤£Ö+ð	,ús   …A Á#B Á?B ÚeventÚerrorc                 ó„  •— |dk(  rdt        |t        «      r	 |j                  «        y t        |t        «      r| j	                  d|«       y | j	                  dt        d|› �«      «       y t        t        t        t        | «      «      j                  ||«       y # t        $ r}| j	                  d|«       Y d }~y d }~ww xY w)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ÒÜ˜%¤Ô)ð,Ø×(Ñ(Õ*ô ˜E¤9Ô-Ø—	‘	˜' 5Õ)à—	‘	˜'¤9Ð/JÈ5È'Ð-RÓ#SÕTä””eÔ/°Ó6Ó7×TÑTØ�uõøô !ò ,Ø—I‘I˜g s×+Ñ+ûð,ús   ˜B Â	B?Â#B:Â:B?)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚSelfr   r   r	   r   r   Ústrr&   r+   Ú__classcell__)r   s   @r   r   r      s…   ø„ ñ!ðF4�tð 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;      s6   ðõ  ß =× =ç ;Ý *ç -à
€ð !Ð
!€ôN˜,õ Nr   