+
    iV  c                   s   ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHtHtHtH	t	H
t
HtHtHt ^RIHtHtHtHtHtHtHt ^RIHt ^RIHtHtHt ]P8                  ! ]4      t]P>                  '       d%   ]P@                  ! R4      t!]PD                  ! R4      t# ! R R	]4      t$ ! R
 R]4      t% ! R R]4      t& ! R R]&] PN                  4      t( ! R R]&4      t) ! R R]&4      t*R# )i    N)BinaryIOCallableClassVar
Collection	GeneratorMappingSequenceType)	JsonError
JsonObject	JsonValuecreate_objectget_boolget_enumget_str)CockpitProblem)EndpointRouterRoutingRule_T_Pc                   s   a a ] tR t^t o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t	Rt
VtV ;t# )ChannelRoutingRulec                $   < V ^8  d   QhRS[ RR/# )   routerchannel_typeszCollection[Type[Channel]])r   Zformat__classdict__   "4/usr/lib/python3.14/site-packages/cockpit/channel.py__annotate__ChannelRoutingRule.__annotate__   s      L Lv L6Q L    c                s  < \         SV `  V4       / V n        V F:  pV P                  P                  VP                  . 4      pVP                  V4       K<  	  V P                  P                  4        F  pVP                  R  RR7       K  	  R# )c                 s,    \        V P                  4      # N)lenrestrictions)cls   &r   Z<lambda>Z-ChannelRoutingRule.__init__.<locals>.<lambda>)   s    s3+;+;'<r    T)keyZreverseN)Zsuper__init__tableZ
setdefaultpayloadZappendZvaluesZsort)selfr   r   r$   Zentry	__class__s   &&&  r   r'   ZChannelRoutingRule.__init__   ss     
 !CJJ))#++r:ELL ! ZZ&&(EJJ<dJK )r    c                    < V ^8  d   QhRS[ /# r   returnr	   r   r   r   r   r   +   s      j r    c                s    / pV P                   P                  4        F/  w  r#. pV F  pVP                  VP                  4       K   	  WAV&   K1  	  V# r!   )r(   ZitemsZextendcapabilities)r*   resultr)   ZimplsZcapsZimpls   &     r   r0   ZChannelRoutingRule.capabilities+   sO    )+"jj..0NG "DD--. "7O	 1
 r    c                *   < V ^8  d   QhRRRS[ RS[/# )r   r#   zCollection[tuple[str, object]]optionsr.   )r	   boolr   r   r   r   r   5   s%      /O Zd im r    c                sj    V F,  w  r4VP                  V4      pVf    R# Vf   K#  WT8w  g   K+   R# 	  R# )NFT)get)r*   r#   r3   r&   Zexpected_valueZ	our_values   &&&   r   check_restrictionsZ%ChannelRoutingRule.check_restrictions5   s=    #/CC(I   )i.I $0 r    c                r   )r   r3   r.   zChannel | Noner/   r   r   r   r   r   F   s      * 1A r    c                s*   V P                   f   Q hVP                  R4      p\        V\        4      '       g   R # V P                  P                  V. 4       F9  pV P                  VP                  V4      '       g   K'  V! V P                   4      u # 	  R # )Nr)   )r   r5   
isinstancestrr(   r6   r#   )r*   r3   r)   r$      &&  r   
apply_ruleZChannelRoutingRule.apply_ruleF   sv    {{&&&++i('3''::>>'2.C&&s'7'7AA4;;'' / r    c                   < V ^8  d   QhRR/# r   r.   N r   r   r   r   r   S         $ r    c                    R # r!   r=   r*   r%   r   shutdownZChannelRoutingRule.shutdownS       r    c                $   < V ^8  d   Qh/ R;R&   # )r   zdict[str, list[Type[Channel]]]r(   r=   r   r   r   r   r      s     ++ r    )r(   )__name__
__module____qualname____firstlineno__r'   r0   r6   r:   rA   __annotate_func____static_attributes____classdictcell__Z__classcell__)r+   r   s   @@r   r   r      sA     L L  "  s  r    r   c                   s    ] tR t^WtRtR# )ChannelErrorr=   N)rD   rE   rF   rG   rI   r=   r    r   rK   rK   W   s    r    rK   c                   sb  a  ] tR t^[t o R=tR>tRt^ t]tRt	R?t
R?t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R/V 3R l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R' tR@R( lt R@V 3R) lR* llt!V 3R+ lR, lt"V 3R- lR. lt#V 3R/ lR0 lt$R@V 3R1 lR2 llt%R3 t&V 3R4 lR5 lt'](PR                  ! ^R67      t*V 3R7 lR8 lt+V 3R9 lR: lt,V 3R; lt-R<t.V t/R# )AChannelFNZ c                *   < V ^8  d   QhRS[ RS[RR/# )r   commandmessager.   Nr8   r	   r   r   r   r   Channel.__annotate__v   s"     % %# %
 %t %r    c                s   VR 8X  d   \        4       V n        \        VR4      V n        \	        VRRR7      '       d   RV n        \        VRR.R4      RJV n        \        VR	R
4      V n        \        VRR.R4      RJV n	        RV n
        V P                  4        V P                  V4       R# VR8X  d   V P                  4        R# VR8X  d   V P                  4        R# VR8X  d   V P                  4        R# VR8X  d   V P!                  V4       R# VR8X  d   V P#                  V4       R# VR8X  d   V P%                  V4       R# R# )Zopenchannelzflow-controlF)defaultTz	send-acksbytesNgrouprS   ZbinaryZrawreadydoneclosepingpongr3   )Zset_tasksr   rR   r   _send_pingsr   
_ack_bytesrU   	is_binarydecoderZfreeze_endpointdo_opendo_readydo_donedo_closedo_pingdo_pong
do_options)r*   rN   rO      &&&r   
do_controlZChannel.do_controlv   s    f%DK"7I6DL??#' &wgYMUYYDO '9=DJ%gx%$GtSDNDL  "LL!MMOLLNMMOLL!LL!	!OOG$ "r    c                s0   < V ^8  d   QhRS[ RS[ RS[RR/# )r   rR   rN   rO   r.   NrP   r   r   r   r   rQ      s*     ( (# ( (j (UY (r    c                s   V P                   e   R #   V P                  W#4       R #   \         d   p\        R\	        T4      R7      ThR p?ii ; i  \         d+   pT P                  TP                  4       4        R p?R # R p?ii ; i)Nprotocol-errorrO   )_close_argsrh   r   rK   r8   rX   	get_attrs)r*   rR   rN   rO   excs   &&&& r   do_channel_controlZChannel.do_channel_control   sr    '	(P1 P"#3SXFCOP 	(JJs}}''	(s,   & AAAA BB  Bc                s,   < V ^8  d   QhRRRRRS[ RR/# )r   hostz
str | NonerU   _messager.   Nr/   r   r   r   r   rQ      s*     	 	L 	 	 	X\ 	r    c                s    V P                   e   R # Ve   R # Ve   V P                  V8w  d   R # V P                  4        R # r!   )rk   rU   rc   )r*   ro   rU   rp   s   &&&&r   do_killZChannel.do_kill   s7    'u!4r    c                r   r   r3   r.   Nr/   r   r   r   r   rQ      s     " "z "d "r    c                    \         hr!   ZNotImplementedErrorr*   r3      &&r   r`   ZChannel.do_open       !!r    c                r;   r<   r=   r   r   r   r   rQ      r>   r    c                r?   r!   r=   r@   r%   r   ra   ZChannel.do_ready   rB   r    c                r;   r<   r=   r   r   r   r   rQ      s       r    c                r?   r!   r=   r@   r%   r   rb   ZChannel.do_done   rB   r    c                r;   r<   r=   r   r   r   r   rQ      s      $ r    c                s&    V P                  4        R # r!   rX   r@   r%   r   rc   ZChannel.do_close   s    

r    c                r   r   rO   r.   Nr/   r   r   r   r   rQ      s     a a* a ar    c                s    \        R RR7      h)znot-supportedz)This channel does not implement "options"rj   )rK   r*   rO   rv   r   rf   ZChannel.do_options   s    ?4_``r    c                r   ry   r/   r   r   r   r   rQ      s        z  d  r    c                s(    V P                  V4       R # r!   )	send_pongrz   rv   r   rd   ZChannel.do_ping   s    wr    c                r   r   datar.   NrT   r   r   r   r   rQ      s     6 6U 6t 6r    c                sf    V P                   '       d   V P                  R \        V4      R7       R# R# )Zackr~   N)r]   send_controlr"   r*   r}   rv   r   send_ackZChannel.send_ack   s'    ???e3t95 r    c                rM   )r   rR   r}   r.   N)r8   rT   r   r   r   r   rQ      s"     
( 
(s 
(% 
(D 
(r    c                s    V P                   e   R #  V P                  V4      '       g   V P                  V4       R # R #   \         d+   pT P	                  TP                  4       4        R p?R # R p?ii ; ir!   )rk   do_datar   rK   rX   rl   )r*   rR   r}   rm      &&& r   do_channel_dataZChannel.do_channel_data   s[    '	(<<%%d# & 	(JJs}}''	(s   > > A3	A..A3c                r   )r   r}   r.   zbool | Noner~   r   r   r   r   rQ      s     	 	E 	m 	r    c                s(    ?V P                  4        R# )zHandles incoming data to the channel.

Return value is True if the channel takes care of send acks on its own,
in which case it should call self.send_ack() on `data` at some point.
None or False means that the acknowledgement is sent automatically.Trx   r   rv   r   r   ZChannel.do_data   s     

r    c                r   )r   kwargsr.   N)r
   r   r   r   r   rQ      s     5 5i 5D 5r    c                sN    V P                  4        V P                  ! RR R/VB  R# )rN   rV   Nr=   )Zthaw_endpointr   )r*   r   s   &,r   rV   ZChannel.ready   s$    4'4V4r    finalc                s,   < V ^8  d   QhRS[ RS[RS[/# )r   r}   r   r.   )rT   r4   r8   r   r   r   r   rQ      s'     L L5 LD LS Lr    c               s    V P                   f   Q h V P                   P                  WR7      #   \         d   p\        R\	        T4      R7      ThR p?ii ; i)Nr   ri   rj   )r_   ZdecodeZUnicodeDecodeErrorrK   r8   )r*   r}   r   rm   s   &&$ r   Z__decode_frameZChannel.__decode_frame   sV    ||'''	L<<&&t&99! 	L/SBK	Ls   . AAAc                r;   r<   r=   r   r   r   r   rQ      s     * *d *r    c                sl    V P                   e   V P                  RRR7       V P                  RR7       R # )Nr    Tr   rW   )rN   )r_   _Channel__decode_framer   r@   r%   r   rW   ZChannel.done   s0    <<#40&)r    c                r,   r-   r4   r   r   r   r   rQ      s     , ,D ,r    c                s    V P                   R J# r!   )rk   r@   r%   r   
is_closingZChannel.is_closing   s    t++r    c                r;   r<   r=   r   r   r   r   rQ      s     1 1D 1r    c                s<    V P                  V P                  4       R # r!   )Zshutdown_endpointrk   r@   r%   r   
_close_nowZChannel._close_now   s    t//0r    c                s    V P                   P                  V4       V P                  e'   V P                   '       g   V P                  4        R # R # R # r!   )r[   Zremoverk   r   )r*   taskrv   r   
_task_doneZChannel._task_done   s<    
 	4 'OO 1<'r    c                s    V P                   e   Q h\        P                  ! V4      pV P                  P	                  V4       VP                  V P                  4       V# )zCreate a task associated with the channel.

All tasks must exit before the channel can close.  You may not create
new tasks after calling .close().
)rk   asynciocreate_taskr[   Zaddadd_done_callbackr   )r*   Z	coroutinenamer   r   r   r   ZChannel.create_task   sM     '''""9-t/r    c                "   < V ^8  d   QhRRRR/# )r   
close_argsJsonObject | Noner.   Nr=   r   r   r   r   rQ   	  s       3 t r    c                s    V P                   e   R# T;'       g    / V n         V P                  '       g   V P                  4        R# R# )zRequests the channel to be closed.

After you call this method, you won't get anymore `.do_*()` calls.

This will wait for any running tasks to complete before sending the
close message.
N)rk   r[   r   )r*   r   rv   r   rX   ZChannel.close	  s;     '%++{{{OO r    c                &   < V ^8  d   QhRS[ RS[/# r   r}   r.   rT   r4   r   r   r   r   rQ     s     5 5u 5 5r    c                sp   V P                  V P                  V4       V P                  '       dq   V P                  \	        V4      ,           pV P                  \
        P                  ,          V\
        P                  ,          8w  d   V P                  RVR7       W n        V P                  V P                  8  # )a[  Send binary data and handle book-keeping for flow control.

The flow control is "advisory".  The data is sent immediately, even if
it's larger than the window.  In general you should try to send packets
which are approximately Channel.BLOCK_SIZE in size.

Returns True if there is still room in the window, or False if you
should stop writing for now.  In that case, `.do_resume_send()` will be
called later when there is more room.

Be careful with text channels (i.e. without binary="raw"): you are responsible
for ensuring that @data is valid UTF-8. This isn't validated here for
efficiency reasons.
rY   )rN   sequence)	Zsend_channel_datarR   r\   _out_sequencer"   rL   
BLOCK_SIZEr   _out_window)r*   r}   Zout_sequence   && r   
send_bytesZChannel.send_bytes  s     	t||T2--D	9L!!W%7%77<7K]K];]]!!&<!H!-!!D$4$444r    c                r   r   r   r   r   r   r   rQ   1  s     9 9e 9 9r    c                s    V P                   '       d   V P                  V4      # V P                  f#   \        P                  ! R4      ! RR7      V n        V P                  V P                  V4      4      # )a  Send data and transparently handle UTF-8 for text channels

Use this for channels which can be text, but are not guaranteed to get
valid UTF-8 frames -- i.e. multi-byte characters may be split across
frames. This is expensive, so prefer send_text() or send_bytes() wherever
possible.
zutf-8Zstrict)Zerrors)r^   r   r_   codecsZgetincrementaldecoder	send_textr   r   rv   r   	send_dataZChannel.send_data1  sY     >>>??4(( <<!77@QDL~~d11$788r    c                r   r   )r8   r4   r   r   r   r   rQ   B  s     . .c .d .r    c                s@    V P                  VP                  4       4      # )zSend UTF-8 string data and handle book-keeping for flow control.

Similar to `send_bytes`, but for text data.  The data is sent as UTF-8 encoded bytes.
)r   encoder   rv   r   r   ZChannel.send_textB  s    
 t{{}--r    c                r2   )r   msgr   r   r.   )r
   r4   r   r   r   r   rQ   I  s$     & &0 &9 &QU &r    c                sz    V P                   P                  \        W4      4      R ,           pV P                  V4      # )Z
)json_encoderr   r   r   )r*   r   r   Zprettys   &&, r   	send_jsonZChannel.send_jsonI  s1    ""))-*DEL~~f%%r    c                s   V P                   '       g#   \        P                  R V P                  4       R# VR,          \        P
                  ,           V n        V P                  V P                  8  d   V P                  4        R# R# )zGot wild pong on channel %sNr   )	r\   loggerZwarningrR   rL   SEND_WINDOWr   r   do_resume_sendrz   rv   r   re   ZChannel.do_pongM  sa    NN8$,,G":.1D1DD 0 00! 1r    c                r;   r<   r=   r   r   r   r   rQ   V  s     K K Kr    c                s    R# )z<Called to indicate that the channel may start sending again.Nr=   r@   r%   r   r   ZChannel.do_resume_sendV  s    r    )Zindentc                rM   )r   rN   r   r.   N)r8   r
   r   r   r   r   rQ   \  s'     I IC I9 I Ir    c                sD    V P                   ! V P                  VR 3/ VB  R # r!   Zsend_channel_controlrR   )r*   rN   r   s   &&,r   r   ZChannel.send_control\  s    !!$,,HHr    c                r   ry   r/   r   r   r   r   rQ   _  s     A A A Ar    c                s@    V P                  V P                  R V4       R# )rZ   Nr   rz   rv   r   r{   ZChannel.send_pong_  s    !!$,,@r    c                s   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[;R&   S[ ;R&   R;R&   R;R&   R	;R
&   R;R&   R;R&   S[ ;R&   R;R&   R;R&   # )r   r\   r   r   r]   zset[asyncio.Task]r[   r   rk   zClassVar[str]r)   z&ClassVar[Sequence[tuple[str, object]]]r#   zClassVar[Sequence[str]]r0   r^   z codecs.IncrementalDecoder | Noner_   zClassVar[json.JSONEncoder]r   )r4   Zintr   r   r   r   rQ   [   s          "       %+   ! " ;?# $ ,0% . O/ 0 0/1 ~ /K r    )
r]   rk   r   r   r\   r[   rR   r_   rU   r^   i @  i    r=   r!   )0rD   rE   rF   rG   r   r   r\   r   r   rk   r#   r0   rR   rU   rh   rn   rq   r`   ra   rb   rc   rf   rd   r   r   r   rV   r   rW   r   r   r   r   rX   r   r   r   r   re   r   jsonZJSONEncoderr   r   r{   rH   rI   rJ   r      @r   rL   rL   [   su    J!K KM"K
 (,K >@L.0L GE
% %8( (	 	" "   a a   6 6
( 
(	 	5 5L5 L L* *, ,1 1
 5 529 9". .& &"K K 261A1A1KLI IA AI  r    rL   c                   s`  a  ] tR tRt o RtRtRtRtRtRt	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 3R! lR" ltV 3R# lR$ ltV 3R% ltR&tV tR# )'ProtocolChannelic  a  A channel subclass that implements the asyncio Protocol interface.

In effect, data sent to this channel will be written to the connected
transport, and vice-versa.  Flow control is supported.

The default implementation of the .do_open() method calls the
.create_transport() abstract method.  This method should return a transport
which will be used for communication on the channel.

Otherwise, if the subclass implements .do_open() itself, it is responsible
for setting up the connection and ensuring that .connection_made() is called.
NTFc                sT   < V ^8  d   QhRS[ P                  RS[RS[ P                  /# )r   loopr3   r.   )r   AbstractEventLoopr	   	Transportr   r   r   r   ProtocolChannel.__annotate__z  s/     " "7+D+D "z "^e^o^o "r    c                   "   \         h5i)zCreates the transport for this channel, according to options.

The event loop for the transport is passed to the function.  The
protocol for the transport is the channel object, itself (self).

This needs to be implemented by the subclass.
rt   )r*   r   r3   rg   r   create_transportZ ProtocolChannel.create_transportz  s      "!   	c                r   rr   r/   r   r   r   r   r     s     R Rz Rd Rr    c                s    \         P                  ! 4       p\         P                  ! V P                  W!4      4      V n        V P                  P                  V P                  4       R # r!   )r   get_running_loopr   r   _create_transport_taskr   create_transport_done)r*   r3   r   r   r   r`   ZProtocolChannel.do_open  sI    '')&-&9&9$:O:OPT:^&_###55d6P6PQr    c                r   )r   r   zasyncio.Task[asyncio.Transport]r.   Nr=   r   r   r   r   r     s      *K PT r    c                sb   WP                   J g   Q hR V n          VP                  4       pT P                  T4       T P                  e   T P                  ! R/ T P                  B  R # T P                  4        R #   \         d+   pT P                  TP	                  4       4        R p?R # R p?ii ; i)Nr=   )r   r1   rK   rX   rl   connection_made_ready_inforV   )r*   r   	transportrm   r9   r   r   Z%ProtocolChannel.create_transport_done  s    22222&*#	I
 	Y''JJ*))*JJL  	JJs}}'	s   A9 9B.B))B.c                s8   < V ^8  d   QhRS[ P                  RR/# )r   r   r.   N)r   ZBaseTransportr   r   r   r   r     s!     $ $)>)> $4 $r    c                sV    \        V\        P                  4      '       g   Q hWn        R # r!   )r7   r   r   
_transport)r*   r   rv   r   r   ZProtocolChannel.connection_made  s     )W%6%67777#r    c                r,   r-   r/   r   r   r   r   r     s       r    c                s    / # r!   r=   r@   r%   r   _get_close_argsZProtocolChannel._get_close_args  s    	r    c                r   )r   rm   zException | Noner.   Nr=   r   r   r   r   r     s     + +#5 +$ +r    c                sD    V P                  V P                  4       4       R # r!   )rX   r   )r*   rm   rv   r   connection_lostZProtocolChannel.connection_lost  s    

4'')*r    c                r   r|   r~   r   r   r   r   r     s     $ $E $d $r    c                s\    V P                   f   Q hV P                   P                  V4       R # r!   )r   writer   rv   r   r   ZProtocolChannel.do_data  s$    ***d#r    c                r;   r<   r=   r   r   r   r   r     s     ( ( (r    c                s    V P                   f   Q hV P                   P                  4       '       d   V P                   P                  4        R # R # r!   )r   Zcan_write_eofZ	write_eofr@   r%   r   rb   ZProtocolChannel.do_done  s:    ***??((**OO%%' +r    c                r;   r<   r=   r   r   r   r   r     s     $ $$ $r    c                sZ    V P                   e   V P                   P                  4        R # R # r!   )r   rX   r@   r%   r   rc   ZProtocolChannel.do_close  s!    ??&OO!!# 'r    c                r   r|   r~   r   r   r   r   r     s     ( (% (D (r    c                s    V P                   f   Q h V P                  V4      '       g   V P                   P                  4        R # R #   \         d+   pT P	                  TP                  4       4        R p?R # R p?ii ; ir!   )r   r   Zpause_readingrK   rX   rl   )r*   r}   rm   r   r   data_receivedZProtocolChannel.data_received  s`    ***	(>>$''--/ ( 	(JJs}}''	(s   A A A<A77A<c                r;   r<   r=   r   r   r   r   r     s     ) ) )r    c                sZ    V P                   f   Q hV P                   P                  4        R # r!   )r   Zresume_readingr@   r%   r   r   ZProtocolChannel.do_resume_send  s"    ***&&(r    c                r;   r<   r=   r   r   r   r   r     s     $ $d $r    c                s    RV n         V P                  '       d-   V P                  f   Q hV P                  P                  4        R# R# )a|  Mark the channel to be closed on EOF.

Normally, ProtocolChannel tries to keep the channel half-open after
receiving EOF from the transport.  This instructs that the channel
should be closed on EOF.

If EOF was already received, then calling this function will close the
channel immediately.

If you don't call this function, you are responsible for closing the
channel yourself.
TN)_close_on_eof_eofr   rX   r@   r%   r   close_on_eofZProtocolChannel.close_on_eof  s:     "999??...OO!!# r    c                r,   r-   r   r   r   r   r   r     s     & &d &r    c                sR    R V n         V P                  4        V P                  '       * # T)r   rW   r   r@   r%   r   eof_receivedZProtocolChannel.eof_received  s!    			%%%%r    c                s\    V P                   '       d   V P                  V4       R # Wn        R # r!   )_send_pongsr{   
_last_pingrz   rv   r   rd   ZProtocolChannel.do_ping  s!    NN7# &Or    c                r;   r<   r=   r   r   r   r   r     s     ! !t !r    c                s    R V n         R# )FN)r   r@   r%   r   pause_writingZProtocolChannel.pause_writing  s
     r    c                r;   r<   r=   r   r   r   r   r     s     # # #r    c                sx    R V n         V P                  e%   V P                  V P                  4       RV n        R# R# TN)r   r   r{   r@   r%   r   resume_writingZProtocolChannel.resume_writing  s0    ??&NN4??+"DO 'r    c                sf   < V ^8  d   Qh/ R;R&   S[ ;R&   R;R&   R;R&   R;R&   S[ ;R	&   S[ ;R
&   # )r   zasyncio.Transport | Noner   r   r   r   z&asyncio.Task[asyncio.Transport] | Noner   r   r   r   r   r   r   r   r   r   c  sa      +1    $*   EK! " %+# ( ) * + r    )r   r   r   r   r   r   )rD   rE   rF   rG   __doc__r   r   r   r   r   r   r   r   r`   r   r   r   r   r   rb   rc   r   r   r   r   rd   r   r   rH   rI   rJ   r   r   r   r   r   c  s      .2JK&*JGK'+K  MD" "R R
 $ $ + +$ $( (
$ $( () )$ $$& &&! !# #w  r    r   c                   s  a  ] tR tR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tRtV tR# )AsyncChanneli  a  A subclass for async/await-style implementation of channels, with flow control

This subclass provides asynchronous `read()` and `write()` calls for
subclasses, with familiar semantics.  `write()` doesn't buffer, so the
`done()` method on the base channel class can be used in a way similar to
`shutdown()`.  A high-level `sendfile()` method is available to send the
entire contents of a binary-mode file-like object.

The subclass must provide an async `run()` function, which will be spawned
as a task.  The task is cancelled when the channel is closed.

On the receiving side, the channel will respond to flow control pings to
indicate that it has received the data, but only after it has been consumed
by `read()`.

On the sending side, write() will block if the channel backs up.
Nc                r   )r   r3   r.   r   r/   r   r   r   r   AsyncChannel.__annotate__  s     " " "0C "r    c                r   r!   rt   ru   rv   r   runZAsyncChannel.run  s     !!r   c                r   rr   r/   r   r   r   r   r     s        r    c           	     s   "    \         P                  ! 4       V n        T P                  V P	                  V4      G R j  xL
 4       R #  L
  \         P
                   d    T P                  4         R # \         d+   pT P                  TP                  4       4        R p?R # R p?i\         d*   pT P                  RRR\        T4      /4        R p?R # R p?i\         d+    T P                  RRR\        P                  ! 4       /4       h i ; i5i)NZproblemri   rO   zinternal-errorZcause)r   r   r   rX   r   ZCancelledErrorrK   rl   r   r8   ZBaseException	tracebackZ
format_exc)r*   r3   rm   r   r   run_wrapperZAsyncChannel.run_wrapper  s     	002DIJJTXXg../.%% 	JJL 	(JJs}}'' 	KJJ	#3YCIJJ 	JJ	#3Wi>R>R>TUV	sn   D9A
 AA
 DA
 
%D/D2D;D<B!D!D.D/CDD +DDc                r;   )r   r.   zbytes | Noner=   r   r   r   r   r     s      N r    c                s   "    V P                   P                  4       G Rj  xL
 pVf   R# \        V\        4      '       d   V P	                  V4       KR  V P                  V4       V#  LF5ir   )receive_queuer5   r7   r   r{   r   )r*   Zitem   & r   readZAsyncChannel.read  sX     
 ++//11D|$((t$d# 2s   A*A(AA*c                r   r|   r~   r   r   r   r   r   !  s     $ $ $$ $r    c                s   "   V P                  V4      '       g6   V P                  P                  4       V n        V P                  G R j  xL
  R # R #  L5ir!   )r   r   Zcreate_futurewrite_waiterr   rv   r   r   ZAsyncChannel.write!  s@     ~~d## $		 7 7 9D#### $#s   AAA		Ac                s*   < V ^8  d   QhRRRRRRRR/# )	r   fnzCallable[_P, _T]argsz_P.argsr   z	_P.kwargsr.   r   r=   r   r   r   r   r   &  s2     J J"4 JY JR] Jbf Jr    c                s`   "   V P                   P                  ! R V.VO5/ VB G R j  xL
 #  L5ir!   )r   run_in_executor)r*   r   r   r   s   &&*,r   	in_threadZAsyncChannel.in_thread&  s,     YY..tRI$I&IIIIs   %.,.c                r   )r   streamr.   N)r    r   r   r   r   r   )  s      X $ r    c                sF  "   T;_uu_ 4         V P                   P                  RVP                  \        P                  4      G Rj  xL
 pVR8X  d   MV P                  V4      G Rj  xL
  Ka  V P                  4        RRR4       R#  LA L"  + '       g   i     R# ; i5i)TNr    )r   r   r   rL   r   r   rW   )r*   r   r}   r   r   sendfileZAsyncChannel.sendfile)  so     V!YY66tV[['J\J\]]3;jj&&&IIK V] ' VVs@   B!:BB	 B(B)B?
B!	BBB		B!c                r;   r<   r=   r   r   r   r   r   3  s     % % %r    c                sj    V P                   e%   V P                   P                  R 4       R V n         R # R # r!   )r   Z
set_resultr@   r%   r   r   ZAsyncChannel.do_resume_send3  s/    (((. $D )r    c                r   rr   r/   r   r   r   r   r   8  s     d dz dd dr    c                s    \         P                  ! 4       V n        V P                  V P	                  V4      V P
                  P                   R V R2R7      V n        R# )z.run_wrapper(Z))r   N)r   ZQueuer   r   r   r+   rD   	_run_taskru   rv   r   r`   ZAsyncChannel.do_open8  sS    $]]_))$*:*:7*C26..2I2I1J-X_W``a/b * dr    c                r;   r<   r=   r   r   r   r   r   =  s     , , ,r    c                s<    V P                   P                  R 4       R # r!   r   Z
put_nowaitr@   r%   r   rb   ZAsyncChannel.do_done=  s    %%d+r    c                r;   r<   r=   r   r   r   r   r   @  s        $  r    c                s:    V P                   P                  4        R # r!   )r   Zcancelr@   r%   r   rc   ZAsyncChannel.do_close@  s    r    c                r   ry   r/   r   r   r   r   r   C  s     / /z /d /r    c                <    V P                   P                  V4       R # r!   r   rz   rv   r   rd   ZAsyncChannel.do_pingC  s    %%g.r    c                r   r   r   r   r   r   r   r   F  s      E d r    c                r   r   r   r   rv   r   r   ZAsyncChannel.do_dataF  s    %%d+r    c                sD   < V ^8  d   Qh/ R;R&   S[ P                  ;R&   # )r   z(asyncio.Queue[bytes | JsonObject | None]r   r   )r   r   r   r   r   r   r     s%     , >=- . 
#
##/ r    )r   r   r   r   )rD   rE   rF   rG   r   r   r   r   r   r   r   r   r   r`   rb   rc   rd   r   rH   rI   rJ   r   r   r   r   r     s     2 L" "  $ $
J J % %
d d
, ,   / / C  r    r   c                   sf   a  ] tR tRt o 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tR
t	V t
R# )GeneratorChanneliK  a
  A trivial Channel subclass for sending data from a generator with flow control.

Calls the .do_yield_data() generator with the options from the open message
and sends the data which it yields.  If the generator returns a value it
will be used for the close message.
c                r   )r   r3   r.   "Generator[bytes, None, JsonObject]r/   r   r   r   r   GeneratorChannel.__annotate__T  s     " "Z "4X "r    c                rs   r!   rt   ru   rv   r   do_yield_dataZGeneratorChannel.do_yield_dataT  rw   r    c                r   rr   r/   r   r   r   r   r   W  s      z d r    c                sR    V P                  V4      V n        V P                  4        R # r!   )r   _GeneratorChannel__generatorr   ru   rv   r   r`   ZGeneratorChannel.do_openW  s!    --g6r    c                r;   r<   r=   r   r   r   r   r   [  s     # # #r    c                s     V P                  \        V P                  4      4      '       d   K,  R #   \         d7   pT P	                  4        T P                  TP                  4        R p?R # R p?ii ; ir!   )r   Znextr   ZStopIterationrW   rX   Zvalue)r*   Zstopr   r   r   ZGeneratorChannel.do_resume_send[  sU    	#..d&6&6!788 9 	#IIKJJtzz""	#s   ,0 A1+A,,A1c                rC   )r   r   r   r=   r   r   r   r   r   K  s      65 r    )Z__generatorN)rD   rE   rF   rG   r   r   r`   r   rH   rI   rJ   r   r   r   r   r   K  s/     " " # #!  r    r   )+r   r   r   Zloggingr   Ztypingr    r   r   r   r   r   r   r   Zjsonutilr   r	   r
   r   r   r   r   Zprotocolr   r   r   r   r   Z	getLoggerrD   r   ZTYPE_CHECKINGZTypeVarr   Z	ParamSpecr   r   rK   rL   ZProtocolr   r   r   r=   r    r   <module>r      s          _ _ _ b b b $ 1 1			8	$ 
		B			$	B: :z	> 	EAh EAP#gw// #Dc7 cL#w #r    