|
Server : LiteSpeed System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64 User : nandedex ( 1060) PHP Version : 8.1.33 Disable Function : NONE Directory : /opt/cppython/lib/python3.8/test/__pycache__/ |
U
>��gq � @ s d Z ddlZddlZddlmZmZ ddlZddlZddlZddl m
Z
dd� ZG dd� de�Z
G d d
� d
ej�ZG dd� de�ZG d
d� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZdS )z/
Various tests for synchronization primitives.
� N)�start_new_thread�TIMEOUT_MAX)�supportc C s t �d� d S )N�{�G�z�?)�time�sleep� r r �./opt/cppython/lib/python3.8/test/lock_tests.py�_wait s r
c @ s2 e Zd ZdZddd�Zdd� Zdd� Zd d
� ZdS )
�Bunchz
A bunch of threads.
Fc sx � �_ |�_g �_g �_| �_t�� �_�j�� � �fdd�}zt |�D ]}t
|d� qLW n d�_� Y nX dS )z�
Construct a bunch of `n` threads running the same function `f`.
If `wait_before_exit` is True, the threads won't terminate until
do_finish() is called.
c s@ t �� } �j�| � z
� � W 5 �j�| � �js:t� q,X d S �N)� threading� get_ident�started�append�finished� _can_exitr
)�tid��f�selfr r �task% s
zBunch.__init__.<locals>.taskr TN)r �nr r r r �wait_threads_exit�wait_thread� __enter__�ranger )r r r Zwait_before_exitr �ir r r �__init__ s
zBunch.__init__c C s t | j�| jk rt� q d S r )�lenr r r
�r r r r �wait_for_started6 s zBunch.wait_for_startedc C s, t | j�| jk rt� q | j�d d d � d S r )r r r r
r �__exit__r r r r �wait_for_finished: s zBunch.wait_for_finishedc C s
d| _ d S �NT)r r r r r � do_finish@ s zBunch.do_finishN)F)�__name__�
__module__�__qualname__�__doc__r r! r# r% r r r r r s
r c @ s$ e Zd Zdd� Zdd� Zdd� ZdS )�BaseTestCasec C s t �� | _d S r )r Zthreading_setup�_threadsr r r r �setUpE s zBaseTestCase.setUpc C s t j| j� t �� d S r )r Zthreading_cleanupr+ �
reap_childrenr r r r �tearDownH s zBaseTestCase.tearDownc C s$ | � ||d � | �||d � d S )Ng333333�?g $@)ZassertGreaterEqual�
assertLess)r �actualZexpectedr r r �
assertTimeoutL s zBaseTestCase.assertTimeoutN)r&