+
    öÙ†jØ#  ã                   ó  € ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt R t	R t
R t]P                  RR l4       tRR lt]P                  RR l4       t ! R	 R
4      tR R lt]! 4       tRR/R ltRR/ 3R ltR# )é    N)Úsupportc                  ó^   € \         P                  ! 4       \        \        P                  4      3# ©N)Ú_threadÚ_countÚlenÚ	threadingÚ	_dangling© ó    Ú4/usr/lib/python3.14/test/support/threading_helper.pyÚthreading_setupr      s   € Ü�>Š>ÓœS¤×!4Ñ!4Ó5Ð5Ð5r   c                  óx  € V w  rR p\         P                  ! VRR7       F:  p\        \        P                  4      p\
        P                  ! 4       pWa8:  g   K9   R# 	  R\         n        \         P                  ! RVR RV RV R	X R\        X4       2
4       V F  p\         P                  ! R
V: 24       K  	  R# )g      ð?F©ÚerrorNTz2threading_cleanup() failed to clean up threads in ú.1fz  seconds
  before: thread count=z, dangling=z
  after: thread count=zDangling thread: )
r   Úsleeping_retryÚlistr	   r
   r   r   Úenvironment_alteredÚprint_warningr   )Úoriginal_valuesÚ
orig_countÚorig_ndanglingÚtimeoutÚ_Údangling_threadsÚcountÚthreads   *       r   Úthreading_cleanupr      sÄ   € Ø!0Ñ€Jà€GÜ×#Ò# G°5×9ˆô  ¤	× 3Ñ 3Ó4ÐÜ—’Ó ˆàÖÚñ :ð #'„GÔÜ×ÒðØ�cˆ]ð "Ø", ¨[¸Ð8Hð I!Ø!&  {´3Ð7GÓ3HÐ2Ið	KôLó
 #ˆÜ×ÒÐ 1°&±Ð<Ö=ó #r   c                óF   a € \         P                  ! S 4      V 3R l4       pV# )z{Use this function when threads are being used.  This will
ensure that the threads are cleaned up even when the test fails.
c                  óT   <€ \        4       p S! V !  \        V!   #   \        T!   i ; ir   )r   r   )ÚargsÚkeyÚfuncs   * €r   Ú	decoratorÚreap_threads.<locals>.decorator>   s)   ø€ äÓˆð	$Ù˜‘;ä˜sÓ#øÔ˜sÓ#ús   � œ')Ú	functoolsÚwraps)r$   r%   s   f r   Úreap_threadsr)   :   s(   ø€ ô ‡_‚_�TÓô$ó ð$ð Ðr   c              #  ó   "  € V f   \         P                  p \        P                  ! 4       p Rx € \        P
                  ! 4       p\         P                  ! V RR7       F6  p\         P                  ! 4        \        P                  ! 4       pWA8:  g   K5   R# 	  \        P
                  ! 4       V,
          pRXV,
           RVR RV RV R	2	p\        V4      h  \        P
                  ! 4       p\         P                  ! T RR7       F5  p\         P                  ! 4        \        P                  ! 4       pYA8:  g   K5   i 	  \        P
                  ! 4       T,
          pRXT,
           RTR RT RT R	2	p\        T4      h; i5i)
a   
bpo-31234: Context manager to wait until all threads created in the with
statement exit.

Use _thread.count() to check if threads exited. Indirectly, wait until
threads exit the internal t_bootstrap() C function of the _thread module.

threading_setup() and threading_cleanup() are designed to emit a warning
if a test leaves running threads in the background. This context manager
is designed to cleanup threads started by the _thread.start_new_thread()
which doesn't allow to wait for thread exit, whereas thread.Thread has a
join() method.
NFr   z!wait_threads() failed to cleanup z threads after r   z seconds (count: z, old count: Ú))	r   ÚSHORT_TIMEOUTr   r   ÚtimeÚ	monotonicr   Ú
gc_collectÚAssertionError)r   Ú	old_countÚ
start_timer   r   ÚdtÚmsgs   &      r   Úwait_threads_exitr5   H   s\  é € ð ‚Ü×'Ñ'ˆÜ—’Ó €Ið&Ûä—^’^Ó%ˆ
Ü×'Ò'¨°u×=ˆAÜ×ÒÔ Ü—N’NÓ$ˆEØÖ!Úñ	 >ô —’Ó! JÕ.ˆBØ6°u¸yÕ7HÐ6Ið J$Ø$& s 8ð ,Ø#˜W M°)°¸Að?ˆCô ! Ó%Ð%øô —^’^Ó%ˆ
Ü×'Ò'¨°u×=ˆAÜ×ÒÔ Ü—N’NÓ$ˆEØÖ!Ùñ	 >ô —’Ó! JÕ.ˆBØ6°u¸yÕ7HÐ6Ið J$Ø$& s 8ð ,Ø#˜W M°)°¸Að?ˆCô ! Ó%Ð%üs+   ‚*E>­C ±AE>ÂAE>ÃAE;Ä9AE;Å;E>c                ó    € Vf   \         P                  pV P                  V4       V P                  4       '       d   RVR R2p\	        V4      hR# )z[Join a thread. Raise an AssertionError if the thread is still alive
after timeout seconds.
Nzfailed to join the thread in r   z seconds)r   r,   ÚjoinÚis_aliver0   )r   r   r4   s   && r   Újoin_threadr9   k   sM   € ð ‚Ü×'Ñ'ˆØ
‡K�K�ÔØ‡�×ÒØ-¨g°c¨]¸(ÐCˆÜ˜SÓ!Ð!ñ r   c              #   ó¨  "  €  ^ RI p\        V 4      p . p  V  F$  pVP                  4        VP	                  V4       K&  	  Rx €  T'       d   T! 4        \        P                  ! 4       p\        ^^4       F±  pT^<,          pT F8  pTP                  \        T\        P                  ! 4       ,
          R4      4       K:  	  T Uu. uF  qDP                  4       '       g   K  TNK  	  ppT'       g    M9\
        P                  '       g   K”  \        R\        T4      T3,          4       K³  	  T Uu. uF  qDP                  4       '       g   K  TNK  	  ppT'       d?   Te    TP                  \         P"                  4       \%        R\        T4      ,          4      hR#   \         d    Rp EL£i ; i   \
        P                  '       d'   \        R\        T 4      \        T4      3,          4       h ; iu upi u upi   T Uu. uF  qDP                  4       '       g   K  TNK  	  Mu upi ppT'       d?   Te    TP                  \         P"                  4       \%        R\        T4      ,          4      hi ; i   T'       d   T! 4        \        P                  ! 4       p\        ^^4       F·  pT^<,          pT F8  pTP                  \        T\        P                  ! 4       ,
          R4      4       K:  	  T Uu. uF  qDP                  4       '       g   K  TNK  	  Mu upi ppT'       g    M9\
        P                  '       g   Kš  \        R\        T4      T3,          4       K¹  	  T Uu. uF  qDP                  4       '       g   K  TNK  	  Mu upi ppT'       d?   Te    TP                  \         P"                  4       \%        R\        T4      ,          4      hi   T Uu. uF  qDP                  4       '       g   K  TNK  	  Mu upi ppT'       d?   Te    TP                  \         P"                  4       \%        R\        T4      ,          4      hi ; i; i5i)r   Nz/Can't start %d threads, only %d threads startedg{®Gáz„?z7Unable to join %d threads during a period of %d minuteszUnable to join %d threads)ÚfaulthandlerÚImportErrorr   ÚstartÚappendr   ÚverboseÚprintr   r-   r.   Úranger7   Úmaxr8   Údump_tracebackÚsysÚstdoutr0   )ÚthreadsÚunlockr;   ÚstartedÚtÚendtimer   s   &&     r   Ústart_threadsrK   w   sD  é € ðÛô �7‹m€GØ€GðQð	Û�Ø—‘”	Ø—‘˜qÖ!ñ ó 	ð	QßÙ”Ü—n’nÓ&ˆGÜ   Bž<�Ø˜2•�Û �AØ—F‘Fœ3˜w¬¯ªÓ)9Õ9¸4Ó@ÖAñ !á&-Ó>¡g ·±·Ÿ1˜1¡g�Ð>ßÙÜ—?—?’?Üð 'Ü*-¨g«,¸Ð)@õAö Bñ (ñ #*Ó:¡'˜Q¯Z©Z¯\—q�q¡'ˆGÐ:ßØÒ+Ø ×/Ñ/´·
±
Ô;Ü$Ð%@Ä3ÀwÃ<Õ%OÓPÐPñ øôC ô à‹ðûð	Ü��ˆÜÐGÜ˜7“|¤S¨£\Ð2õ3ô 4àüò ?ùò ;ø¡'Ó:¡'˜Q¯Z©Z¯\—q�q¢'ùÒ:ˆGÐ:ßØÒ+Ø ×/Ñ/´·
±
Ô;Ü$Ð%@Ä3ÀwÃ<Õ%OÓPÐPð ûð!	QßÙ”Ü—n’nÓ&ˆGÜ   Bž<�Ø˜2•�Û �AØ—F‘Fœ3˜w¬¯ªÓ)9Õ9¸4Ó@ÖAñ !á&-Ó>¡g ·±·Ÿ1˜1¢gùÒ>�Ð>ßÙÜ—?—?’?Üð 'Ü*-¨g«,¸Ð)@õAö Bñ (ñ #*Ó:¡'˜Q¯Z©Z¯\—q�q¢'ùÒ:ˆGÐ:ßØÒ+Ø ×/Ñ/´·
±
Ô;Ü$Ð%@Ä3ÀwÃ<Õ%OÓPÐPð øñ #*Ó:¡'˜Q¯Z©Z¯\—q�q¢'ùÒ:ˆGÐ:ßØÒ+Ø ×/Ñ/´·
±
Ô;Ü$Ð%@Ä3ÀwÃ<Õ%OÓPÐPð ÿs  ‚Q„F ˆQ—*F/ ÁI4 ÁA>G; ÃG1Ã G1Ã&G; Ä
!G; Ä+QÄ/G6ÅG6ÅA
QÆF,Æ(QÆ+F,Æ,QÆ/?G.Ç.I4 Ç1G; Ç6QÇ;I1È H#ÈH#È"AI1É1QÉ4QÉ6A>OË4L
ÌL
Ì%OÍ !OÍ!QÍ%NÎNÎAQÏQÏO>Ï7O>Ï=AQÑQÑQc                   ó<   a € ] tR t^¢t o RtR tR tR tR tRt	V t
R# )Úcatch_threading_exceptiona¼  
Context manager catching threading.Thread exception using
threading.excepthook.

Attributes set when an exception is caught:

* exc_type
* exc_value
* exc_traceback
* thread

See threading.excepthook() documentation for these attributes.

These attributes are deleted at the context manager exit.

Usage:

    with threading_helper.catch_threading_exception() as cm:
        # code spawning a thread which raises an exception
        ...

        # check the thread exception, use cm attributes:
        # exc_type, exc_value, exc_traceback, thread
        ...

    # exc_type, exc_value, exc_traceback, thread attributes of cm no longer
    # exists at this point
    # (to avoid reference cycles)
c                óL   € R V n         R V n        R V n        R V n        R V n        R # r   )Úexc_typeÚ	exc_valueÚexc_tracebackr   Ú	_old_hook©Úselfs   &r   Ú__init__Ú"catch_threading_exception.__init__Á   s&   € ØˆŒØˆŒØ!ˆÔØˆŒØˆŽr   c                óŽ   € VP                   V n         VP                  V n        VP                  V n        VP                  V n        R # r   )rO   rP   rQ   r   )rT   r"   s   &&r   Ú_hookÚcatch_threading_exception._hookÈ   s1   € ØŸ™ˆŒØŸ™ˆŒØ!×/Ñ/ˆÔØ—k‘kˆŽr   c                óZ   € \         P                  V n        V P                  \         n        V # r   )r	   Ú
excepthookrR   rX   rS   s   &r   Ú	__enter__Ú#catch_threading_exception.__enter__Î   s    € Ü"×-Ñ-ˆŒØ#Ÿz™zŒ	ÔØˆr   c                ó@   € V P                   \        n        V =V =V =V =R # r   )rR   r	   r[   rO   rP   rQ   r   )rT   Úexc_infos   &*r   Ú__exit__Ú"catch_threading_exception.__exit__Ó   s#   € Ø#Ÿ~™~Œ	ÔØˆMØˆNØÐØŠKr   )rR   rQ   rO   rP   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rU   rX   r\   r`   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   rM   rM   ¢   s#   ø‡ € ñò<ò"ò÷
ð r   rM   c                ó$   € V ^8„  d   QhR\         /# )é   Úreturn)Úbool)Úformats   "r   Ú__annotate__ro   Û   s   € ÷ ñ œ4ñ r   c                 ó’   € \         P                  R8X  d   \         P                  P                  # \         P                  R8X  d   R# R# )a]  Detect whether Python can start new threads.

Some WebAssembly platforms do not provide a working pthread
implementation. Thread support is stubbed and any attempt
to create a new thread fails.

- wasm32-wasi does not have threading.
- wasm32-emscripten can be compiled with or without pthread
  support (-s USE_PTHREADS / __EMSCRIPTEN_PTHREADS__).
Ú
emscriptenÚwasiFT)rD   ÚplatformÚ_emscripten_infoÚpthreadsr   r   r   Ú_can_start_threadrv   Û   s6   € ô ‡|�|�|Ô#Ü×#Ñ#×,Ñ,Ð,Ü	�‰˜Ô	Ùñ r   ÚmoduleFc                ó”   € RpV '       d%   \         '       g   \        P                  ! V4      hR# \        P                  ! \         V4      # )z~Skip tests or modules that require working threading.

Can be used as a function/class decorator or to skip an entire module.
zrequires threading supportN)Úcan_start_threadÚunittestÚSkipTestÚ
skipUnless)rw   r4   s   $ r   Úrequires_working_threadingr}   ð   s>   € ð
 '€CßßÓÜ×#Ò# CÓ(Ð(ñ  ô ×"Ò"Ô#3°SÓ9Ð9r   c                ó  a	€ ^ RI Hp Vf   \        V 4      p\        W4      '       g   V .V,          p \        V 4      V8X  g   Q h\        P
                  ! V4      o	V	3R lp\        4       ;_uu_ 4       pV  Uu. uF  p\        P                  ! WW.VO5VR7      NK!  	  pp\        V4      ;_uu_ 4         RRR4       VP                  e   VP                  h RRR4       R# u upi   + '       g   i     L:; i  + '       g   i     R# ; i)zÆ
Run the worker function(s) concurrently in multiple threads.

If `worker_func` is a single callable, it is used for all threads.
If it is a list of callables, each callable is used for one thread.
)ÚIterableNc                 ó8   <€ SP                  4        V ! V/ VB  R # r   )Úwait)r$   r"   ÚkwargsÚbarriers   &*,€r   Úwrapper_funcÚ&run_concurrently.<locals>.wrapper_func  s   ø€ à�‰ŒÙˆdÐ�fÔr   )Útargetr"   r‚   )
Úcollections.abcr   r   Ú
isinstancer	   ÚBarrierrM   ÚThreadrK   rP   )
Úworker_funcÚnthreadsr"   r‚   r   r„   Úcmr$   Úworkersrƒ   s
   &&&&     @r   Úrun_concurrentlyr�   ý   së   ø€ õ )àÒÜ�{Ó#ˆÜ�k×,Ò,Ø"�m hÕ.ˆÜˆ{Ó˜xÔ'Ð'Ð'ä×Ò Ó)€Gõô
 
#×	$Ô	$¨ñ $ó
á#�ô ×Ò L°}¸t±}ÈV×TÙ#ð 	ð 
ô ˜7×#Õ#Ø÷ $ð �<‰<Ò#Ø—,‘,Ðð $÷ 
%Ñ	$ùò
÷ $×#ú÷ 
%×	$Ð	$ús6   Á2C8Á7%C ÂC8Â1C%	Â3"C8Ã C8Ã%C5Ã0C8Ã8D		r   r   )r   Ú
contextlibr'   rD   r	   r-   rz   Útestr   r   r   r)   Úcontextmanagerr5   r9   rK   rM   rv   ry   r}   r�   r   r   r   Ú<module>r“      sž   ðÛ Û Û Û 
Û Û Û å ò6ò>ò<ð ×Ñó&ó ð&ôD	"ð ×Ñó'Qó ð'Q÷T6ñ 6õrñ& %Ó&Ð ð
:¨ô 
:ð ,0°bÀö  r   