§
    ÎAÄj»  ã                   óš   — d dl 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 	 d dlmZ n# e$ r dZY nw xY wdgZ G d„ de¦  «        ZdS )	é    )ÚAnyÚCallableÚDictÚOptionalÚTuple)ÚDeferredÚensureDeferred)ÚFailure)ÚEventEmitterÚPyeeException)ÚiscoroutineNÚTwistedEventEmitterc                   ór   ‡ — e Zd ZdZˆ fd„Zdedeedf         dee	ef         ddfd	„Z
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.
    c                 óV   •— t          t          | ¦  «                             ¦   «          d S )N)Úsuperr   Ú__init__)ÚselfÚ	__class__s    €úPC:\Projects\Historical\FacebookAutoPoster\venv\Lib\site-packages\pyee/twisted.pyr   zTwistedEventEmitter.__init__7   s&   ø€ ÝÕ! 4Ñ(Ô(×1Ò1Ñ3Ô3Ð3Ð3Ð3ó    ÚfÚargs.ÚkwargsÚreturnNc                 óP  ‡ — d }	  ||i |¤Ž}t           r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>.errbackM   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_run:   sõ   ø€ ð &*ˆð	"Ø�Q˜Ð' Ð'Ð'ˆFõ ð �{¨6Ñ2Ô2ð Ý" 6Ñ*Ô*��Ý˜F¥HÑ-Ô-ð Ø��Øð Ø�ð2¥ð 2¨Tð 2ð 2ð 2ð 2ð 2ð 2ð �LŠL˜Ñ!Ô!Ð!Ð!Ð!øõ ð 	,ð 	,ð 	,Ø�IŠI�i¥¡¤Ñ+Ô+Ð+Ð+Ð+Ð+ð	,øøøs   …A5 Á5,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          | ¦  «                             ||¦  «         d S )Nr   r'   zUnexpected failure object: )	r    r
   ÚraiseExceptionr"   r   r   r   r   Ú_emit_handle_potential_error)r   r&   r'   Úexcr   s       €r   r*   z0TwistedEventEmitter._emit_handle_potential_errorS   s  ø€ Ø�IÒÐÝ˜%¥Ñ)Ô)ð Yð,Ø×(Ò(Ñ*Ô*Ð*Ð*Ð*øÝ ð ,ð ,ð ,Ø—I’I˜g sÑ+Ô+Ð+Ð+Ð+Ð+Ð+Ð+Ð+øøøøð,øøøå˜E¥9Ñ-Ô-ð YØ—	’	˜' 5Ñ)Ô)Ð)Ð)Ð)à—	’	˜'¥=Ð1VÈuÐ1VÐ1VÑ#WÔ#WÑXÔXÐXÐXÐXåÕ&¨Ñ-Ô-×KÒKØ�uñô ð ð ð s   ž4 ´
A¾AÁA)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   Ústrr%   r*   Ú__classcell__)r   s   @r   r   r      sÀ   ø€ € € € € ð!ð !ðF4ð 4ð 4ð 4ð 4ð"àð"ð �C˜�HŒoð"ð �S˜#�X”ð	"ð
 
ð"ð "ð "ð "ð2°#ð ¸cð Àdð ð ð ð ð ð ð ð ð ð r   )Útypingr   r   r   r   r   Útwisted.internet.deferr   r	   Útwisted.python.failurer
   Ú	pyee.baser   r   Úasyncior   ÚImportErrorÚ__all__r   © r   r   ú<module>r:      sù   ðð 8Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7à ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø *Ð *Ð *Ð *Ð *Ð *à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1ðØ#Ð#Ð#Ð#Ð#Ð#Ð#øØð ð ð Ø€K€K€Kðøøøð !Ð
!€ðNð Nð Nð Nð N˜,ñ Nô Nð Nð Nð Ns   ¦- ­7¶7