
    Eg                       U d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
mZ d dlmZmZmZmZmZmZmZmZmZmZ d dlZd dlZddlmZmZmZmZmZmZm Z m!Z!m"Z" ddl#m$Z$ ddl%m&Z& dd	l'm(Z(m)Z)m*Z*m+Z+m,Z, dd
l-m.Z. erd dl/m0Z0 ddl1m2Z2 eee3eej4        ee5         f         f                  Z6 ed          Z7dGdZ8dGdZ9dGdZ:dGdZ;dGdZ<dHdIdZ=dGdZ>dGdZ?dGdZ@dGdZAdJd!ZBejC        D                    d"g d#          ejC        D                    d$d%d&g          ejC        D                    d'd%d&g          dKd*                                    ZEdGd+ZFdGd,ZGdLd-ZHdGd.ZIdGd/ZJ ejK        d0          ZLd1eMd0<   dGd2ZNdGd3ZOdGd4ZPdGd5ZQdGd6ZRdGd7ZSdGd8ZTdGd9ZUdGd:ZVdGd;ZWdGd<ZXdGd=ZYdGd>ZZdGd?Z[dGd@Z\dGdAZ]dGdBZ^dGdCZ_e&dGdD            Z`dGdEZadGdFZbdS )M    )annotationsNpartial)
TYPE_CHECKINGAsyncGenerator	AwaitableCallableListNoReturnTupleTypeTypeVarUnion   )	CancelScopeCapacityLimiterEventTrioDeprecationWarning_core
fail_aftermove_on_aftersleepsleep_forever)ki_self)slow)current_default_thread_limiterfrom_thread_check_cancelledfrom_thread_runfrom_thread_run_syncto_thread_run_sync)wait_all_tasks_blocked)Outcome)TaskTreturnNonec                 t  K   t          j                    	 ddfd} t          j                    }dd} | t          |d|           d {V  dd} | t          |dt
          f|           d {V  dd} | t          |d|           d {V  dd} | t          |dt          f|           d {V  d S )Ndo_in_trio_threadCallable[..., threading.Thread]fnCallable[..., T | Awaitable[T]]expectedtuple[str, T]
trio_token_core.TrioToken | Noner%   r&   c                4   K   g d
 fd}t          j        |d          }|                                 |                                r8t	          d           t          d           d {V  |                                8d|fd	f|gk    sJ d S )Nr%   r&   c                 :   	                      dt          j                    f                      }                      d| f           d S # t          $ r>}t	          |                                dt          |          f           Y d }~d S d }~ww xY w)Nstartr.   goterror)append	threadingcurrent_threadBaseExceptionprinttype)xexcr(   r*   recordr.   s     M/var/www/sysmax/venv/lib/python3.11/site-packages/trio/_tests/test_threads.pythreadfnz<test_do_in_trio_thread.<locals>.check_case.<locals>.threadfnE   s    4w	(@(B(BCDDD%%b&ZHHHuaj)))))  4 4 4c


wS		23333333334s   AA 
B3BBT)targetdaemonyawn{Gz?r2   fr%   r&   )r7   Threadr2   is_aliver:   r   )r(   r*   r,   r.   r@   child_threadr>   trio_threads   `` `  @r?   
check_casez*test_do_in_trio_thread.<locals>.check_case=   s        	4 	4 	4 	4 	4 	4 	4 	4 	4 !'xEEE##%% 	&MMM++ ##%% 	 7L1C3ExPPPPPPP    r>   
RecordTypeintc                    t          j                    rJ |                     dt          j                    f           dS )NrE   r   )r   currently_ki_protectedr6   r7   r8   r>   s    r?   f1z"test_do_in_trio_thread.<locals>.f1W   s<    /11111sI4667888qrL   )r4   r   r3   r   c                    t          j                    rJ |                     dt          j                    f           t
          NrE   )r   rP   r6   r7   r8   
ValueErrorrQ   s    r?   f2z"test_do_in_trio_thread.<locals>.f2^   s=    /11111sI4667888rL   r5   c                   K   t          j                    rJ t          j                     d {V  |                     dt	          j                    f           dS )NrE      )r   rP   
checkpointr6   r7   r8   rQ   s    r?   f3z"test_do_in_trio_thread.<locals>.f3e   sa      /11111         sI4667888qrL   )r4   rX   c                   K   t          j                    rJ t          j                     d {V  |                     dt	          j                    f           t          rT   )r   rP   rY   r6   r7   r8   KeyErrorrQ   s    r?   f4z"test_do_in_trio_thread.<locals>.f4m   sa      /11111         sI4667888rL   N)
r(   r)   r*   r+   r,   r-   r.   r/   r%   r&   )r>   rM   r%   rN   )r>   rM   r%   r   )r7   r8   r   current_trio_tokenr   rU   r   r\   )rK   tokenrR   rV   rZ   r]   rJ   s         @r?   test_do_in_trio_threadra   :   sk     *,,K .2	Q Q Q Q Q Q Q0 $&&E   
 *)2ze
L
L
LLLLLLLL   
 *)2/DQV
W
W
WWWWWWWW    *_b*
G
G
GGGGGGGG    *_b7H*=%
P
P
PPPPPPPPPPrL   c                   K   t          j        t                    5  t          d            d d d            n# 1 swxY w Y   dd} t          j        t                    5  t	          |            d d d            d S # 1 swxY w Y   d S )Nc                     d S r^    rd   rL   r?   <lambda>z9test_do_in_trio_thread_from_trio_thread.<locals>.<lambda>x       T rL   r%   r&   c                 
   K   d S r^   rd   rd   rL   r?   fooz4test_do_in_trio_thread_from_trio_thread.<locals>.fooz         rL   rF   )pytestraisesRuntimeErrorr   r   )rh   s    r?   'test_do_in_trio_thread_from_trio_threadrm   v   s     	|	$	$ + +\\***+ + + + + + + + + + + + + + +    
|	$	$                   s   9= =!A>>BBc                 l    t                      dfd} t          j        |            ddhk    sJ d S )Nr%   r&   c                   K   t          j                    dddfddfd} t          j        |           }|                                 t          d           |                                r)t          d           d {V  |                                )t          d	           |                                 t          d
           d S )Nr%   r&   c                    t          d           t          j                    rJ t          d           	 t                       dd l} t          d | j                               d S # dd l} t          d | j                               w xY w)Nzin Trio threadr   r   finally)r:   r   rP   r   sysexc_info)rr   s    r?   trio_thread_fnzTtest_run_in_trio_thread_ki.<locals>.check_run_in_trio_thread.<locals>.trio_thread_fn   s    "###355555)1			


i00000 


i0000s   A& &#B	c                     K                  d S r^   rd   )rt   s   r?   trio_thread_afnzUtest_run_in_trio_thread_ki.<locals>.check_run_in_trio_thread.<locals>.trio_thread_afn   s      NrL   c                 B   	 t          d           t                     n4# t          $ r' t          d                                d           Y nw xY w	 t	                     d S # t          $ r( t          d                                d           Y d S w xY w)Nrunningr3   ok1ok2)r:   r   KeyboardInterruptaddr   )r>   r`   rv   rt   s   r?   external_thread_fnzXtest_run_in_trio_thread_ki.<locals>.check_run_in_trio_thread.<locals>.external_thread_fn   s    "i   $^FFFFF$ " " "e

5!!!!!""EBBBBBB$ " " "e

5!!!!!!"s!    $ .AAA, ,.BB)rA   waitingrD   zwaited, joiningdonerF   )	r   r_   r7   rG   r2   r:   rH   r   join)r}   threadr`   rv   rt   r>   s     @@@r?   check_run_in_trio_threadz<test_run_in_trio_thread_ki.<locals>.check_run_in_trio_thread   s     (**		1 		1 		1 		1	 	 	 	 	 		" 	" 	" 	" 	" 	" 	" 	" 	" !);<<<ioo 	++ oo 	   frL   ry   rz   rF   )setr   run)r   r>   s    @r?   test_run_in_trio_thread_kir      s[     UUF% % % % % %N 
I&'''eU^######rL   c                     g t                      dfddfddfd} t          j        |           }|                                 d	d
gk    sJ d S )Nr%   r&   c                    K                        d                                             t          j        d            d {V  d S )Nsleepingc                $    t           j        j        S r^   )r   Abort	SUCCEEDED)_s    r?   re   zMtest_await_in_trio_thread_while_main_exits.<locals>.trio_fn.<locals>.<lambda>   s    EK4I rL   )r6   r   r   wait_task_rescheduled)evr>   s   r?   trio_fnz;test_await_in_trio_thread_while_main_exits.<locals>.trio_fn   sS      j!!!
)*I*IJJJJJJJJJJJrL   r`   _core.TrioTokenc                    	 t          |            d S # t          j        $ r                     d           Y d S w xY w)Nr3   	cancelled)r   r   	Cancelledr6   )r`   r>   r   s    r?   	thread_fnz=test_await_in_trio_thread_while_main_exits.<locals>.thread_fn   sY    	'G666666 	' 	' 	'MM+&&&&&&	's    $>>threading.Threadc                    K   t          j                    } t          j        | f          }|                                                                  d {V  dgk    sJ |S )N)rA   argsr   )r   r_   r7   rG   r2   wait)r`   r   r   r>   r   s     r?   mainz8test_await_in_trio_thread_while_main_exits.<locals>.main   sj      (**!%BBBggii*%%%%rL   r   r   rF   )r`   r   r%   r&   )r%   r   )r   r   r   r   )r   r   r   r>   r   r   s     @@@@r?   *test_await_in_trio_thread_while_main_exitsr      s    F	BK K K K K K K
' ' ' ' ' ' '        Yt__F
KKMMMj+.......rL   c                 ^  K   d} d| z   fdddfd	t                     d {V  t          d 
           d {V  t           d| z                        d {V  dfd} |d           d {V   |d           d {V   |d           d {V   |d           d {V  d S )Nz0 from trio._tests.test_threads.test_named_threadinnernamestrr%   r   c                d    t          j                    j        | k    sJ t          j                    S r^   )r7   r8   r   )r   s    r?   r   z test_named_thread.<locals>.inner   s.    ')).$6666')))rL   "Callable[[None], threading.Thread]c                $    t          |           S r^   r   r   r   s    r?   rE   ztest_named_thread.<locals>.f       ud###rL   thread_namer&   c                   K   t           |           |            d {V }t          j        d|j                  sJ d S )Nr   Trio thread [0-9]*)r    rematchr   )r   r   rE   s     r?   test_thread_namez+test_named_thread.<locals>.test_thread_name   sT      )!!D''tDDDDDDDDDx,fk:::::::rL    fobiedooname_longer_than_15_characters   💙r   r   r%   r   r   r   r%   r   )r   r   r%   r&   r    )endingr   rE   r   s     @@r?   test_named_threadr      sv     ?F!F* * * * * *$ $ $ $ $ $ U
#
########
U
5
5
55555555 QQv//
0
00000000; ; ; ; ; ; 
2



:
&
&&&&&&&&

;
<
<<<<<<<<

6
"
""""""""""rL   ident
int | None
str | Nonec                F   dd l }dd l}|j                            d          }|st	          dt
          j         d           d S |                    |          }t          |dd           }|sJ |j	        |j
        |j        g|_        |j        |_        |                    dd          }| t!          j                    }  || |d          dk    sJ 	 |j                                        S # t(          $ r*}t+          j        d	|j        d
|            Y d }~d S d }~ww xY w)Nr   pthreadzno pthread on )pthread_getname_nprL      )sizezvalue: z, exception: )ctypesctypes.utilutilfind_libraryr:   rr   platformCDLLgetattrc_void_pc_char_pc_size_targtypesc_intrestypecreate_string_bufferr7   	get_identvaluedecodeUnicodeDecodeErrorrj   fail)r   r   libpthread_path
libpthreadr   name_bufferes          r?   _get_thread_namer      so   MMMk..y99O .s|...///t_--J -A4HH  	#
 "(--c-;;K}#%%e["55::::E ''))) E E ECk/CCCCDDDDDDDDDEs   C, ,
D 6DD c                 <  K   dddfdd} t           |                      d {V  t           |           d 	           d {V  ddfd} |d           d {V   |d           d {V   |d           d {V   |dd           d {V  d S )Nr   r   r%   r   c                    t                      }|2t          j        dk    r"t          j        dt          j                    n|| d d         k    sJ t          j                    S )Nlinuxzno pthread OS support on    )r   rr   r   rj   skipr7   r8   )r   os_thread_names     r?   r   z#test_named_thread_os.<locals>.inner  se    )++!clg&=&=KBCLBBCCCC!T#2#Y....')))rL   r   c                $    t          |           S r^   r   r   s    r?   rE   ztest_named_thread_os.<locals>.f  r   rL   z4None from trio._tests.test_threads.test_named_threadr   r,   r   r&   c                   K   || }t           |          |            d {V }t          |j                  }|
J d            t          j        d|          sJ d S )Nr   z'should skip earlier if this is the caser   )r    r   r   r   r   )r   r,   r   r   rE   s       r?   r   z.test_named_thread_os.<locals>.test_thread_name#  s      H)!!H++4HHHHHHHHH)&,77))+T)))x,n=======rL   r   r   r   r   ?)r,   r   r   r^   )r   r   r,   r   r%   r&   r   )defaultr   rE   r   s     @@r?   test_named_thread_osr     sT     * * * *$ $ $ $ $ $ EG
QQwZZ
(
((((((((
QQwZZT
:
:
::::::::> > > > > > > 
2



:
&
&&&&&&&&

;
<
<<<<<<<<

6C
0
0
0000000000rL   c                    K   ddl m}   |             }|5t          j        dk    sJ t	          j        dt          j                    d S d S )Nr   )get_os_thread_name_funcr   zno pthread_setname_np on )trio._core._thread_cacher   rr   r   rj   r   )r   ks     r?   test_has_pthread_setname_npr   3  sf      @@@@@@!!Ay|w&&&&>>>????? yrL   c                   K   t          j                    } dd}t          |d           d {V \  }}|dk    sJ || k    sJ dd}t          j        t
          d	
          5 }t          |           d {V  d d d            n# 1 swxY w Y   t          |j        j                   |j        j        d         | k    sJ d S )Nr<   r$   r%   tuple[T, threading.Thread]c                ,    | t          j                    fS r^   )r7   r8   )r<   s    r?   rE   z$test_run_in_worker_thread.<locals>.f?  s    9+--..rL      r   c                 B    t          t          j                              r^   )rU   r7   r8   rd   rL   r?   gz$test_run_in_worker_thread.<locals>.gF  s    133444rL   z1^<Thread\(Trio thread \d+, started daemon \d+\)>$r   r   )r<   r$   r%   r   )r%   r   )	r7   r8   r    rj   rk   rU   r:   r   r   )rJ   rE   r<   rI   r   excinfos         r?   test_run_in_worker_threadr   <  sI     *,,K/ / / / /q!44444444OA|6666;&&&&5 5 5 5 
N
 
 
 $	 #########$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 
'-
=a K//////s   "BBBc                   K   d gdfddfd	} g t          j                    }t          j                    4 d {V }|                    | |d
           t                       d {V  dgk    sJ |j                                         d d d           d {V  n# 1 d {V swxY w Y   d         dk    sJ |                    d            d         dk    r t          j
        d           d         dk     g d d<   t          j                    4 d {V }|                    | |d           t                       d {V  |j                                         t          j        d
          5  t          d          D ]}t          j                     d {V  	 d d d            n# 1 swxY w Y   dgk    sJ |                    d            d d d           d {V  n# 1 d {V swxY w Y   t          j                    5 }|                                  | |d           d {V  d d d            n# 1 swxY w Y   |j        sJ d S )Nqstdlib_queue.Queue[str]r%   r&   c                D    dd<   |                                   dd<   d S )Nblockingr   finished)get)r   registers    r?   rE   z1test_run_in_worker_thread_cancellation.<locals>.fT  s&     	 rL   stdlib_queue.Queue[None]abandon_on_cancelboolc                   K                        d           	 t          | |           d {V 	                      d           S #                      d           w xY w)Nr2   r   exit)r6   r    )r   r   rE   r>   s     r?   childz5test_run_in_worker_thread_cancellation.<locals>.childZ  ss      g	"+AqDUVVVVVVVVVVMM&!!!!FMM&!!!!s   A ATr2   r   r   rD   Fshield
   )r   r   r%   r&   )r   r   r   r   r%   r&   )stdlib_queueQueuer   open_nursery
start_soonr!   cancel_scopecancelputtimer   r   rangerY   cancelled_caught)r   r   nurseryr   scoperE   r>   r   s        @@@r?   &test_run_in_worker_thread_cancellationr  Q  sa     "&H! ! ! ! ! !" " " " " " " F"."4"6"6A!## & & & & & & &w5!T*** %&&&&&&&&&'""""##%%%& & & & & & & & & & & & & & & & & & & & & & & & & & & A;*$$$$EE$KKK
1+
#
#
4 1+
#
# FHQK!## 	 	 	 	 	 	 	w5!U+++$&&&&&&&&&##%%%d+++ 	) 	)2YY ) )&(((((((((()	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) '""""	d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 
			 eAuoo               !!!!!!s\   AB$$
B.1B.$AG2>,F7+G27F;	;G2>F;	?!G22
G<?G<'I		IIcapfdpytest.CaptureFixture[str]monkeypatchpytest.MonkeyPatchc                   |                     t          j        dd           t          j                    t          j                    dfddfd}t          j        |                               d                                            }|                                r(t          j
        d           |                                (|                                 \  }}d|vsJ d|vsJ d S )	NIDLE_TIMEOUTrD   r%   r&   c                 |                                                           t          j                               d S r^   )r   r  r7   r8   )q1q2s   r?   r   z6test_run_in_worker_thread_abandoned.<locals>.thread_fn  s1    

y'))*****rL   c                   K   dfd} t          j                    4 d {V }|                    |            t                       d {V  |j                                         d d d           d {V  d S # 1 d {V swxY w Y   d S )Nr%   r&   c                 :   K   t           d           d {V  d S )NTr   r   )r   s   r?   r   z@test_run_in_worker_thread_abandoned.<locals>.main.<locals>.child  s2      $Y$GGGGGGGGGGGGrL   rF   )r   r  r  r!   r  r  )r   r
  r   s     r?   r   z1test_run_in_worker_thread_abandoned.<locals>.main  s>     	H 	H 	H 	H 	H 	H %'' 	* 	* 	* 	* 	* 	* 	*7u%%%(********* '')))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s   AA99
BBzException in threadrF   )setattrr   _thread_cacher   r  r   r  r   rH   r  r   
readouterr)	r  r  r   r   outerrr  r  r   s	         @@@r?   #test_run_in_worker_thread_abandonedr    s!    +^TBBB#/#5#7#7B/;/A/C/CB+ + + + + + +* * * * * * 
IdOOOFF4LLL VVXXF
//

 
4 //

  !!HC ++++ ++++++rL   MAX)rX      r   r  FTuse_default_limiterrN   r   c                   
K   d| z  }t          j                    
t          j                    |rt                      }|j        }| |_        d nt          |           }| }|	  G d d          d_        d_        d_        d_	        t          j                    d
fd	dfd}t          j                    4 d {V }t          d           g }t          |          D ]S}	|                    t                                 |                    ||d                    t#                       d {V  TrCt          d           |d                                          d {V  t#                       d {V  j	        | k    s|                                j        | k    r=t+          d           d {V  j	        | k     |                                j        | k    =
                                 d d d           d {V  n# 1 d {V swxY w Y   j        | k    sJ r+|j        dk    r t+          d           d {V  |j        dk     j        |k    sJ j        dk    sJ 	 ||_        d S # ||_        w xY w)Nr   c                  8    e Zd ZU ded<   ded<   ded<   ded<   dS )0test_run_in_worker_thread_limiter.<locals>.staterN   ran
high_waterrx   parkedN)__name__
__module____qualname____annotations__rd   rL   r?   stater#    s4         HHHOOOLLLKKKKKrL   r+  r   r  r   r%   r&   c                   t          d           t          | j                   5  xj        dz  c_        xj        dz  c_        t          j        j                  _        xj        dz  c_        d d d            n# 1 swxY w Y                                    5  xj        dz  c_        xj        dz  c_        d d d            n# 1 swxY w Y   t          d           d S )Nzthread_fn startr3   r   zthread_fn exiting)	r:   r   r  r$  rx   maxr%  r&  r   )r  gatelockr+  r`   s    r?   r   z4test_run_in_worker_thread_limiter.<locals>.thread_fn  sl   #$$$ !4GGGG " "		Q		"#&u'7#G#G  !" " " " " " " " " " " " " " " IIKKK # #!"# # # # # # # # # # # # # # # %&&&&&s$   ABB	B	&!CCCeventr   c                   K   t          j                    5 }t          |           d {V  d d d            n# 1 swxY w Y   t          d|j                   |                                  d S )N)r   limiterzrun_thread finished, cancelled:)r   r   r    r:   r	  r   )r0  r  r  limiter_argr   s     r?   
run_threadz5test_run_in_worker_thread_limiter.<locals>.run_thread  s      "$$ ( &,'	                        3\5RSSSIIKKKKKs   =AAspawningz'waiting for first cancellation to clearrD   )r  r   r%   r&   )r0  r   r%   r&   )r7   r   Lockr   total_tokensr   r$  r%  rx   r&  r   r_   r  r:   r  r6   r  r!   r   
statisticstasks_waitingr   r   borrowed_tokens)r  r  r   COUNTcorig_total_tokensr4  r
  eventsr   r.  r3  r/  r+  r   r`   s    `        @@@@@@r?   !test_run_in_worker_thread_limiterr@    s      GE?D>D *,,NC  Y+	 	 	 	 	 	 	 	 	(**	' 	' 	' 	' 	' 	' 	' 	' 	' 		 		 		 		 		 		 		 		 %'' 	 	 	 	 	 	 	7*F5\\ / /egg&&&"":vbz:::,..........  /?@@@Qinn&&&&&&&&&,......... ,#%%)E)L)LDkk!!!!!!! ,#%%)E)L)L HHJJJ1	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	4 3&&&& 	" #a''Dkk!!!!!!! #a'' yE!!!!}!!!!!******s3   *A&J D3HJ 
HJ "H#AJ 	Jc                    K   g  G fdd          } t          d  |                        d {V  ddgk    sJ d S )Nc                  (    e Zd Zd fdZd fdZdS )	?test_run_in_worker_thread_custom_limiter.<locals>.CustomLimiterborrowerr#   r%   r&   c                D   K                        d           || _        d S Nacquirer6   	_borrowerselfrD  r>   s     r?   acquire_on_behalf_ofzTtest_run_in_worker_thread_custom_limiter.<locals>.CustomLimiter.acquire_on_behalf_of+  s$      MM)$$$%DNNNrL   c                L                         d           || j        k    sJ d S )NreleaserH  rJ  s     r?   release_on_behalf_ofzTtest_run_in_worker_thread_custom_limiter.<locals>.CustomLimiter.release_on_behalf_of/  s.    MM)$$$t~------rL   NrD  r#   r%   r&   r'  r(  r)  rL  rO  rQ   s   r?   CustomLimiterrC  *  sQ        	& 	& 	& 	& 	& 	&	. 	. 	. 	. 	. 	. 	. 	.rL   rR  c                     d S r^   rd   rd   rL   r?   re   z:test_run_in_worker_thread_custom_limiter.<locals>.<lambda>5  rf   rL   r2  rG  rN  r   )rR  r>   s    @r?   (test_run_in_worker_thread_custom_limiterrU  %  s       F. . . . . . . . . . \\==??
C
C
CCCCCCCCi+++++++rL   c                   K   g  G fdd          }  |             }t          j        t          d          5 }t          d |           d {V  d d d            n# 1 swxY w Y   |j        j        J ddgk    sJ g i t          j        t          d          5 }t          fd	|           d {V  d d d            n# 1 swxY w Y   t          |j        j        t                    sJ ddgk    sJ d S )
Nc                  (    e Zd Zd	 fdZd
 fdZdS )Ctest_run_in_worker_thread_limiter_error.<locals>.BadCapacityLimiterrD  r#   r%   r&   c                6   K                        d           d S rF  )r6   rJ  s     r?   rL  zXtest_run_in_worker_thread_limiter_error.<locals>.BadCapacityLimiter.acquire_on_behalf_of=  s      MM)$$$$$rL   r   c                L                         d           t          d          )NrN  zrelease on behalf)r6   rU   rJ  s     r?   rO  zXtest_run_in_worker_thread_limiter_error.<locals>.BadCapacityLimiter.release_on_behalf_of@  s$    MM)$$$0111rL   NrP  )rD  r#   r%   r   rQ  rQ   s   r?   BadCapacityLimiterrX  <  sQ        	% 	% 	% 	% 	% 	%	2 	2 	2 	2 	2 	2 	2 	2rL   r[  z^release on behalf$r   c                     d S r^   rd   rd   rL   r?   re   z9test_run_in_worker_thread_limiter_error.<locals>.<lambda>G       rL   rT  rG  rN  c                      d         S )Nr<   rd   )ds   r?   re   z9test_run_in_worker_thread_limiter_error.<locals>.<lambda>P  s    3 rL   )rj   rk   rU   r    r   __context__
isinstancer\   )r[  bsr   r_  r>   s      @@r?   'test_run_in_worker_thread_limiter_errorrc  9  s     F2 2 2 2 2 2 2 2 2 2 
			B	z)>	?	?	? ;7 r::::::::::; ; ; ; ; ; ; ; ; ; ; ; ; ; ;=$,,,i+++++F A	z)>	?	?	? =7 <<<<<<<<<<= = = = = = = = = = = = = = =gm/:::::i+++++++s#   A  A$'A$"C		CCc                l  K   dd}|                      t          j        j        d|           t	                      }|j        dk    sJ t          j        t                    5 }t          d	            d {V  d d d            n# 1 swxY w Y   d
t          |j                  v sJ |j        dk    sJ d S )NrK  objectr   r%   r   c                     t          d          )Nz!the engines canna take it captain)rl   )rK  r   s     r?   	bad_startz:test_run_in_worker_thread_fail_to_spawn.<locals>.bad_startY  s    >???rL   start_thread_soonr   c                     d S r^   rd   rd   rL   r?   re   z9test_run_in_worker_thread_fail_to_spawn.<locals>.<lambda>c  r]  rL   engines)rK  re  r   re  r%   r   )r  r   r  ThreadCacher   r;  rj   rk   rl   r    r   r   )r  rg  r2  r   s       r?   'test_run_in_worker_thread_fail_to_spawnrl  U  s     @ @ @ @ +79LiXXX,..G"a'''' 
|	$	$ / ........./ / / / / / / / / / / / / / /GM******"a''''''s   !BBBc                 r   K   dd} t          j                    }t          |            d {V }||k    sJ d S )Nr%   r   c                 8    t          t          j                  } | S r^   r   r   r_   callee_tokens    r?   r   z5test_trio_to_thread_run_sync_token.<locals>.thread_fnl      +E,DEErL   r%   r   r   r_   r    r   caller_tokenrq  s      r?   "test_trio_to_thread_run_sync_tokenrw  i  `          +--L+I66666666L<''''''rL   c                    K   dd} t          j        t          d          5  t          |            d {V  d d d            d S # 1 swxY w Y   d S )Nr%   r&   c                 
   K   d S r^   rd   rd   rL   r?   async_fnz=test_trio_to_thread_run_sync_expected_error.<locals>.async_fnw  ri   rL   zexpected a sync functionr   rF   )rj   rk   	TypeErrorr    r{  s    r?   +test_trio_to_thread_run_sync_expected_errorr~  u  s          
y(B	C	C	C + + *********+ + + + + + + + + + + + + + + + + +s   AA	A	trio_test_contextvarzcontextvars.ContextVar[str]c                   K   t          j                    } t                              d           d
d}t	          |           d {V \  }}|dk    sJ || k    sJ dd}t	          |           d {V \  }}}t                                          }|dk    sJ |dk    sJ |dk    s
J d            t          j                    d	k    sJ d S )Nr   r%   tuple[str, threading.Thread]c                     t                                           } t          j        t          j                  5  t	          j                     d d d            n# 1 swxY w Y   | t          j                    fS r^   )	r  r   rj   rk   sniffioAsyncLibraryNotFoundErrorcurrent_async_libraryr7   r8   )r   s    r?   rE   z3test_trio_to_thread_run_sync_contextvars.<locals>.f  s    $((**]7<== 	, 	,)+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,y/1122s   AAA!tuple[str, str, threading.Thread]c                 X   t                                           } t                               d           t                                           }t          j        t
          j                  5  t          j                     d d d            n# 1 swxY w Y   | |t          j	                    fS )Nworker)
r  r   r   rj   rk   r  r  r  r7   r8   )parent_valueinner_values     r?   r   z3test_trio_to_thread_run_sync_contextvars.<locals>.g  s    +//11  ****..00]7<== 	, 	,)+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, $&&
 	
s   +BBBr  zRThe contextvar value set on the worker would not propagate back to the main threadtrio)r%   r  )r%   r  )r7   r8   r  r   r    r   r  r  )rJ   rE   r   rI   r   r  r  current_values           r?   (test_trio_to_thread_run_sync_contextvarsr    s0     *,,KV$$$3 3 3 3 !31 5 5555555E<F????;&&&&

 

 

 

 5Gq4I4I.I.I.I.I.I.I+L+|(,,..M6!!!!(""""F"""	 #"" (**f444444rL   c                   K   d	d} t          |            d {V }t          |t                    sJ d
dd
fd}t          j        t
          d          5  t          |           d {V  d d d            d S # 1 swxY w Y   d S )Nr%   floatc                 8    t          t          j                  } | S r^   )r   r   current_time)	trio_times    r?   thread_fn_1z3test_trio_from_thread_run_sync.<locals>.thread_fn_1  s    ();<<	rL   r&   c                 
   K   d S r^   rd   rd   rL   r?   r{  z0test_trio_from_thread_run_sync.<locals>.async_fn  ri   rL   c                 &    t                      d S r^   )r   r}  s   r?   thread_fn_2z3test_trio_from_thread_run_sync.<locals>.thread_fn_2  s    X&&&&&rL   zexpected a synchronous functionr   )r%   r  rF   )r    ra  r  rj   rk   r|  )r  r  r  r{  s      @r?   test_trio_from_thread_run_syncr    s          )55555555Ii'''''   ' ' ' ' ' ' 
y(I	J	J	J . . ---------. . . . . . . . . . . . . . . . . .s   A<<B B c                   K   g d
fdd
fd} t          |            d {V  ddgk    sJ d
d}t          j        t          d	          5  t          t          |           d {V  d d d            d S # 1 swxY w Y   d S )Nr%   r&   c                 \   K   t          j                                          d           d S )Nback in trio)r   r  r6   rQ   s   r?   back_in_trio_fnz2test_trio_from_thread_run.<locals>.back_in_trio_fn  s.      n%%%%%rL   c                 P                         d           t                      d S )N	in thread)r6   r   )r  r>   s   r?   r   z,test_trio_from_thread_run.<locals>.thread_fn  s)    k"""(((((rL   r  r  c                     d S r^   rd   rd   rL   r?   sync_fnz*test_trio_from_thread_run.<locals>.sync_fn  s    rL   zappears to be synchronousr   rF   )r    rj   rk   r|  r   )r   r  r  r>   s     @@r?   test_trio_from_thread_runr    s:      F& & & & & &) ) ) ) ) ) ) Y
'
''''''''k>22222    
y(C	D	D	D ; ; ':::::::::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s   A;;A?A?c                 r   K   dd} t          j                    }t          |            d {V }||k    sJ d S )Nr%   r   c                 8    t          t          j                  } | S r^   ro  rp  s    r?   r   z.test_trio_from_thread_token.<locals>.thread_fn  rr  rL   rs  rt  ru  s      r?   test_trio_from_thread_tokenr    rx  rL   c                 t   K   dd} t          j                    }t          | |           d {V }||k    sJ d S )Nr`   r   r%   c                <    t          t          j        |           }|S )Nr3   ro  )r`   rq  s     r?   r   z4test_trio_from_thread_token_kwarg.<locals>.thread_fn  s    +E,DQVWWWrL   )r`   r   r%   r   rt  ru  s      r?   !test_trio_from_thread_token_kwargr    sb          +--L+I|DDDDDDDDL<''''''rL   c                    K   t          j        t                    5  t          t          j                   d d d            d S # 1 swxY w Y   d S r^   rj   rk   rl   r   r   r  rd   rL   r?   test_from_thread_no_tokenr    s       
|	$	$ 1 1U/0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s   AA
Ac                 B  K   t                               d           dd} t          |            d {V \  }}}}}t                                           }||cxk    rdk    sn J ||cxk    r|cxk    rdk    sn J t	          j                    dk    sJ |dk    sJ d S )	Nr   r%   tuple[str, str, str, str, str]c                 *   t                                           } t                               d           t                                           }t          j        t
          j                  5  t          j                     d d d            n# 1 swxY w Y   dd}t          |          \  }}t                                           }t          j        t
          j                  5  t          j                     d d d            n# 1 swxY w Y   | ||||fS )Nr  r%   tuple[str, str]c                     t                                           } t                               d           t                                           }t          j                    dk    sJ | |fS Nback_in_mainr  r  r   r   r  r  back_parent_valueback_current_values     r?   r  zStest_trio_from_thread_run_sync_contextvars.<locals>.thread_fn.<locals>.back_in_main  s`     4 8 8 : : $$^444!5!9!9!;!;022f<<<<$&888rL   r%   r  )	r  r   r   rj   rk   r  r  r  r   )thread_parent_valuethread_current_valuer  r  r  thread_after_values         r?   r   z=test_trio_from_thread_run_sync_contextvars.<locals>.thread_fn  s   26688  ***37799]7<== 	, 	,)+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,	9 	9 	9 	9 1E\0R0R--15577]7<== 	, 	,)+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,   
 	
$   +BBB#DD
Dr  r  r  r%   r  r  r   r    r   r  r  r   r  r  r  r  r  r  s          r?   *test_trio_from_thread_run_sync_contextvarsr    s      V$$$
 
 
 
@ !++++++++(,,..M/99996999999#4VVVV8JVVVVhVVVVVV(**f4444//////rL   c                 B  K   t                               d           dd} t          |            d {V \  }}}}}t                                           }||cxk    rdk    sn J ||cxk    r|cxk    rdk    sn J |dk    sJ t	          j                    dk    sJ d S )	Nr   r%   r  c                 *   t                                           } t                               d           t                                           }t          j        t
          j                  5  t          j                     d d d            n# 1 swxY w Y   dd}t          |          \  }}t                                           }t          j        t
          j                  5  t          j                     d d d            n# 1 swxY w Y   | ||||fS )Nr  r%   r  c                    K   t                                           } t                               d           t                                           }t          j                    dk    sJ | |fS r  r  r  s     r?   async_back_in_mainzTtest_trio_from_thread_run_contextvars.<locals>.thread_fn.<locals>.async_back_in_main*  sd       4 8 8 : : $$^444!5!9!9!;!;022f<<<<$&888rL   r  )	r  r   r   rj   rk   r  r  r  r   )r  r  r  r  r  r  s         r?   r   z8test_trio_from_thread_run_contextvars.<locals>.thread_fn#  s   26688  ***37799]7<== 	, 	,)+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,	9 	9 	9 	9 1@@R0S0S--15577]7<== 	, 	,)+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,   
 	
r  r  r  r  r  r  r  s          r?   %test_trio_from_thread_run_contextvarsr     s      V$$$
 
 
 
@ !++++++++(,,..M/99996999999#4VVVV8JVVVVhVVVVVV////(**f444444rL   c                     t          j        t                    5  t          t          j        d           d d d            d S # 1 swxY w Y   d S )NzNot TrioTokentyper3   r  rd   rL   r?   4test_run_fn_as_system_task_catched_badly_typed_tokenr  K  s    	|	$	$ 
 
*	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   AA
Ac                    K   dd} t          j                    }t          j        t                    5  t          | |           d d d            d S # 1 swxY w Y   d S )Nr%   r&   c                     t                      r^   )AssertionErrorrd   rL   r?   
not_calledz7test_from_thread_inside_trio_thread.<locals>.not_calledT  s    rL   r3   rF   )r   r_   rj   rk   rl   r   )r  r.   s     r?   #test_from_thread_inside_trio_threadr  S  s          )++J	|	$	$ @ @ZJ????@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @s   AAAc                     g g dfddfd	} t          j        | d
           t          j        | d           ddgk    sJ d S )Nr`   r/   r%   AsyncGenerator[None, None]c                 K   	 d W V  t          j        d          5  	 t          t          t          t
          d|                      d {V                      d           n*# t           j        $ r                     d           Y nw xY wd d d            d S # 1 swxY w Y   d S # t          j        d          5  	 t          t          t          t
          d|                      d {V                      d           n*# t           j        $ r                     d           Y nw xY wd d d            w # 1 swxY w Y   w xY w)NTr   r   r3   cleanr   )r   r   r    r   r   r   r6   RunFinishedError)r`   r>   s    r?   agenz2test_from_thread_run_during_shutdown.<locals>.agen`  s0     	+EEEE"$/// + ++,eLLL         MM'**** - . . .MM*-----.+ + + + + + + + + + + + + + + + + +"$/// + ++,eLLL         MM'**** - . . .MM*-----.+ + + + + + + + + + + + + + + +s   B+ B0A'B'$BBBBB"%B"+ED?0D	3D?	$D0	-D?/D0	0D?3E?EEEEuse_system_taskr   r&   c                   K                         | rt          j                    nd                      d                             d            d {V  d S )Nr6  )r6   r   r_   asend)r  r  saves    r?   r   z2test_from_thread_run_during_shutdown.<locals>.mainn  sd      DDP1333DQQRRR2hnnT"""""""""""rL   TFr   r  )r`   r/   r%   r  )r  r   r%   r&   )r   r   )r   r  r>   r  s    @@@r?   $test_from_thread_run_during_shutdownr  \  s    DF+ + + + + +# # # # # # # 
IdD	IdEj'*******rL   c                    K   t          j                    } t          | t           j                  sJ t	          j        |           }|  |            u sJ d S r^   )r   r_   ra  	TrioTokenweakrefref)r`   weak_references     r?   "test_trio_token_weak_referenceabler  w  sZ      $&&EeU_-----[''NNN$$$$$$$$rL   c                    K    G d d          } t          j        t                    5  t          t           |                        d {V  d d d            d S # 1 swxY w Y   d S )Nc                      e Zd ZddZdS )4test_unsafe_abandon_on_cancel_kwarg.<locals>.BadBoolr%   r   c                    t           r^   )NotImplementedError)rK  s    r?   __bool__z=test_unsafe_abandon_on_cancel_kwarg.<locals>.BadBool.__bool__  s    %%rL   Nr%   r   )r'  r(  r)  r  rd   rL   r?   BadBoolr    s(        	& 	& 	& 	& 	& 	&rL   r  r   )rj   rk   r  r    rN   )r  s    r?   #test_unsafe_abandon_on_cancel_kwargr  ~  s      & & & & & & & & 
*	+	+ C C 		BBBBBBBBBBC C C C C C C C C C C C C C C C C Cs   %AA"Ac                    K   t          j                    } dd}| t          t          t           j                   d {V u sJ | t          t          |           d {V u sJ d S )Nr%   
_core.Taskc                 ,   K   t          j                    S r^   )r   current_taskrd   rL   r?   async_current_taskz8test_from_thread_reuses_task.<locals>.async_current_task  s      !###rL   )r%   r  )r   r  r    r   r   )taskr  s     r?   test_from_thread_reuses_taskr    s      D$ $ $ $ +,@%BTUUUUUUUUUUUU+O=OPPPPPPPPPPPPPPrL   c                 R   K   d dfd} t          |            d {V k    sJ d S )Nr%   rN   c                 h    t          j                     t          t          t           j                  S r^   )r7   r   r   r    )tids   r?   get_tid_then_reenterz6test_recursive_to_thread.<locals>.get_tid_then_reenter  s%    !##193FGGGrL   )r%   rN   r   )r  r  s    @r?   test_recursive_to_threadr    se      
CH H H H H H *+?@@@@@@@@@@@@@@rL   c                 Z  K   t          j                    dfd} t          j                    5 t	          |            d {V  d d d            n# 1 swxY w Y   j        rJ                                 rJ t          j                    5 t	          | d           d {V  d d d            n# 1 swxY w Y   j        sJ t	          t          j        d                     d {V rJ dd	dfd
}t          j                    5 t	          |           d {V  d d d            n# 1 swxY w Y   j        rJ                                 rJ t          j                    5 t	          |d           d {V  d d d            n# 1 swxY w Y   j        sJ t	          t          j        d                     d {V rJ dfd}t          j                    5 t	          t          |           d {V  d d d            n# 1 swxY w Y   j        sJ d S )Nr%   r&   c                     t           j                   	 t          t                                         d           d S # t          j        $ r                     d           Y d S w xY wNFT)r   r  r   r  r   r   )r  queues   r?   
sync_checkz3test_from_thread_host_cancelled.<locals>.sync_check  su    \0111	 &&& IIe  	 	 	IIdOOOOOO	s   A $A*)A*Tr   r   timeoutr   c                 
   K   dS )NTrd   rd   rL   r?   no_checkpointz6test_from_thread_host_cancelled.<locals>.no_checkpoint  s      trL   c                     t           j                   	 t                    sJ 	                     d           d S # t          j        $ r                     d           Y d S w xY wr  )r   r  r   r  r   r   )r  r  r  s   r?   async_checkz4test_from_thread_host_cancelled.<locals>.async_check  s~    \0111	"=111111 IIe  	 	 	IIdOOOOOO	s   A   $A('A(c                    K                                      t          d          5  t                       d {V  d d d            d S # 1 swxY w Y   d S )Nr   )r  r   r   )r  s   r?   async_time_bombz8test_from_thread_host_cancelled.<locals>.async_time_bomb  s      ^^ 	" 	"//!!!!!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s   A		AArF   r  )
r   r  r   r   r    r	  
get_nowaitr   r   r   )r  r  r  r  r  r  s      @@@r?   test_from_thread_host_cancelledr    sP     &2&8&:&:E       
			 - ,,,,,,,,,- - - - - - - - - - - - - - - ,,,,!!!!!				 E tDDDDDDDDDDE E E E E E E E E E E E E E E (((('	1(E(E(EFFFFFFFFFFF           
			 . ---------. . . . . . . . . . . . . . . ,,,,!!!!!				 F EEEEEEEEEEF F F F F F F F F F F F F F F (((('	1(E(E(EFFFFFFFFFFF" " " " " "
 
			 C /BBBBBBBBBC C C C C C C C C C C C C C C ((((((sY   AAAB66B:=B:D66D:=D:3FFF/HHHc                   K   t          j                    dfd} dfdg t          j                    t	          j                    4 d {V }|                    | d	t	          j                               t                       d {V  d
         dk    sJ 	                    d          dk    sJ 
                                 d d d           d {V  n# 1 d {V swxY w Y   d         dk    sJ g t          j                    t	          j                    }t	          j                    4 d {V }|                    | d	|           t                       d {V  d
         dk    sJ 	                    d          dk    sJ |                                 
                                 d d d           d {V  n# 1 d {V swxY w Y   |j        sJ dv sJ d         dk    sJ dfdg t          j                    t	          j                    }t	          j                    4 d {V }|                    | d|           t                       d {V  d
         dk    sJ |                                 
                                 d d d           d {V  n# 1 d {V swxY w Y   |j        sJ dv sJ d         dk    sJ 	                    d          dk    sJ d S )Nr   r   r  r   r%   r&   c                L  K   |5                       d           	 t          |            d {V 	                      d           cd d d            S # t          j        $ r                      d            w xY w#                      d           w xY w# 1 swxY w Y   d S )Nr2   r   r   r  )r6   r    r   r   )r   r  rE   r>   s     r?   r   z/test_from_thread_check_cancelled.<locals>.child  s      	& 	&MM'"""&/EVWWWWWWWWWW
 f%%%	& 	& 	& 	& 	& 	& 	& 	& ?   h''' f%%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	&s3   BAB&A<<A??BBB Bc                     	 t                                           d           n*# t          j        $ r                     d           Y nw xY w                                  t                      S NNot Cancelledr   )r   r  r   r   r   r   r   s   r?   rE   z+test_from_thread_check_cancelled.<locals>.f  s}    	#'))) EE/""""  	 	 	EE+	 				*,,,s   ' $AAFr   r2   r   r  r  r   r  r6  c                                                        	 t                                           d           d S # t          j        $ r                     d           Y d S w xY wr  )r   r   r  r   r   r  s   r?   rE   z+test_from_thread_check_cancelled.<locals>.f  su    
				#'))) EE/"""""  	 	 	EE+	s   < $A$#A$Tr   )r   r   r  r   r%   r&   rF   )r   r  r7   r   r   r  r  r   r!   r   r   r  r	  )r   r
  r  r   rE   r   r>   s      @@@@r?    test_from_thread_check_cancelledr    s     !-!3!5!5A	& 	& 	& 	& 	& 	& 	&- - - - - - - F			B!##       w5%):)<)<===$&&&&&&&&&ayG####uuQu?2222
                           !9 F			BE!##       w5%///$&&&&&&&&&ayG####uuQu?2222
                           !!!!v":# # # # # # # F			BE!##       w5$...$&&&&&&&&&ayG####
                           !!!!v":555{******s9   A;C##
C-0C-A>G
G G	A"J==
K
Kc                    K   t          j        t                    5  t                       d d d            n# 1 swxY w Y   t	          j                     t          j        t           fd           t          j        t                    5                       d          	                                 d d d            d S # 1 swxY w Y   d S )Nc                .                         |           S r^   )r  )r   r   s    r?   re   zLtest_from_thread_check_cancelled_raises_in_foreign_threads.<locals>.<lambda>,  s    15588 rL   r   r  )
rj   rk   rl   r   r   r  r   rh  r   unwrap)r   s   @r?   :test_from_thread_check_cancelled_raises_in_foreign_threadsr
  (  s8     	|	$	$ & &#%%%& & & & & & & & & & & & & & &-9-?-A-AA	79K9K9K9KLLL	|	$	$ " "	a!!!" " " " " " " " " " " " " " " " " "s   8<<)CC	Cc                 ,  K   dd} t          d          5  t          j                    4 d {V }t          d          D ]}|                    |            	 d d d           d {V  n# 1 d {V swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr%   r&   c                 P   K   	 t          t          t          dd           d {V  $)NTr   Fr   )r    r   r   rd   rL   r?   r   z+test_reentry_doesnt_deadlock.<locals>.child7  s<      	Y$_eQRWXXXXXXXXXX	YrL   r      rF   )r   r   r  r  r  )r   r
  r   s      r?   test_reentry_doesnt_deadlockr  1  s~     Y Y Y Y 
q		 * *%'' 	* 	* 	* 	* 	* 	* 	*71XX * *""5))))*	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	** * * * * * * * * * * * * * * * * *s4   B	(A+B	+
A5	5B	8A5	9B		BBc                 L  K   t          j        t          d          5  t          t          dd           d {V  d d d            n# 1 swxY w Y   t          j        t          d          5  t          t          dd           d {V  d d d            d S # 1 swxY w Y   d S )NzC^Cannot set `cancellable` and `abandon_on_cancel` simultaneously\.$r   TF)cancellabler   )rj   rk   rU   r    r   rd   rL   r?   #test_cancellable_and_abandon_raisesr  A  sr     	T
 
 
 R R !45QQQQQQQQQQ	R R R R R R R R R R R R R R R 
T
 
 
 Q Q !44PPPPPPPPPP	Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Qs#   AAA.BB Bc                 @  K   t          j        t                    5  t          t          d           d {V  d d d            n# 1 swxY w Y   t          j        t                    5  t          t          d           d {V  d d d            d S # 1 swxY w Y   d S )NF)r  T)rj   warnsr   r    r   rd   rL   r?   test_cancellable_warnsr  O  s-     	,	-	- : : 59999999999: : : : : : : : : : : : : : : 
,	-	- 9 9 488888888889 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9s#   AA	A	)BBBrF   r^   )r   r   r%   r   )r  r  r  r  r%   r&   )r  rN   r  r   r   r   r%   r&   )r  r  r%   r&   )c
__future__r   contextvarsr  r   r   rr   r7   r  r  	functoolsr   typingr   r   r   r	   r
   r   r   r   r   r   rj   r  r   r   r   r   r   r   r   r   r   r   _core._tests.test_kir   _core._tests.tutilr   _threadsr   r   r   r   r    testingr!   outcomer"   lowlevelr#   r   rG   r9   rM   r$   ra   rm   r   r   r   r   r   r   r   r  r  markparametrizer@  rU  rc  rl  rw  r~  
ContextVarr  r*  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r  r  r  rd   rL   r?   <module>r"     s*   " " " " " " "         				 



                                     
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 + * * * * * % % % % % %              - , , , , ,  %U9#3T-5H#HIIJK
GCLL9Q 9Q 9Q 9Qx   -$ -$ -$ -$`/ / / /8# # # #:E E E E EL 1  1  1  1F@ @ @ @0 0 0 0*6" 6" 6" 6"x", ", ", ",J 


++E4=11.>>m+ m+ m+ ?> 21 ,+m+`, , , ,(, , , ,8( ( ( ((	( 	( 	( 	(+ + + + 5KK4J5 5     
"5 "5 "5 "5J. . . .*; ; ; ;0	( 	( 	( 	(	( 	( 	( 	(1 1 1 1(0 (0 (0 (0V(5 (5 (5 (5V
 
 
 
@ @ @ @+ + + +6% % % %C C C CQ Q Q Q	A 	A 	A 	A8) 8) 8) 8)vK+ K+ K+ K+\" " " " * * * *Q Q Q Q9 9 9 9 9 9rL   