o
    HXh~                     @   s   	 d dl Z d dlmZ d dlZd dlZd dlZd dlmZ dZdZ	e
 ZG dd dejZG dd	 d	ejZed
krAe  dS dS )    N)threading_helper)	print_exc   2   c                   @   s   e Zd ZdZdZdd ZdS )TempFileGreedyr   c                 C   sn   t  | _t  ttD ]'}ztd}|	  W n   |  j
d7  _
t| jd Y q|  jd7  _qd S )Nzw+b   )file)ioStringIOerrors
startEventwaitrangeFILES_PER_THREADtempfileTemporaryFilecloseerror_countr   ok_count)selfif r   D/opt/python-3.10.19/usr/lib/python3.10/test/test_threadedtempfile.pyrun$   s   

zTempFileGreedy.runN)__name__
__module____qualname__r   r   r   r   r   r   r   r       s    r   c                   @   s   e Zd Zdd ZdS )ThreadedTempFileTestc                 C   s   dd t tD }t|tj W d    n1 sw   Y  tdd |D }dd |D }dt||d|f }| 	|g | | 	|tt
  d S )Nc                 S   s   g | ]}t  qS r   )r   ).0r   r   r   r   
<listcomp>4   s    z2ThreadedTempFileTest.test_main.<locals>.<listcomp>c                 s   s    | ]}|j V  qd S )N)r   r   tr   r   r   	<genexpr>7   s    z1ThreadedTempFileTest.test_main.<locals>.<genexpr>c                 S   s*   g | ]}|j rt|jt|j  qS r   )r   strnamer   getvaluer!   r   r   r   r    8   s    zErrors: errors %d ok %d
%s
)r   NUM_THREADSr   Zstart_threadsr   setsumlenjoinZassertEqualr   )r   threadsokr   msgr   r   r   	test_main3   s   
zThreadedTempFileTest.test_mainN)r   r   r   r0   r   r   r   r   r   2   s    r   __main__)r   Ztest.supportr   Zunittestr	   	threading	tracebackr   r(   r   Eventr   Threadr   ZTestCaser   r   mainr   r   r   r   <module>   s    