Sindbad~EG File Manager
a
��gNx � @ s( d Z ddlZddlZddlZddlZddlmZmZ ddlZddl Z ddl
Z
ddlmZ e �
eed�d�Zdd� ZG d d
� d
e�ZG dd� de j�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�ZG dd� de�ZdS )z/
Various tests for synchronization primitives.
� N)�start_new_thread�TIMEOUT_MAX)�support�forkz9platform doesn't support fork (no _at_fork_reinit method)c C s t �d� d S )N�{�G�z�?)�time�sleep� r r �+/usr/local/lib/python3.9/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 n0 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 sZ t �� } �j�| � z$� � W �j�| � �jsVt� q*n�j�| � �jsTt� qF0 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_started= 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_finishedA s zBunch.wait_for_finishedc C s
d| _ d S �NT)r r! r r r
� do_finishG s zBunch.do_finishN)F)�__name__�
__module__�__qualname__�__doc__r r"