ó
    X=Œjà	  ã                   óp   • S SK JrJrJr  S SKJr  S SKJrJrJ	r	J
r
JrJr  S SKJr  \rS/r " S S\5      rg)é    )ÚExecutorÚFutureÚThreadPoolExecutor)ÚTracebackType)ÚAnyÚCallableÚDictÚOptionalÚTupleÚType)ÚEventEmitterÚExecutorEventEmitterc                   óÎ   ^ • \ rS rSrSrSS\S\\   SS4U 4S jjjrS\S\	S	\
\S
4   S\\\4   SS4
S jrSS\S\SS4S jjrS\SS 4S jrS\S\\   S\S\S\\   4
S jrSrU =r$ )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                 ód   >• [         [        U ]  5         U(       a  Xl        g [	        5       U l        g ©N)Úsuperr   Ú__init__Ú	_executorr   )r   r   Ú	__class__s     €ÚQ/Users/stevendouglas/BidBrain/.venv/lib/python3.13/site-packages/pyee/executor.pyr   ÚExecutorEventEmitter.__init__1   s#   ø€ ÜÔ" DÑ2Ô4ÞØ'/�Nä/Ó1ˆD�Nó    ÚfÚargs.Úkwargsc                 ó„   ^ • T R                   R                  " U/UQ70 UD6nUR                  S[        SS 4U 4S jj5       ng )Nr   r   c                 ó€   >• U R                  5       n[        U[        5      (       a  TR                  SU5        g Ub  Ueg )NÚerror)Ú	exceptionÚ
isinstanceÚ	ExceptionÚemit)r   Úexcr   s     €r   Ú	_callbackÚ1ExecutorEventEmitter._emit_run.<locals>._callback@   s8   ø€ à+,¯;©;«=ˆCÜ˜#œy×)Ñ)Ø—	‘	˜' 3Õ'Ø‘Ø�	ð !r   )r   ÚsubmitÚadd_done_callbackr   )r   r   r   r   Úfuturer(   s   `     r   Ú	_emit_runÚExecutorEventEmitter._emit_run8   sI   ø€ ð Ÿ™×.Ò.¨qÐB°4ÒB¸6ÑBˆà	×	!Ñ	!ð	œð 	 Dö 	ó 
"ñ	r   Úwaitc                 ó6   • U R                   R                  US9  g)z)Call `shutdown` on the internal executor.)r/   N)r   Úshutdown)r   r/   s     r   r1   ÚExecutorEventEmitter.shutdownH   s   € ð 	�‰×Ñ TÐÒ*r   c                 ó   • U $ r   © )r   s    r   Ú	__enter__ÚExecutorEventEmitter.__enter__M   s   € Øˆr   ÚtypeÚvalueÚ	tracebackc                 ó$   • U R                  5         g r   )r1   )r   r7   r8   r9   s       r   Ú__exit__ÚExecutorEventEmitter.__exit__P   s   € ð 	�‰ŒØr   )r   r   )T)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚSelfr
   r   r   r   r   r   r	   Ústrr-   Úboolr1   r5   r   r%   r   r;   Ú__static_attributes__Ú__classcell__)r   s   @r   r   r      sØ   ø† ñ ñD2�tð 2 x°Ñ'9ð 2ÀT÷ 2ð 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   rB   Ú__all__r   r4   r   r   Ú<module>rL      s5   ð÷ DÑ CÝ ß =× =å "à
€à!Ð
"€ôF˜<õ Fr   