+
    Ȝi2                     J  a  R t0 t R t^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
Ht ^ RIHt ^ RI	HtHtHtHtHt ]! R4      t ! R R]4      t]]]3,          t]! 4       t] ^ k R R	 lt]P4                  ! ]4        ! R
 R4      t ! R R]P8                  4      tR# )a  Ensure asyncio selector methods (add_reader, etc.) are available
tornado 6.1 adds AddThreadSelectorEventLoop event loop,
running select in a thread and defining these methods on the running event loop.
This factors out the functionality of AddThreadSelectorEventLoop
into a standalone SelectorThread object which can be attached to any running event loop.
Vendored from tornado v6.4.0
Redistributed under license Apache-2.0
N)Callable)suppress)AnyOptionalProtocolTypeVarUnion_Tc                   2   a  ] tR t^t o V 3R lR ltRtV tR# )
_HasFilenoc                    < V ^8  d   QhRS[ /# )   return)int)format__classdict__s   "d/Users/mibo/.openclaw/workspace/.venv-ak/lib/python3.14/site-packages/curl_cffi/_asyncio_selector.py__annotate___HasFileno.__annotate__    s           c                    ^ # )     selfs   &r   fileno_HasFileno.fileno    s    r   r   N)__name__
__module____qualname____firstlineno__r   __static_attributes____classdictcell__r   s   @r   r   r      s      r   r   c                    V ^8  d   QhRR/# r   r   Nr   )r   s   "r   r   r   +   s      $ r   c                     \          F  p V P                  ;_uu_ 4        R V n        V P                  P                  4        RRR4       \	        \
        4      ;_uu_ 4        V P                  P                  R4       RRR4       V P                  f   K  V P                  P                  4        K  	  \         P                  4        R#   + '       g   i     L; i  + '       g   i     Lg; i)TN   a)_selector_loops_select_cond_closing_selectornotifyr   BlockingIOError_waker_wsend_threadjoinclear)loops    r   _atexit_callbackr3   +   s    %)D"$$&  o&&MMt$ '<<#
 LL     '&s   "CCCC*c                     a  ] tR t^>t o RtRtV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 lt	V 3R lR lt
V 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltRtV tR# )SelectorThreadaY  Define ``add_reader`` methods to be called in a background select thread.

Instances of this class start a second thread to run a selector.
This thread is completely hidden from the user;
all callbacks are run on the wrapped event loop's thread.

Typically used via ``AddThreadSelectorEventLoop``,
but can be attached to a running asyncio loop.
Fc                8   < V ^8  d   QhRS[ P                  RR/# r   	real_loopr   NasyncioAbstractEventLoop)r   r   s   "r   r   SelectorThread.__annotate__K   s!      <  <'";";  <  <r   c                4  a a VS n         \        P                  ! 4       S n        R S n        RS n        R S n        S P                  4       S n        R V 3R lloS P                   P                  V V3R l4       / S n
        / S n        \        P                  ! 4       w  S n        S n        S P                  P!                  R4       S P                  P!                  R4       \"        P%                  S 4       S P'                  S P                  S P(                  4       R # )NFc                    V ^8  d   QhRR/# r%   r   )r   s   "r   r   -SelectorThread.__init__.<locals>.__annotate__V   s     	: 	:D 	:r   c                  X   <"   S P                   P                  4       G R j  xL
  R #  L5iN)_thread_manager_handle	__anext__r   s   r   thread_manager_anext5SelectorThread.__init__.<locals>.thread_manager_anextV   s       --77999s   *(*c                  D   < S P                   P                  S! 4       4      # rA   )
_real_loopcreate_task)r   rD   s   r   <lambda>)SelectorThread.__init__.<locals>.<lambda>_   s    DOO//0D0FGr   )rG   	threading	Conditionr)   _select_argsr*   r/   _thread_managerrB   	call_soon_readers_writerssocket
socketpair_waker_rr-   setblockingr(   add
add_reader_consume_waker)r   r8   rD   s   f&@r   __init__SelectorThread.__init__K   s    #%//1  	 "'37&*&:&:&<#	: 	: 	!!G	
 >@=? (.'8'8':$t}!!%(!!%(D!t':':;r   c                   < V ^8  d   QhRR/# r%   r   )r   r   s   "r   r   r<   m   s      t r   c                   V P                   '       d   R # V P                  ;_uu_ 4        RV n        V P                  P                  4        R R R 4       V P	                  4        V P
                  e   V P
                  P                  4        \        P                  V 4       V P                  V P                  4       V P                  P                  4        V P                  P                  4        RV n         R #   + '       g   i     L; i)NT)_closedr)   r*   r+   _wake_selectorr/   r0   r(   discardremove_readerrT   closer-   r   s   &r   ra   SelectorThread.closem   s    <<<%)D"$$&  	<<#LL%4==) s   "C88D	c                B   < V ^8  d   QhRS[ P                  R,          /# )r   r   )NN)typingAsyncGenerator)r   r   s   "r   r   r<   |   s      v'<'<Z'H r   c                  "   \         P                  ! R RV P                  R7      V n        V P                  P	                  4        V P                  4         R5x  R#   \         d    T P                  4        h i ; i5i)zTornado selectorT)namedaemontargetN)rK   Thread_run_selectr/   start_start_selectGeneratorExitra   r   s   &r   rN   SelectorThread._thread_manager|   sj      !''###

 	
	  	JJL	s   AA=A A=A::A=c                   < V ^8  d   QhRR/# r%   r   )r   r   s   "r   r   r<      s     % % %r   c                    V P                   '       d   R # \        \        4      ;_uu_ 4        V P                  P	                  R4       R R R 4       R #   + '       g   i     R # ; i)Nr'   )r]   r   r,   r-   r.   r   s   &r   r^   SelectorThread._wake_selector   s:    <<<o&&MMt$ '&&&s   AA#	c                   < V ^8  d   QhRR/# r%   r   )r   r   s   "r   r   r<      s     % % %r   c                    \        \        4      ;_uu_ 4        V P                  P                  R 4       RRR4       R#   + '       g   i     R# ; i)i   N)r   r,   rT   recvr   s   &r   rX   SelectorThread._consume_waker   s.    o&&MMt$ '&&&s	   >A	c                   < V ^8  d   QhRR/# r%   r   )r   r   s   "r   r   r<      s     ' 't 'r   c                R   V P                   ;_uu_ 4        V P                  e   Q h\        V P                  P	                  4       4      \        V P
                  P	                  4       4      3V n        V P                   P                  4        R R R 4       R #   + '       g   i     R # ; irA   )r)   rM   listrP   keysrQ   r+   r   s   &r   rm   SelectorThread._start_select   st     $$,,,!%dmm&8&8&:!;T$--BTBTBV=W XD$$& s   A6BB&	c                   < V ^8  d   QhRR/# r%   r   )r   r   s   "r   r   r<      s     > >T >r   c                L    V P                   ;_uu_ 4        V P                  f/   V P                  '       g   V P                   P                  4        K<  V P                  '       d    RRR4       R# V P                  f   Q hV P                  w  rRV n        RRR4        \        P                  ! XXV4      w  r4pWE,           p T P                  P                  T P                  Y44       K    + '       g   i     L]; i  \
         d{   pTP                  \        \        R\        P                  4      8X  dG   \        P                  ! T P                  P                  4       .. . ^ 4      w  p pT'       d   . p Rp?Lh h Rp?ii ; i  \         d     EK  \         d     EK  i ; i)TNWSAENOTSOCK)r)   rM   r*   waitselectOSErrorerrnogetattrEBADFrT   r   rG   call_soon_threadsafe_handle_selectRuntimeErrorAttributeError)r   to_readto_writerswsxse_s   &       r   rk   SelectorThread._run_select   sS   """''/8N8N8N%%**,)))	 #"
 ((444$($5$5!$(! #  $]]7HhG
W,44T5H5H"Qa #"4   77ge]EKKHH%}}dmm.B.B.D-Er2qQHB1'.    !  	s_    C*-C*%C*0%C*#C= &F *C:	=FA+E=4E=;E==FF#F#F#"F#c                J   < V ^8  d   QhRS[ S[,          RS[ S[,          RR/# )r   r   r   r   N)ry   _FileDescriptorLike)r   r   s   "r   r   r<      s1      *+156I1J	r   c                    V F  pV P                  W0P                  4       K   	  V F  pV P                  W@P                  4       K   	  V P                  4        R # rA   )_handle_eventrP   rQ   rm   )r   r   r   rws   &&&  r   r   SelectorThread._handle_select   sH     Aq--0 Aq--0 r   c                @   < V ^8  d   QhRS[ RS[S[ S[3,          RR/# )r   fdcb_mapr   N)r   dictr   )r   r   s   "r   r   r<      s4     	 		 ((23	 
		r   c                J     W!,          pT! 4        R #   \          d     R # i ; irA   )KeyError)r   r   r   callbacks   &&& r   r   SelectorThread._handle_event   s)    
	zH 	
  		s    ""c                >   < V ^8  d   QhRS[ RS[R,          RS[RR/# r   r   r   Nargsr   .Nr   r   r   )r   r   s   "r   r   r<      2      %19)1DMP	r   c                p    \         P                  ! V.VO5!  V P                  V&   V P                  4        R # rA   )	functoolspartialrP   r^   r   r   r   r   s   &&&*r   rW   SelectorThread.add_reader   .     &--h>>br   c                >   < V ^8  d   QhRS[ RS[R,          RS[RR/# r   r   )r   r   s   "r   r   r<     r   r   c                p    \         P                  ! V.VO5!  V P                  V&   V P                  4        R # rA   )r   r   rQ   r^   r   s   &&&*r   
add_writerSelectorThread.add_writer  r   r   c                &   < V ^8  d   QhRS[ RS[/# r   r   r   r   bool)r   r   s   "r   r   r<            3  r   c                f     V P                   V T P                  4        R#   \         d     R # i ; iFT)rP   r   r^   r   r   s   &&r   r`   SelectorThread.remove_reader  8    	b! 	  		   ! 00c                &   < V ^8  d   QhRS[ RS[/# r   r   )r   r   s   "r   r   r<     r   r   c                f     V P                   V T P                  4        R#   \         d     R # i ; ir   )rQ   r   r^   r   s   &&r   remove_writerSelectorThread.remove_writer  r   r   )r]   r*   rP   rG   rM   r)   r/   rB   rT   r-   rQ   N)r   r   r   r    __doc__r]   rY   ra   rN   r^   rX   rm   rk   r   r   rW   r   r`   r   r!   r"   r#   s   @r   r5   r5   >   s      G <  <D  2% %% %' '> >@ 	 	    r   r5   c                      a a ] tR tRt oRt0 RmtV3R lV 3R lltV3R lR ltV3R lR ltV3R	 lR
 lt	V3R lR lt
V3R lR ltV3R lR ltRtVtV ;t# )AddThreadSelectorEventLoopi  a{  Wrap an event loop to add implementations of the ``add_reader`` method family.

Instances of this class start a second thread to run a selector.
This thread is completely hidden from the user; all callbacks are
run on the wrapped event loop's thread.

This class is used automatically by Tornado; applications should not need
to refer to it directly.

It is safe to wrap any event loop with this class, although it only makes sense
for event loops that do not implement the ``add_reader`` family of methods
themselves (i.e. ``WindowsProactorEventLoop``)

Closing the ``AddThreadSelectorEventLoop`` also closes the wrapped event loop.

c                &   < V ^8  d   QhRS[ RS[/# )r   rg   r   )strr   )r   r   s   "r   r   'AddThreadSelectorEventLoop.__annotate__7  s     . .S .S .r   c                x   < V\         P                  9   d   \        SV `  V4      # \	        V P
                  V4      # rA   )r   MY_ATTRIBUTESsuper__getattribute__r   rG   )r   rg   	__class__s   &&r   r   +AddThreadSelectorEventLoop.__getattribute__7  s3    -;;;7+D11t--r   c                8   < V ^8  d   QhRS[ P                  RR/# r7   r9   )r   r   s   "r   r   r   <  s!     3 3'";"; 3 3r   c                2    Wn         \        V4      V n        R # rA   )rG   r5   	_selector)r   r8   s   &&r   rY   #AddThreadSelectorEventLoop.__init__<  s    #'	2r   c                   < V ^8  d   QhRR/# r%   r   )r   r   s   "r   r   r   @  s        t  r   c                n    V P                   P                  4        V P                  P                  4        R # rA   )r   ra   rG   r   s   &r   ra    AddThreadSelectorEventLoop.close@  s"    r   c                <   < V ^8  d   QhRRRS[ R,          RS[RR/# r   r   r   r   Nr   r   r   r   r   )r   r   s   "r   r   r   D  8     > >!> 9%> 	>
 
>r   c                >    V P                   P                  ! W.VO5!  # rA   )r   rW   r   s   &&&*r   rW   %AddThreadSelectorEventLoop.add_readerD       ~~((===r   c                <   < V ^8  d   QhRRRS[ R,          RS[RR/# r   r   )r   r   s   "r   r   r   L  r   r   c                >    V P                   P                  ! W.VO5!  # rA   )r   r   r   s   &&&*r   r   %AddThreadSelectorEventLoop.add_writerL  r   r   c                $   < V ^8  d   QhRRRS[ /# r   r   r   r   r   )r   r   s   "r   r   r   T       0 0 5 0$ 0r   c                8    V P                   P                  V4      # rA   )r   r`   r   s   &&r   r`   (AddThreadSelectorEventLoop.remove_readerT      ~~++B//r   c                $   < V ^8  d   QhRRRS[ /# r   r   )r   r   s   "r   r   r   W  r   r   c                8    V P                   P                  V4      # rA   )r   r   r   s   &&r   r   (AddThreadSelectorEventLoop.remove_writerW  r   r   )rG   r   >   ra   r   rG   rW   r   r`   r   )r   r   r   r    r   r   r   rY   ra   rW   r   r`   r   r!   r"   __classcell__)r   r   s   @@r   r   r     s\     &M. .
3 3   > >> >0 00 0 0r   r   c                N    V ^8  d   Qh/ ^ \         9   d   \        R,          ;R&   # )r   r5   r(   )__conditional_annotations__set)r   s   "r   r   r      s&      N / .%& .Or   )r   r   r:   atexitr   r   r   rR   rK   rd   collections.abcr   
contextlibr   r   r   r   r   r   r	   r   r   r   r   r(   r3   registerr5   r;   r   r   )r   s   @r   <module>r      s            $   T] 
 CO,  *- .    !X Xv?0!:!: ?0r   