ó
    X=Œj£  ã                   ó|   • 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
Jr  S SKJr  S SKJrJr  \rS/r " S S\5      rg)	é    )Úiscoroutine)ÚAnyÚCallableÚcastÚDictÚOptionalÚTuple)ÚDeferredÚensureDeferred)ÚFailure)ÚEventEmitterÚ	PyeeErrorÚTwistedEventEmitterc            
       óŠ   ^ • \ rS rSrSrS\SS4U 4S jjrS\S\S\\	S	4   S
\
\\	4   SS4
S jrS\S\S\	SS4U 4S jjrSrU =r$ )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                 ó*   >• [         [        U ]  5         g )N)Úsuperr   Ú__init__)r   Ú	__class__s    €ÚP/Users/stevendouglas/BidBrain/.venv/lib/python3.13/site-packages/pyee/twisted.pyr   ÚTwistedEventEmitter.__init__5   s   ø€ ÜÔ! 4Ñ1Õ3ó    ÚfÚargs.Úkwargsc                 ó*  ^ • S n U" U0 UD6n[        U5      (       a  [        U5      nO [        U[        5      (       a  UnOU(       d  g S[        SS 4U 4S jjnUR                  U5        g ! [         a    T R                  S[	        5       5         g f = f)NÚfailurer   c                 ó:   >• U (       a  TR                  SU 5        g g )Nr   )Úemit)r   r   s    €r   ÚerrbackÚ.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_runÚTwistedEventEmitter._emit_run8   s�   ø€ ð &*ˆð	"Ù˜Ð' Ñ'ˆFô ˜6×"Ñ"Ü" 6Ó*‘Ü˜F¤H×-Ñ-Ø‘ÞØð2¤ð 2¨T÷ 2ð �L‰L˜Õ!øô ó 	,Ø�I‰I�i¤£Ö+ð	,ús   …A+ Á+$BÂBÚeventÚerrorc                 óš  >• US:X  an  [        U[        5      (       a   UR                  5         g [        U[        5      (       a  U R	                  SU5        g U R	                  S[        SU 35      5        g [        [        [        [        U 5      5      R                  X5        g ! [         a  nU R	                  SU5         S nAg S nAff = f)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/   Ú0TwistedEventEmitter._emit_handle_potential_errorQ   s¤   ø€ Ø�IÓÜ˜%¤×)Ñ)ð,Ø×(Ñ(Õ*ô ˜E¤9×-Ñ-Ø—	‘	˜' 5Õ)à—	‘	˜'¤9Ð/JÈ5È'Ð-RÓ#SÕTä””eÔ/°Ó6Ó7×TÑTØõøô !ó ,Ø—I‘I˜g s×+Ñ+ûð,ús   žB$ Â$
C
Â.CÃC
© )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚSelfr   r   r	   r   r   Ústrr)   r/   Ú__static_attributes__Ú__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   r8   Ú__all__r   r2   r   r   Ú<module>rB      s6   ðõ  ß =× =ç ;Ý *ç -à
€ð !Ð
!€ôN˜,õ Nr   