Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_threadedtempfile.cpython-311.pyc
�

�Ke����dZddlZddlmZddlZddlZddlZddlmZej	d���dZ
dZej��Z
Gd	�d
ej��ZGd�dej��Zed
krej��dSdS)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)�threading_helper)�	print_excT)�module��2c��eZdZdZdZd�ZdS)�TempFileGreedyrc�`�tj��|_t���tt��D]g}	tjd��}|�	��|xj
dz
c_
�<#|xjdz
c_t|j���Y�exYwdS)Nzw+b�)�file)
�io�StringIO�errors�
startEvent�wait�range�FILES_PER_THREAD�tempfile�
TemporaryFile�close�ok_count�error_countr)�self�i�fs   �D/usr/local/apps/python3/lib/python3.11/test/test_threadedtempfile.py�runzTempFileGreedy.run%s����k�m�m����������'�(�(�	#�	#�A�
#��*�5�1�1�����	�	�	�
�
�
��"�
�
�
��	
,�� � �A�%� � ��t�{�+�+�+�+�+�+����
	#�	#s�	(B�'B+N)�__name__�
__module__�__qualname__rrr��rr	r	!s-�������K��H�#�#�#�#�#r"r	c��eZdZd�ZdS)�ThreadedTempFileTestc��d�tt��D��}tj|tj��5	ddd��n#1swxYwYt
d�|D����}d�|D��}dt|��|d�|��fz}|�	|g|��|�	|ttz��dS)Nc�*�g|]}t����Sr!)r	)�.0rs  r�
<listcomp>z2ThreadedTempFileTest.test_main.<locals>.<listcomp>5s��@�@�@��>�#�#�@�@�@r"c3�$K�|]}|jV��dS)N)r�r'�ts  r�	<genexpr>z1ThreadedTempFileTest.test_main.<locals>.<genexpr>8s$����-�-����-�-�-�-�-�-r"c��g|]D}|j�	t|j��t|j�����z��ESr!)r�str�namer�getvaluer*s  rr(z2ThreadedTempFileTest.test_main.<locals>.<listcomp>9sQ��5�5�5��a�m�5�#�a�f�+�+��A�H�$5�$5�$7�$7� 8� 8�8�5�5�5r"zErrors: errors %d ok %d
%s�
)r�NUM_THREADSr�
start_threadsr�set�sum�len�join�assertEqualr)r�threads�okr�msgs     r�	test_mainzThreadedTempFileTest.test_main4s(��@�@�U�;�-?�-?�@�@�@��
�
+�G�Z�^�
D�
D�	�	��	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�-�-�W�-�-�-�
-�
-��5�5�"�5�5�5��,�s�6�{�{�B��I�I�f���/��������S�)�)�)�����[�+;�;�<�<�<�<�<s�A�A�AN)rrr r<r!r"rr$r$3s#������=�=�=�=�=r"r$�__main__)�__doc__r�test.supportr�unittestr
�	threading�	tracebackr�requires_working_threadingr2r�Eventr�Threadr	�TestCaser$r�mainr!r"r�<module>rHs��
�
�����)�)�)�)�)�)�����	�	�	�	�����������+��+�4�8�8�8�8������Y�_�
�
�
�#�#�#�#�#�Y�%�#�#�#�$=�=�=�=�=�8�,�=�=�=��z����H�M�O�O�O�O�O��r"