Nexus File Manager
v2.0
🏠
Dashboard
⚡
System
🌐
›
opt
›
alt
›
python38
›
lib64
›
python3.8
›
test
›
__pycache__
Quick:
⬆️ Parent
🌐 Root
🏠 Home
🌍 WWW
📁 Temp
⚙️ Etc
📤 Upload
📁 Create
⚡ WordPress Admin
🔄 Refresh
✏️ test_threadedtempfile.cpython-38.pyc
← Back
U i�fj � @ s� d Z ddlZddlmZ ddlZddlZddlZddlmZ dZ dZ e�� ZG dd� dej �ZG d d � d ej�Zedkr�e�� dS )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)� start_threads)� print_exc� �2 c @ s e Zd ZdZdZdd� ZdS )�TempFileGreedyr c C sp t �� | _t�� tt�D ]P}zt�d�}|� � W n& | j d7 _ t| jd� Y qX | jd7 _qd S )Nzw+b� )�file) �io�StringIO�errors� startEvent�wait�range�FILES_PER_THREAD�tempfileZ TemporaryFile�close�error_countr �ok_count)�self�i�f� r �?/opt/alt/python38/lib64/python3.8/test/test_threadedtempfile.py�run$ s zTempFileGreedy.runN)�__name__� __module__�__qualname__r r r r r r r r s r c @ s e Zd Zdd� ZdS )�ThreadedTempFileTestc C s� dd� t t�D �}t|tj�� W 5 Q R X tdd� |D ��}dd� |D �}dt|�|d�|�f }| �|g |� | �|tt � d S )Nc S s g | ] }t � �qS r )r )�.0r r r r � <listcomp>4 s z2ThreadedTempFileTest.test_main.<locals>.<listcomp>c s s | ]}|j V qd S )N)r �r �tr r r � <genexpr>7 s z1ThreadedTempFileTest.test_main.<locals>.<genexpr>c S s* g | ]"}|j rt|j�t|j�� � �qS r )r �str�namer �getvaluer r r r r 8 s �zErrors: errors %d ok %d %s� ) r �NUM_THREADSr r �set�sum�len�joinZassertEqualr )r Zthreads�okr �msgr r r � test_main3 s � �zThreadedTempFileTest.test_mainN)r r r r. r r r r r 2 s r �__main__)�__doc__r Ztest.supportr Zunittestr Z threading� tracebackr r'