
    0hh                         S r SSKrSSKJr  SSKJr  SSKrSSKrSSKrSSK	J
r
  \R                  " SS9  SrS	r\R                  " 5       r " S
 S\R                   5      r " S S\R$                  5      r\S:X  a  \R*                  " 5         gg)an  
Create and delete FILES_PER_THREAD temp files (via tempfile.TemporaryFile)
in each of NUM_THREADS threads, recording the number of successes and
failures.  A failure is a bug in tempfile, and may be due to:

+ Trying to create more than one tempfile with the same name.
+ Trying to delete a tempfile that doesn't still exist.
+ Something we've never seen before.

By default, NUM_THREADS == 20 and FILES_PER_THREAD == 50.  This is enough to
create about 150 failures per run under Win98SE in 2.0, and runs pretty
quickly. Guido reports needing to boost FILES_PER_THREAD to 500 before
provoking a 2.0 failure under Linux.
    N)support)threading_helper)	print_excT)module   2   c                   "    \ rS rSrSrSrS rSrg)TempFileGreedy"   r   c                 d   [         R                  " 5       U l        [        R	                  5         [        [        5       H?  n [        R                  " S5      nUR                  5         U =R                  S-  sl
        MA     g !   U =R                  S-  sl        [        U R                  S9   Mq  = f)Nzw+b   )file)ioStringIOerrors
startEventwaitrangeFILES_PER_THREADtempfileTemporaryFilecloseok_counterror_countr   )selfifs      C/opt/python-3.13.8/usr/lib/python3.13/test/test_threadedtempfile.pyrunTempFileGreedy.run&   s{    kkm'(A#**51	
 " ),  A% t{{+s   &B*B/)r   N)__name__
__module____qualname____firstlineno__r   r   r   __static_attributes__     r   r
   r
   "   s    KH#r'   r
   c                   D    \ rS rSr\R
                  " \SSS9S 5       rSrg)ThreadedTempFileTest4   i  F)sizememusedry_runc                 `   [        [        5       Vs/ s H  n[        5       PM     nn[        R                  " U[
        R                  5          S S S 5        [        S U 5       5      nU Vs/ s HN  oUR                  (       d  M  [        UR                  5      [        UR                  R                  5       5      -   PMP     nnS[        U5      USR                  U5      4-  nU R                  U/ U5        U R                  U[        [         -  5        g s  snf ! , (       d  f       N= fs  snf )Nc              3   8   #    U  H  oR                   v   M     g 7f)N)r   ).0ts     r   	<genexpr>1ThreadedTempFileTest.test_main.<locals>.<genexpr>:   s     -WWs   zErrors: errors %d ok %d
%s
)r   NUM_THREADSr
   r   start_threadsr   setsumr   strnamer   getvaluelenjoinassertEqualr   )r   r+   r   threadsokr1   r   msgs           r   	test_mainThreadedTempFileTest.test_main5   s    -2;-?@-?>#-?@++GZ^^D E-W--"5"amm 9#aff+AHH$5$5$7 88" 	 5 ,s6{BIIf/ S)[+;;< ADD5s   DD-D+=D+
D(r&   N)	r!   r"   r#   r$   r   
bigmemtestr5   rB   r%   r&   r'   r   r)   r)   4   s$    [5I= J=r'   r)   __main__)__doc__r   testr   test.supportr   unittestr   	threading	tracebackr   requires_working_threadingr5   r   Eventr   Threadr
   TestCaser)   r!   mainr&   r'   r   <module>rQ      s      )  	    + +4 8  __
#Y%% #$=8,, = zMMO r'   