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

�Ke���|�dZddlZddlZddlZddlZddlZddlmZddlm	Z	dZ
dZdZGd�d	ej
��ZdS)
arThis test case provides support for checking forking and wait behavior.

To test different wait behavior, override the wait_impl method.

We want fork1() semantics -- only the forking thread survives in the
child after a fork().

On some systems (e.g. Solaris without posix threads) we find that all
active threads survive in the child after a fork(); this is an error.
�N)�support)�threading_helper�g�?�c�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�ForkWaitc�`�tj��|_i|_d|_g|_dS)Nr)r�threading_setup�_threading_key�alive�stop�threads)�selfs �8/usr/local/apps/python3/lib/python3.11/test/fork_wait.py�setUpzForkWait.setUps,��.�>�@�@�����
���	������c��d|_|jD]}|����d}|j���t	j|j�dS)N�)r
r�join�clearr�threading_cleanupr)r�threads  r�tearDownzForkWait.tearDownsY����	��l�	�	�F��K�K�M�M�M�M�����������*�D�,?�@�@�@�@rc��|jsOtj��|j|<	t	jt��n#t$rYnwxYw|j�MdSdS)N)r
�os�getpidr�time�sleep�
SHORTSLEEP�OSError)r�ids  r�fz
ForkWait.f'su���)�	��Y�[�[�D�J�r�N�
��
�:�&�&�&�&���
�
�
���
����	�)�	�	�	�	�	s�>�
A�
Ac�2�tj||���dS)N��exitcode)r�wait_process)r�cpidr%s   r�	wait_implzForkWait.wait_impl/s����T�H�5�5�5�5�5�5rc��tt��D]L}tj|j|f���}|���|j�|���Mtj	��tjz}t|j
��tkrItjd��|tj	��krnt|j
��tk�It|j
�����}|�|t%tt������|j
���}t(jdvrt-j��}nt-j��}|dkrWtjt2��d}|j
D]}|j
|||kr|dz
}�t-j|��dS|�|d���dS)N)�target�argsg�������?)�	unixware7rrr$)�range�NUM_THREADS�	threading�Threadr"�startr�appendr�	monotonicr�
SHORT_TIMEOUT�lenrr�sorted�keys�assertEqual�list�copy�sys�platformr�fork1�fork�	LONGSLEEP�_exitr()	r�ir�deadline�a�
prefork_livesr'�n�keys	         r�	test_waitzForkWait.test_wait2s����{�#�#�	(�	(�A��%�T�V�1�$�?�?�?�F��L�L�N�N�N��L����'�'�'�'��>�#�#�g�&;�;���$�*�o�o��+�+��J�s�O�O�O��$�.�*�*�*�*���$�*�o�o��+�+�

�4�:�?�?�$�$�%�%������D��{�!3�!3�4�4�5�5�5��
���)�)�
��<�=�(�(��8�:�:�D�D��7�9�9�D��1�9�9��J�y�!�!�!��A��z�
�
���:�c�?�m�C�&8�8�8���F�A���H�Q�K�K�K�K�K�
�N�N�4�!�N�,�,�,�,�,rN)�__name__�
__module__�__qualname__rrr"r(rG�rrrrsb���������A�A�A����6�6�6�!-�!-�!-�!-�!-rr)�__doc__rr;r�unittestr/�testr�test.supportrr?rr.�TestCaserrKrr�<module>rQs���	�	���������������������������)�)�)�)�)�)�
�	�
�
���=-�=-�=-�=-�=-�x� �=-�=-�=-�=-�=-r