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

�Ke8
����dZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZej
sejd���Gd�de
��Zd�Zed	krej��dSdS)
z.This test checks for correct fork() behavior.
�N)�ForkWait)�supportz$test module requires working os.forkc��eZdZd�Zd�ZdS)�ForkTestc������	�tj���d�d�	d�����	fd�}tj|���}|�������d}tj��}	|s^t���}|�krtj|��n_tj
dkrtd��tjd��n+|���|�
||�	��	tj|tj��d
S#t"$rYd
SwxYw#	tj|tj��w#t"$rYwwxYwxYw)zFCheck fork() in main thread works while a subthread is doing an importzfake test module�partial�completec����tj���tj�<����tjd���tj�<tj��dS)Ng{�G�z�?)�imp�acquire_lock�sys�modules�set�time�sleep�release_lock)�complete_module�fake_module_name�import_started�partial_modules�����9/usr/local/apps/python3/lib/python3.11/test/test_fork1.py�importerz9ForkTest.test_threaded_import_lock_fork.<locals>.importersc��������,:�C�K�(�)���� � � ��J�t����,;�C�K�(�)��������)�target�*�z Child encountered partial module��exitcodeN)�	threading�Event�Thread�start�wait�os�fork�
__import__�_exitr�verbose�print�join�	wait_impl�kill�signal�SIGKILL�OSError)
�selfr�tr�pid�mrrrrs
      @@@@r�test_threaded_import_lock_forkz'ForkTest.test_threaded_import_lock_forks�������"��*�*��-��"��$��	�	�	�	�	�	�	�	�
��H�-�-�-��	���	�	�	����������g�i�i��	��

7��/�0�0����'�'��H�X�&�&�&�&����*�*��@�A�A�A��H�Q�K�K�K�K����������s�X��6�6�6�
����V�^�,�,�,�,�,���
�
�
����
�����
����V�^�,�,�,�,���
�
�
���
������sC�9BD7�D&�&
D4�3D4�7E)�9E�E)�
E&�#E)�%E&�&E)c�T���d���fd�}td��D]
}||���dS)zJCheck fork() in main thread works while the main thread is doing an importrc���d}d}		t|��D]}tj��|dz
}�tj��}|}t|��D]}tj���n*#t|��D]}tj���wxYwnD#t$r7|r3tjdkrtd��tj
d���wxYw|rtj
�����|����dS)NrFrzRuntimeError in childr)�rangerrr$r%r�RuntimeErrorrr(r)r'r+)�level�release�in_child�ir2rr0s     ��r�fork_with_import_lockzDForkTest.test_nested_import_lock_fork.<locals>.fork_with_import_lockEs=����G��H�
�+�"�5�\�\�%�%���(�*�*�*��1�����'�)�)�C�#&�w�H�"�7�^�^�+�+���(�*�*�*�*�+��U�7�^�^�+�+���(�*�*�*�*�+����+���
�
�
�� ����*�*��5�6�6�6��H�Q�K�K�K��
�����
#����"�"�"��N�N�3��N�2�2�2�2�2s�AA.�&B�.'B�B�AC�N)r7)r0r=r9rs`  @r�test_nested_import_lock_forkz%ForkTest.test_nested_import_lock_forkAs\������	3�	3�	3�	3�	3�	3�2�1�X�X�	)�	)�E�!�!�%�(�(�(�(�	)�	)rN)�__name__�
__module__�__qualname__r4r?�rrrrs3������(�(�(�V)�)�)�)�)rrc�,�tj��dS)N)r�
reap_childrenrCrr�tearDownModulerFbs��������r�__main__)�__doc__�_imprr$r-r
rr�unittest�test.fork_waitr�testr�has_fork_support�SkipTestrrFr@�mainrCrr�<module>rPs��������	�	�	�	�
�
�
�
�
�
�
�
�������������#�#�#�#�#�#���������D�
�(�
�B�
C�
C�C�J)�J)�J)�J)�J)�x�J)�J)�J)�Z����z����H�M�O�O�O�O�O��r