Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/lock_tests.cpython-311.pyc |
�
�Ke�} � �� � d Z ddlZddlZddlZddlZddlmZmZ ddlZddl Z ddl
Z
ddlmZ ddl
mZ e j ej d� � Zd� Z G d� d e� � Z G d
� de j � � Z G d� d
e� � Z G d� de� � Z G d� de� � Z G d� de� � Z G d� de� � Z G d� de� � Z G d� de� � Z G d� de� � Z G d� de� � ZdS )z/
Various tests for synchronization primitives.
� N)�start_new_thread�TIMEOUT_MAX)�support)�threading_helperz9platform doesn't support fork (no _at_fork_reinit method)c �. � t j d� � d S )N�{�G�z�?)�time�sleep� � �9/usr/local/apps/python3/lib/python3.11/test/lock_tests.py�_waitr s � ��J�t�����r c �, � e Zd ZdZdd�Zd� Zd� Zd� ZdS ) �Bunchz
A bunch of threads.
Fc � � �� �� _ |� _ g � _ g � _ | � _ t j � � � _ � j � � � �� fd�} t |� � D ]}t |d� � �dS # d� _ � xY w)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 �^ �� t j � � } �j � | � � �� � �j � | � � �j st
� � �j �d S d S # �j � | � � �j st
� � �j �w xY w�N)� threading� get_ident�started�append�finished� _can_exitr )�tid�f�selfs ��r
�taskzBunch.__init__.<locals>.task- s� �� ��%�'�'�C��L����$�$�$�
�������
�$�$�S�)�)�)��.� ��G�G�G� �.� � � � � �� �
�$�$�S�)�)�)��.� ��G�G�G� �.� � � � � s �
A4 �48B,r TN)r �nr r r r �wait_threads_exit�wait_thread� __enter__�ranger )r r r �wait_before_exitr �is `` r
�__init__zBunch.__init__ s� ��� � �����������
�-�-���+�=�?�?�����"�"�$�$�$� � � � � � � ��1�X�X�
+�
+�� ��r�*�*�*�*�
+�
+�� �!�D�N����s �"B �
B
c � � t | j � � | j k r-t � � t | j � � | j k �+d S d S r )�lenr r r �r s r
�wait_for_startedzBunch.wait_for_started>