§
    ÎAÄj’	  ã                   ót   — d dl mZmZmZ 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 dgZ G d„ de¦  «        ZdS )é    )ÚExecutorÚFutureÚThreadPoolExecutor)ÚTracebackType)ÚAnyÚCallableÚDictÚOptionalÚTupleÚType)ÚEventEmitterÚExecutorEventEmitterc            	       ó´   ‡ — e Zd ZdZddee         fˆ fd„Zdedee	df         de
ee	f         fd	„Zddeddfd„Zdd„Zdee         dededee         fd„Zˆ xZS )r   a  An event emitter class which runs handlers in a `concurrent.futures`
    executor.

    By default, this class creates a default `ThreadPoolExecutor`, but
    a custom executor may also be passed in explicitly to, for instance,
    use a `ProcessPoolExecutor` instead.

    This class runs all emitted events on the configured executor. Errors
    captured by the resulting Future are automatically emitted on the
    `error` event. This is unlike the EventEmitter, which have no error
    handling.

    The underlying executor may be shut down by calling the `shutdown`
    method. Alternately you can treat the event emitter as a context manager:

    ```py
    with ExecutorEventEmitter() as ee:
        # Underlying executor open

        @ee.on('data')
        def handler(data):
            print(data)

        ee.emit('event')

    # Underlying executor closed
    ```

    Since the function call is scheduled on an executor, emit is always
    non-blocking.

    No effort is made to ensure thread safety, beyond using an executor.
    NÚexecutorc                 ó’   •— t          t          | ¦  «                             ¦   «          |r	|| _        d S t	          ¦   «         | _        d S ©N)Úsuperr   Ú__init__Ú	_executorr   )Úselfr   Ú	__class__s     €úQC:\Projects\Historical\FacebookAutoPoster\venv\Lib\site-packages\pyee/executor.pyr   zExecutorEventEmitter.__init__/   sD   ø€ ÝÕ" DÑ)Ô)×2Ò2Ñ4Ô4Ð4Øð 	2Ø'/ˆDŒNˆNˆNå/Ñ1Ô1ˆDŒNˆNˆNó    ÚfÚargs.Úkwargsc                 ól   ‡ —  ‰ j         j        |g|¢R i |¤Ž}|j        dt          dd fˆ fd„¦   «         }d S )Nr   Úreturnc                 ó’   •— |                       ¦   «         }t          |t          ¦  «        r‰                     d|¦  «         d S |�|‚d S )NÚerror)Ú	exceptionÚ
isinstanceÚ	ExceptionÚemit)r   Úexcr   s     €r   Ú	_callbackz1ExecutorEventEmitter._emit_run.<locals>._callback>   sM   ø€ à+,¯;ª;©=¬=ˆCÝ˜#�yÑ)Ô)ð Ø—	’	˜' 3Ñ'Ô'Ð'Ð'Ð'Ø�Ø�	ð !�r   )r   ÚsubmitÚadd_done_callbackr   )r   r   r   r   Úfuturer&   s   `     r   Ú	_emit_runzExecutorEventEmitter._emit_run6   sm   ø€ ð /˜œÔ.¨qÐB°4ÐBÐBÐB¸6ÐBÐBˆà	Ô	!ð	�ð 	 Dð 	ð 	ð 	ð 	ð 	ñ 
"Ô	!ð	ð 	ð 	r   TÚwaitr   c                 ó<   — | j                              |¬¦  «         dS )z)Call `shutdown` on the internal executor.)r+   N)r   Úshutdown)r   r+   s     r   r-   zExecutorEventEmitter.shutdownF   s#   € ð 	Œ×Ò TÐÑ*Ô*Ð*Ð*Ð*r   c                 ó   — | S r   © )r   s    r   Ú	__enter__zExecutorEventEmitter.__enter__K   s   € Øˆr   ÚtypeÚvalueÚ	tracebackc                 ó.   — |                       ¦   «          d S r   )r-   )r   r1   r2   r3   s       r   Ú__exit__zExecutorEventEmitter.__exit__N   s   € ð 	�Š‰Œˆˆˆr   r   )T)r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   r   r   r   r   r   r	   Ústrr*   Úboolr-   r0   r   r#   r   r5   Ú__classcell__)r   s   @r   r   r      s  ø€ € € € € ð ð  ðD2ð 2 ¨(Ô!3ð 2ð 2ð 2ð 2ð 2ð 2ðàðð �C˜�HŒoðð �S˜#�X”ð	ð ð ð ð +ð +˜Tð +¨Tð +ð +ð +ð +ð
ð ð ð ðØ˜”OðØ,5ðØBOðà	�$Œðð ð ð ð ð ð ð r   N)Úconcurrent.futuresr   r   r   Útypesr   Útypingr   r   r	   r
   r   r   Ú	pyee.baser   Ú__all__r   r/   r   r   ú<module>rB      sÀ   ðð DÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CØ Ð Ð Ð Ð Ð Ø =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =à "Ð "Ð "Ð "Ð "Ð "à!Ð
"€ðEð Eð Eð Eð E˜<ñ Eô Eð Eð Eð Er   