Ë
    v¹1hà	  ã                   óp   — 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 eZdgZ G d„ de«      Zy)é    )ÚExecutorÚFutureÚThreadPoolExecutor)ÚTracebackType)ÚAnyÚCallableÚDictÚOptionalÚTupleÚType)ÚEventEmitterÚExecutorEventEmitterc                   ó¶   ‡ — e Zd ZdZddede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dededdfd„Zdedd fd„Zde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ÚselfÚexecutorÚreturnc                 ó\   •— t         t        | �  «        |r|| _        y t	        «       | _        y ©N)Úsuperr   Ú__init__Ú	_executorr   )r   r   Ú	__class__s     €úK/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/pyee/executor.pyr   zExecutorEventEmitter.__init__1   s%   ø€ ÜÔ" DÑ2Ô4ÙØ'/ˆD�Nä/Ó1ˆD�Nó    ÚfÚargs.Úkwargsc                 ó€   ‡ —  ‰ j                   j                  |g|¢­i |¤Ž}|j                  dt        dd fˆ fd„«       }y )Nr   r   c                 ót   •— | j                  «       }t        |t        «      r‰j                  d|«       y |�|‚y )NÚerror)Ú	exceptionÚ
isinstanceÚ	ExceptionÚemit)r   Úexcr   s     €r   Ú	_callbackz1ExecutorEventEmitter._emit_run.<locals>._callback@   s5   ø€ à+,¯;©;«=ˆCÜ˜#œyÔ)Ø—	‘	˜' 3Õ'Ø�Ø�	ð !r   )r   ÚsubmitÚadd_done_callbackr   )r   r   r   r   Úfuturer&   s   `     r   Ú	_emit_runzExecutorEventEmitter._emit_run8   sK   ø€ ð /˜Ÿ™×.Ñ.¨qÐB°4ÒB¸6ÑBˆà	×	!Ñ	!ð	œð 	 Dô 	ó 
"ñ	r   Úwaitc                 ó<   — | j                   j                  |¬«       y)z)Call `shutdown` on the internal executor.)r+   N)r   Úshutdown)r   r+   s     r   r-   zExecutorEventEmitter.shutdownH   s   € ð 	�‰×Ñ TÐÕ*r   c                 ó   — | S r   © )r   s    r   Ú	__enter__zExecutorEventEmitter.__enter__M   s   € Øˆr   ÚtypeÚvalueÚ	tracebackc                 ó$   — | j                  «        y r   )r-   )r   r1   r2   r3   s       r   Ú__exit__zExecutorEventEmitter.__exit__P   s   € ð 	�‰ŒØr   r   )T)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚSelfr
   r   r   r   r   r   r	   Ústrr*   Úboolr-   r0   r   r#   r   r5   Ú__classcell__)r   s   @r   r   r      sÎ   ø„ ñ ñD2�tð 2 x°Ñ'9ð 2ÀTõ 2ðØðàðð �C˜�H‰oðð �S˜#�X‘ð	ð
 
óñ +�tð + 4ð +°4ó +ð
˜ð Ð!7ó ðØðØ˜y™/ðØ2;ðØHUðà	�$‰÷r   N)Úconcurrent.futuresr   r   r   Útypesr   Útypingr   r   r	   r
   r   r   Ú	pyee.baser   r:   Ú__all__r   r/   r   r   ú<module>rC      s5   ð÷ DÑ CÝ ß =× =å "à
€à!Ð
"€ôF˜<õ Fr   