
    gY                       U d dl mZ d dlZd dlZd dlmZmZmZ d dlm	Z	m
Z
 d dlmZmZmZ ddlmZmZ ddlmZmZmZmZmZ dd	lmZ d
dlmZ erd dlmZ d dlmZm Z   ed          Z!ej"        dk     rd dl#m$Z$  ede          Z% ede          Z&eg ee'e%e&f                  f         Z(de)d<    G d dee%e&f                   Z*e		 d,d-d            Z+d.d%Z,d/d(Z-d0d+Z.dS )1    )annotationsN)	AwaitableCallable	Generator)contextmanagersuppress)TYPE_CHECKINGGenericTypeVar   )CancelScope_core)AsyncResourceHalfCloseableStreamReceiveStream
SendStreamStream)aclose_forcefully   )assert_checkpoints)TracebackType)	ParamSpec	TypeAliasArgsT)      )BaseExceptionGroupRes1)boundRes2r   StreamMakerc                  &    e Zd ZddZddZddZdS )_ForceCloseBothbothtuple[Res1, Res2]returnNonec                $    |\  | _         | _        d S N_first_second)selfr$   s     g/var/www/html/nodeJS/PythonScripts/venv3.11/lib/python3.11/site-packages/trio/testing/_check_streams.py__init__z_ForceCloseBoth.__init__#   s    $(!T\\\    c                "   K   | j         | j        fS r)   r*   )r-   s    r.   
__aenter__z_ForceCloseBoth.__aenter__&   s      {DL((r0   exc_typetype[BaseException] | None	exc_valueBaseException | None	tracebackTracebackType | Nonec                   K   	 t          | j                   d {V  t          | j                   d {V  d S # t          | j                   d {V  w xY wr)   )r   r+   r,   )r-   r3   r5   r7   s       r.   	__aexit__z_ForceCloseBoth.__aexit__)   s~      	2#DK000000000#DL11111111111#DL1111111111s	   : AN)r$   r%   r&   r'   )r&   r%   )r3   r4   r5   r6   r7   r8   r&   r'   )__name__
__module____qualname__r/   r2   r:    r0   r.   r#   r#   "   sP        ) ) ) )) ) ) )	2 	2 	2 	2 	2 	2r0   r#   Fexpected_exctype[BaseException]wrappedboolr&   Generator[None, None, None]c              #    K   d}	 d V  t          d|            # t          $ rN}|s
J d            t          |j                  dk    sJ t	          |j        d         |           sJ Y d }~d S d }~w| $ r |r
J d            Y d S w xY w)NTzexpected exception: z:caught exceptiongroup, but expected an unwrapped exceptionr   r   z0caught exception, but expected an exceptiongroup)AssertionErrorr   len
exceptions
isinstance)r?   rA   __tracebackhide__excs       r.   _assert_raisesrK   7   s      
 
D BLBBCCC  ; ; ;TTTTTT3>""a''''#.+\::::::::::: O O ONNNNNNNNNOs    
BAA//BBstream_maker&StreamMaker[SendStream, ReceiveStream]clogged_stream_maker-StreamMaker[SendStream, ReceiveStream] | Noner'   c                |(  K   t           |              d{V           4 d{V \  t          t                    sJ t          t                    sJ d8fdd9d:fd
d;fdd<dt	          j                    4 d{V }|                    d           |                    d           ddd          d{V  n# 1 d{V swxY w Y   d=fd}t	          j                    4 d{V }|                    |           |                    d           ddd          d{V  n# 1 d{V swxY w Y   t	          j                    4 d{V }|                    t          d                     |                    d           ddd          d{V  n# 1 d{V swxY w Y   t	          j                    4 d{V }|                    t          d                     |                    d           ddd          d{V  n# 1 d{V swxY w Y   t          t                    5                      d           d{V  ddd           n# 1 swxY w Y   t          t                    5                      d           d{V  ddd           n# 1 swxY w Y   t          t                    5                      d           d{V  ddd           n# 1 swxY w Y   t	          j                    4 d{V }|                    d                         d{V dk    sJ 	 ddd          d{V  n# 1 d{V swxY w Y   t	          j                    4 d{V }|                    d            d           d{V dk    sJ 	 ddd          d{V  n# 1 d{V swxY w Y   t          t          j        d          5  t	          j                    4 d{V }|                    d           |                    d           ddd          d{V  n# 1 d{V swxY w Y   ddd           n# 1 swxY w Y   d>fd}t	          j                    4 d{V }|                    ||j                   |                    d           ddd          d{V  n# 1 d{V swxY w Y   d=fd}t	          j                    4 d{V }|                    |           |                               ddd          d{V  n# 1 d{V swxY w Y   t          t          j                  5   d            d{V  ddd           n# 1 swxY w Y   t          t          j                  5   d!           d{V  ddd           n# 1 swxY w Y               d{V              d{V              d{V  t          t          j                  5   d            d{V  ddd           n# 1 swxY w Y   t          t          j                  5   d"           d{V  ddd           n# 1 swxY w Y   t          t          j                  5  t#                      5                                   d{V  ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y               d{V              d{V  ddd          d{V  n# 1 d{V swxY w Y   t           |              d{V           4 d{V \  d=fd#}d=fd$}t	          j                    4 d{V }|                    |           |                    |           ddd          d{V  n# 1 d{V swxY w Y   ddd          d{V  n# 1 d{V swxY w Y   t           |              d{V           4 d{V \  t'                     d{V  t          t          j                  5  	  d            d{V  # 1 swxY w Y   t          t          j                  5   d!           d{V  ddd           n# 1 swxY w Y   ddd          d{V  n# 1 d{V swxY w Y   t           |              d{V           4 d{V \  t'                     d{V  t          t          j                  5   d%           d{V  ddd           n# 1 swxY w Y   t)          t          j                  5   d"           d{V  ddd           n# 1 swxY w Y   ddd          d{V  n# 1 d{V swxY w Y   t           |              d{V           4 d{V \  t	          j                    5 }|                                                                  d{V  ddd           n# 1 swxY w Y   t	          j                    5 }|                                                                  d{V  ddd           n# 1 swxY w Y   t          t          j                  5   d%           d{V  ddd           n# 1 swxY w Y   t          t          j                  5   d!           d{V  ddd           n# 1 swxY w Y   ddd          d{V  n# 1 d{V swxY w Y   t           |              d{V           4 d{V \  d?d,}	t	          j                    5 }|                                 t	          j                    4 d{V }|                    |	d           |                    |	d           ddd          d{V  n# 1 d{V swxY w Y   ddd           n# 1 swxY w Y   t	          j                    4 d{V }|                               |                               ddd          d{V  n# 1 d{V swxY w Y   ddd          d{V  n# 1 d{V swxY w Y   t           |              d{V           4 d{V \  d=fd-}
t	          j                    4 d{V }|                    |
           t	          j                     d{V  t'                     d{V  ddd          d{V  n# 1 d{V swxY w Y   ddd          d{V  n# 1 d{V swxY w Y   |t           |             d{V           4 d{V \  g d@fd/}d=fd0}t	          j                    4 d{V }|                    ||j                   t	          j                     d{V  |                    |           ddd          d{V  n# 1 d{V swxY w Y   g d1k    sJ 	 ddd          d{V  n# 1 d{V swxY w Y   t           |             d{V           4 d{V \  t          t          j        d          5  t	          j                    4 d{V }|                    j                   |                    j                   ddd          d{V  n# 1 d{V swxY w Y   ddd           n# 1 swxY w Y   t          t          j        d          5  t	          j                    4 d{V }|                    j                   |                    j        d%           ddd          d{V  n# 1 d{V swxY w Y   ddd           n# 1 swxY w Y   ddd          d{V  n# 1 d{V swxY w Y   t           |             d{V           4 d{V \  t          t          j        d          5  t	          j                    4 d{V }|                    j        d%           |                    j        d%           ddd          d{V  n# 1 d{V swxY w Y   ddd           n# 1 swxY w Y   ddd          d{V  n# 1 d{V swxY w Y   t           |             d{V           4 d{V \  d=fd2}d=fd3}t	          j                    4 d{V }|                    |           |                    |           ddd          d{V  n# 1 d{V swxY w Y   ddd          d{V  n# 1 d{V swxY w Y   t           |             d{V           4 d{V \  t'                     d{V  	 t#                      5                                   d{V  ddd           n# 1 swxY w Y   n# t          j        $ r Y nw xY wddd          d{V  n# 1 d{V swxY w Y   dAd6}t           |             d{V           4 d{V \  t	          j                    4 d{V }|                    |           t          t          j                  5                      d7           d{V  ddd           n# 1 swxY w Y   ddd          d{V  n# 1 d{V swxY w Y   ddd          d{V  n# 1 d{V swxY w Y   t           |             d{V           4 d{V \  t	          j                    4 d{V }|                    |           t          t          j                  5                                   d{V  ddd           n# 1 swxY w Y   ddd          d{V  n# 1 d{V swxY w Y   ddd          d{V  dS # 1 d{V swxY w Y   dS dS )Ba  Perform a number of generic tests on a custom one-way stream
    implementation.

    Args:
      stream_maker: An async (!) function which returns a connected
          (:class:`~trio.abc.SendStream`, :class:`~trio.abc.ReceiveStream`)
          pair.
      clogged_stream_maker: Either None, or an async function similar to
          stream_maker, but with the extra property that the returned stream
          is in a state where ``send_all`` and
          ``wait_send_all_might_not_block`` will block until ``receive_some``
          has been called. This allows for more thorough testing of some edge
          cases, especially around ``wait_send_all_might_not_block``.

    Raises:
      AssertionError: if a test fails.

    Ndatabytes | bytearray | memoryviewr&   r'   c                   K   t                      5                      |            d {V J 	 d d d            d S # 1 swxY w Y   d S r)   )r   send_all)rQ   ss    r.   do_send_allz)check_one_way_stream.<locals>.do_send_alld   s      #%% 6 6ZZ--------55556 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6s   >AA	max_bytes
int | Nonebytes | bytearrayc                   K   t                      5                      |            d {V cd d d            S # 1 swxY w Y   d S r)   )r   receive_some)rW   rs    r.   do_receive_somez-check_one_way_stream.<locals>.do_receive_someh   s      #%% 7 7^^I666666667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7s   :>>expectedbytesc                :   K    d           d {V | k    sJ d S Nr   r>   )r^   r]   s    r.   checked_receive_1z/check_one_way_stream.<locals>.checked_receive_1l   s:      (++++++++x777777r0   resourcer   c                   K   t                      5  |                                  d {V  d d d            d S # 1 swxY w Y   d S r)   )r   aclose)rc   s    r.   	do_aclosez'check_one_way_stream.<locals>.do_acloseo   s      #%% ( (oo'''''''''( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (s   9= =   xc                 P   K     d           d {V    d           d {V  d S )Nr0      yr>   rV   s   r.   send_empty_then_yz/check_one_way_stream.<locals>.send_empty_then_yx   sS       +c"""""""""+d###########r0   ri      1   2r   g      ?TrA   r   scoper   c                   K   t                      5                                   d {V  d d d            n# 1 swxY w Y   |                                  d S r)   )r   wait_send_all_might_not_blockcancel)rp   rU   s    r.   *simple_check_wait_send_all_might_not_blockzHcheck_one_way_stream.<locals>.simple_check_wait_send_all_might_not_block   s       $%% 8 8557777777778 8 8 8 8 8 8 8 8 8 8 8 8 8 8LLNNNNNs   9= =c                 |   K   t          t          j                  5  	   d           d {V  # 1 swxY w Y   d S )NTd   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)rK   r   BrokenResourceErrorrj   s   r.   expect_broken_stream_on_sendz:check_one_way_stream.<locals>.expect_broken_stream_on_send   s       9:: 2 22%+j11111111122 2 2 2 2 2 2 2 2 2s   155rv   i   r0   c                 P   K    d           d {V               d {V  d S )Nri   r>   )rf   rV   rU   s   r.   send_then_closez-check_one_way_stream.<locals>.send_then_close   sO      +d#########)A,,r0   c                    K   t          j                     d {V    d           d {V    d           d {V              d {V  d S )Nri   r0   )r   wait_all_tasks_blocked)rb   rf   r\   s   r.   receive_send_then_closez5check_one_way_stream.<locals>.receive_send_then_close   s      
 .000000000##D)))))))))##C((((((((()A,,r0   s   123afn"Callable[ArgsT, Awaitable[object]]args
ArgsT.argskwargsArgsT.kwargsc                   K   t          t          j                  5   | |i | d {V  d d d            d S # 1 swxY w Y   d S r)   )rK   r   	Cancelled)r~   r   r   s      r.   expect_cancelledz.check_one_way_stream.<locals>.expect_cancelled$  s      
  00 + +c4*6*********+ + + + + + + + + + + + + + + + + +s   8<<c                    K   t          t          j                  5                       d           d {V  d d d            d S # 1 swxY w Y   d S )N
   )rK   r   ClosedResourceErrorr[   r\   s   r.   receive_expecting_closedz6check_one_way_stream.<locals>.receive_expecting_closed:  s       9:: ) )nnR((((((((() ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )s   AA
A
cancel_scopec                  K                        d           t                      5                                   d {V  d d d            n# 1 swxY w Y                        d           |                                  d S )Nwaiter sleepingwaiter wokeup)appendr   rr   rs   )r   recordrU   s    r.   waiterz$check_one_way_stream.<locals>.waiterH  s      /000')) < <99;;;;;;;;;< < < < < < < < < < < < < < <o...##%%%%%s   AAAc                    K   t          j                     d {V                      d           	                      d           d {V  )Nreceiver startingTiA  )r   r|   r   r[   )r\   r   s   r.   receiverz&check_one_way_stream.<locals>.receiverO  si      244444444412220../////////0r0   )r   r   r   c                    K   	 t                      5                                    d {V  d d d            d S # 1 swxY w Y   d S # t          j        $ r Y d S w xY wr)   )r   rr   r   rw   rU   s   r.   senderz$check_one_way_stream.<locals>.sender}  s      +-- @ @==?????????@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @0   DDs.   A ;A ?A ?A AAc                 h   K   t          j                     d {V  t                      d {V  d S r)   r   r|   r   r   s   r.   r   z&check_one_way_stream.<locals>.receiver  sN      2444444444'***********r0   rU   r   c                f   K   t          j                     d {V  t          |            d {V  d S r)   r   r   s    r.   
close_soonz(check_one_way_stream.<locals>.close_soon  sM      .000000000#A&&&&&&&&&&&r0   s   xyzzy)rQ   rR   r&   r'   r)   )rW   rX   r&   rY   )r^   r_   r&   r'   )rc   r   r&   r'   r&   r'   )rp   r   r&   r'   )r~   r   r   r   r   r   r&   r'   )r   r   r&   r'   )rU   r   r&   r'   )r#   rH   r   r   r   open_nursery
start_soon	bytearray
memoryviewrK   
ValueErrorr[   	TypeErrorBusyResourceErrorr   rw   r   r   rr   r   r   r   rs   re   r|   rT   )rL   rN   nurseryrk   rt   rx   rz   r}   rp   r   r   r   r   r   r   rb   rf   r]   rV   r\   r   rU   s                  @@@@@@@r.   check_one_way_streamr   J   sT/     , \\^^33333344 } } } } } } }A!Z(((((!]+++++	6 	6 	6 	6 	6 	6	7 	7 	7 	7 	7 	7 	7	8 	8 	8 	8 	8 	8	( 	( 	( 	(
 %'' 	8 	8 	8 	8 	8 	8 	87{D1110$777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8	$ 	$ 	$ 	$ 	$ 	$ %'' 	8 	8 	8 	8 	8 	8 	8701110$777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 %'' 	8 	8 	8 	8 	8 	8 	87{IdOO<<<0$777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 %'' 	8 	8 	8 	8 	8 	8 	87{Jt,<,<===0$777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8
 J'' 	% 	%..$$$$$$$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%J'' 	$ 	$..#########	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$I&& 	& 	&..%%%%%%%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& %'' 	3 	3 	3 	3 	3 	3 	37{D111(********d22222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 %'' 	7 	7 	7 	7 	7 	7 	77{D111(........$66666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 E3TBBB 	7 	7)++ 7 7 7 7 7 7 7w""?A666""?A6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7	 	 	 	 	 	 %'' 	3 	3 	3 	3 	3 	3 	37:$   222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3	2 	2 	2 	2 	2 	2
 %'' 	- 	- 	- 	- 	- 	- 	-7;<<<y!,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-
 E566 	* 	*+j)))))))))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* E566 	( 	(!/$'''''''''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( illill ill E566 	* 	*+j)))))))))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* E566 	# 	#+c"""""""""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# E566 	8 	8#%% 8 8557777777778 8 8 8 8 8 8 8 8 8 8 8 8 8 8	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8
 illill{} } } } } } } } } } } } } } } } } } } } } } } } } } }~ \\^^33333344 8 8 8 8 8 8 8A	 	 	 	 	 	 	 		 	 	 	 	 	 	 	 %'' 	8 	8 	8 	8 	8 	8 	87///6777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8!8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8( \\^^33333344 ( ( ( ( ( ( (A"""""""""E566 	. 	..!k*---------.	. 	. 	. 	. 	. 	. 	. 	. E566 	( 	(!/$'''''''''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( \\^^33333344 
) 
) 
) 
) 
) 
) 
)A"""""""""E566 	& 	&+f%%%%%%%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& e/00 	) 	)##C(((((((((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) 
) \\^^33333344 ( ( ( ( ( ( (A   	ELLNNN((**	 	 	 	 	 	 	 	 	 	 	 	 	 	 	    	ELLNNN((**	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 E566 	& 	&+f%%%%%%%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& E566 	( 	(!/$'''''''''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (0 \\^^33333344 - - - - - - -A	+ 	+ 	+ 	+    	IELLNNN)++ I I I I I I Iw""#3[$GGG""#3_aHHHI I I I I I I I I I I I I I I I I I I I I I I I I I I	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I %'' 	- 	- 	- 	- 	- 	- 	-7y!,,,y!,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-!- - - - - - - - - - - - - - - - - - - - - - - - - - -, \\^^33333344 	' 	' 	' 	' 	' 	' 	'A	) 	) 	) 	) 	) 	) %'' 	' 	' 	' 	' 	' 	' 	'77888.000000000#A&&&&&&&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' '")=)=)?)?#?#?#?#?#?#?@@ 	 	 	 	 	 	 	FQ "F& & & & & & &0 0 0 0 0 0 0 )++ - - - - - - -w""67+?@@@2444444444""8,,,- - - - - - - - - - - - - - - - - - - - - - - - - - -
         -	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	8 #)=)=)?)?#?#?#?#?#?#?@@ 	; 	; 	; 	; 	; 	; 	;FQ 7FFF H H -// H H H H H H H7&&q'FGGG&&q'FGGGH H H H H H H H H H H H H H H H H H H H H H H H H H HH H H H H H H H H H H H H H H   7FFF ; ; -// ; ; ; ; ; ; ;7&&q'FGGG&&qz6:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ;	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;  #)=)=)?)?#?#?#?#?#?#?@@ 	; 	; 	; 	; 	; 	; 	;FQ   7FFF ; ; -// ; ; ; ; ; ; ;7&&qz6:::&&qz6:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ;	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; #)=)=)?)?#?#?#?#?#?#?@@ 	- 	- 	- 	- 	- 	- 	-FQ     + + + + + + )++ - - - - - - -w""6***""8,,,- - - - - - - - - - - - - - - - - - - - - - - - - - -	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-$ #)=)=)?)?#?#?#?#?#?#?@@ 	 	 	 	 	 	 	FQ#A&&&&&&&&&')) < <99;;;;;;;;;< < < < < < < < < < < < < < <,   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 		' 	' 	' 	' #)=)=)?)?#?#?#?#?#?#?@@ 	/ 	/ 	/ 	/ 	/ 	/ 	/FQ)++ / / / / / / /w"":q111#E$=>> / /**X........./ / / / / / / / / / / / / / // / / / / / / / / / / / / / / / / / / / / / / / / / /	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ #)=)=)?)?#?#?#?#?#?#?@@ 	< 	< 	< 	< 	< 	< 	<FQ)++ < < < < < < <w"":q111#E$=>> < <99;;;;;;;;;< < < < < < < < < < < < < < << < < < < < < < < < < < < < < < < < < < < < < < < < <	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<{ ('s  A"]-C<]
C	]C	"]>,D<*]<
E	]	E	
]&:F2 ]2
F<	<]?F<	 ]:H(](
H2	2]5H2	6]I5)]5I9	9]<I9	=]J<0]<K 	 ]K 	]L7]L	]
L	]'-M']'
M1	1]4M1	5].O ]
O	]O	 ]>Q4-QQ4
Q!!Q4$Q!%Q4(]4Q8	8];Q8	<"]2S"]"
S,	,]/S,	0"],U>]
U	]U	]:V]V	]V	 ]<W]W	]!W	"A]1Y]Y	]Y	]3Z]Z	]Z	]5\[+\+[//\2[/3\6]\	]	\	
%]
]]5-`"+_`
_)	)`,_)	-`
``62c(a<<b 	 cb 	c b>2c>c	cc	c
c%(c%2f>ef>e#	#f>&e#	'f>f!f>!f%	%f>(f%	)f>>
gg2l>	/i8l>i	l>i	l>"/jl>j!	!l>$j!	%l>kl>k#	#l>&k#	'l>l!l>!l%	%l>(l%	)l>>
mm2r.p;/o<*p<
pp	p
prp	r p	!r=-q<*r<
r	r	r	
r
r),r)#u/6Au:u/
u	u/u	u//
u9<u9&-yA
x/y/
x9	9y<x9	=y
y'*y'00|.
5|?|.
||.||."0.|2	205|2	60.6~6$6
   0	0	00
:=:@$AC AACA7AB&BACB&
AB0B0ACB3AB0B4ACB7AC CAC	CAC C
AC	CAC C 
AC*C-AC*D)AFD=+AE:E(AFE:
AF	FAFFAF	FAFF
AF'F*AF'GAIG+AH,G9AH HAH,H AH$	H$AH,H'AH$	H(AH,H+AIH,AH>H;AIH=AH>H>AII
AII AIJAM J(0ALKAL K4ALL ALLALLALLALLAM L
AL'	L'AM L*AL'	L+AM M 
AM
MAM
M4AP)N0APOAO(OAPO(AO,O,APO/AO,O0APO3AP)P
AP	PAP)PAP	PAP)P)
AP3P6AP3StreamMaker[Stream, Stream]"StreamMaker[Stream, Stream] | Nonec           
     d   K   t                      d{V  d fd}dfd}nd}t          ||           d{V  t                         d{V           4 d{V \  }t          |t                    sJ t          t                    sJ d}dt	          j        d          }|                    d	|z            }|                    |d
          }dfd}	dfd}
t          j	                    4 d{V }|
                    |	||d           |
                    |	|ddd         d           |
                    |
||ddd         d           |
                    |
|d           ddd          d{V  n# 1 d{V swxY w Y   dfd}t          j	                    4 d{V }|
                    |           |
                    |j                   ddd          d{V  n# 1 d{V swxY w Y   ddd          d{V  dS # 1 d{V swxY w Y   dS )u  Perform a number of generic tests on a custom two-way stream
    implementation.

    This is similar to :func:`check_one_way_stream`, except that the maker
    functions are expected to return objects implementing the
    :class:`~trio.abc.Stream` interface.

    This function tests a *superset* of what :func:`check_one_way_stream`
    checks – if you call this, then you don't need to also call
    :func:`check_one_way_stream`.

    Nr&   tuple[Stream, Stream]c                 :   K                  d {V d d d         S Nrn   r>   )rL   s   r.   flipped_stream_makerz2check_two_way_stream.<locals>.flipped_stream_maker  s0      "lnn$$$$$$ddd++r0   c                 :   K                  d {V d d d         S r   r>   )rN   s   r.   flipped_clogged_stream_makerz:check_two_way_stream.<locals>.flipped_clogged_stream_maker  s3      ..00000000$$B$77r0   i   i @  r      littlerU   r   rQ   rR   seedintr'   c                   K   t          j        |          }t          |          }|rG|                    d          }|                     |d |                    d {V  ||d          }|Ed S d S ra   )randomRandomr   randintrT   )rU   rQ   r   r\   m
chunk_sizeCHUNK_SIZE_MAXs         r.   r   z$check_two_way_stream.<locals>.sender  s      
 d##A4  A #YYq.99
jj;J;000000000jkkN  # # # # #r0   rY   c                P  K   t          j        |          }t                      }t          |          t          |          k     rX|                     |                    d                     d {V }|sJ ||z  }t          |          t          |          k     X||k    sJ d S ra   )r   r   r   rF   r[   r   )rU   rQ   r   r\   gotchunkr   s         r.   r   z&check_two_way_stream.<locals>.receiver  s      d##A++Cc((SYY&&nnQYYq.-I-IJJJJJJJJu c((SYY&& $;;;;;;r0   rn   r   r   r   c                    K                         d           d {V dk    sJ                                   d {V  d S )Nr   r0   )r[   re   )s2s   r.   expect_receive_some_emptyz7check_two_way_stream.<locals>.expect_receive_some_empty  s\      ,,,,,,,,3333))++r0   )r&   r   )rU   r   rQ   rR   r   r   r&   r'   )rU   r   rQ   rY   r   r   r&   r'   r   )r   r#   rH   r   r   r   getrandbitsto_bytesr   r   r   re   )rL   rN   r   r   s1DUPLEX_TEST_SIZEr\   i	test_datar   r   r   r   r   r   s   ``           @@r.   check_two_way_streamr     sx       |-A
B
BBBBBBBB, , , , , ,
 '	8 	8 	8 	8 	8 	8 	8 (,$
35Q
R
RRRRRRRR\\^^33333344 -* -* -* -* -* -* -*R"f%%%%%"f%%%%% !M!MM!..//JJ/::	
	# 
	# 
	# 
	# 
	# 
	#	 	 	 	 	 	 %'' 	; 	; 	; 	; 	; 	; 	;7vr9a888vr9TTrT?A>>>xYttt_a@@@xY:::		; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;	 	 	 	 	 	 %'' 	* 	* 	* 	* 	* 	* 	*78999ry)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*W-* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -* -*s\   'BHA3F	7H	
F	HF	"H90G;)H;
H	HH		H
H),H)5StreamMaker[HalfCloseableStream, HalfCloseableStream]<StreamMaker[HalfCloseableStream, HalfCloseableStream] | Nonec                  K   t          | |           d{V  t           |              d{V           4 d{V \  }}t          |t                    sJ t          |t                    sJ dd}dd}t	          j                    4 d{V }|                    ||           |                    ||           ddd          d{V  n# 1 d{V swxY w Y   t          t          j                  5  |	                    d	           d{V  ddd           n# 1 swxY w Y   t                      5  |                                 d{V  ddd           n# 1 swxY w Y   t	          j                    4 d{V }|                    ||           |                    ||           ddd          d{V  n# 1 d{V swxY w Y   ddd          d{V  n# 1 d{V swxY w Y   |t           |             d{V           4 d{V \  }}t          t          j        d
          5  t	          j                    4 d{V }|                    |j	        d           t	          j                     d{V  |                    |j                   ddd          d{V  n# 1 d{V swxY w Y   ddd           n# 1 swxY w Y   ddd          d{V  n# 1 d{V swxY w Y   t           |             d{V           4 d{V \  }}t          t          j        d
          5  t	          j                    4 d{V }|                    |j                   t	          j                     d{V  |                    |j                   ddd          d{V  n# 1 d{V swxY w Y   ddd           n# 1 swxY w Y   ddd          d{V  dS # 1 d{V swxY w Y   dS dS )u  Perform a number of generic tests on a custom half-closeable stream
    implementation.

    This is similar to :func:`check_two_way_stream`, except that the maker
    functions are expected to return objects that implement the
    :class:`~trio.abc.HalfCloseableStream` interface.

    This function tests a *superset* of what :func:`check_two_way_stream`
    checks – if you call this, then you don't need to also call
    :func:`check_two_way_stream`.

    NrU   r   r&   r'   c                   K   |                      d           d {V  t                      5  |                                  d {V  d d d            d S # 1 swxY w Y   d S )Nrg   )rT   r   send_eofr   s    r.   send_x_then_eofz4check_half_closeable_stream.<locals>.send_x_then_eof  s      **T"""""""""#%% # #jjll"""""""# # # # # # # # # # # # # # # # # #s   AAAr\   c                   K   t          j                     d {V  |                     d           d {V dk    sJ |                     d           d {V dk    sJ d S )Nr   rg   r0   )r   r|   r[   r   s    r.   expect_x_then_eofz6check_half_closeable_stream.<locals>.expect_x_then_eof  s      .000000000++++++++t3333++++++++s222222r0   ri   Tro   rg   )rU   r   r&   r'   )r\   r   r&   r'   )r   r#   rH   r   r   r   r   rK   r   rT   r   r   r   r|   rr   )rL   rN   r   r   r   r   r   s          r.   check_half_closeable_streamr     s       |-A
B
BBBBBBBB\\^^33333344 6 6 6 6 6 6 6R"122222"122222	# 	# 	# 	#
	3 	3 	3 	3
 %'' 	6 	6 	6 	6 	6 	6 	673330"555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6
 E566 	$ 	$++d#########	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$  !! 	  	 ++--	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  %'' 	6 	6 	6 	6 	6 	6 	673330"555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	676 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6> '")=)=)?)?#?#?#?#?#?#?@@ 	4 	4 	4 	4 	4 	4 	4HR 7FFF 4 4 -// 4 4 4 4 4 4 47&&r{D9996888888888&&r{3334 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 44 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 #)=)=)?)?#?#?#?#?#?#?@@ 	4 	4 	4 	4 	4 	4 	4HR   7FFF 4 4 -// 4 4 4 4 4 4 47&&r'GHHH6888888888&&r{3334 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 44 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 ('sX  AG&-C<G&
C	G&C	G&8D G& D$	$G&'D$	(G&9E G& E$	$G&'E$	(G&-G1G&
G	G&G	G&&
G03G0K1<KAJ7%K7
KKKKK1K	K1K	K11
K;>K;%O9OAN>,O>
OOOOO9O	O9"O	#O99
PP)F)r?   r@   rA   rB   r&   rC   )rL   rM   rN   rO   r&   r'   )rL   r   rN   r   r&   r'   )rL   r   rN   r   r&   r'   )/
__future__r   r   syscollections.abcr   r   r   
contextlibr   r   typingr	   r
   r    r   r   _abcr   r   r   r   r   _highlevel_genericr   _checkpointsr   typesr   typing_extensionsr   r   r   version_infoexceptiongroupr   r   r    tupler!   __annotations__r#   rK   r   r   r   r>   r0   r.   <module>r      sf   " " " " " " "  



 : : : : : : : : : : / / / / / / / /          " ! ! ! ! ! ! ! X X X X X X X X X X X X X X 2 2 2 2 2 2 , , , , , , ######66666666IgEg111111wv]+++wv]+++!"idDj0A&B"BC C C C C2 2 2 2 2gdDj) 2 2 2*  D D D D D$[< [< [< [<|
M* M* M* M*`A4 A4 A4 A4 A4 A4r0   