Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_fork1.cpython-310.pyc

o

0�i��@s�dZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZe�
ed�Gdd�de
�Zdd	�Zed
krFe��dSdS)z.This test checks for correct fork() behavior.
�N)�ForkWait)�support�forkc@seZdZdd�Zdd�ZdS)�ForkTestcs�t���d�d�d�����fdd�}tj|d�}|�����d}t��}z@|sGt��}|�kr8t�|�nt	j
dkrAtd	�t�d�n|��|j
||d
�Wz
t�|tj�WdStygYdSwz	t�|tj�WwtyzYww)zFCheck fork() in main thread works while a subthread is doing an importzfake test module�partialZcompletecs:t���tj�<���t�d��tj�<t��dS)Ng{�G�z�?)�imp�acquire_lock�sys�modules�set�time�sleep�release_lock��Zcomplete_moduleZfake_module_nameZimport_startedZpartial_moduler�6/opt/alt/python310/lib64/python3.10/test/test_fork1.py�importers


z9ForkTest.test_threaded_import_lock_fork.<locals>.importer)�target�*�z Child encountered partial module��exitcodeN)�	threadingZEventZThread�start�wait�osr�
__import__�_exitr�verbose�print�join�	wait_impl�kill�signal�SIGKILL�OSError)�selfr�tr�pid�mrrr�test_threaded_import_lock_forks>
����z'ForkTest.test_threaded_import_lock_forkcs,d���fdd�}td�D]}||�q
dS)zJCheck fork() in main thread works while the main thread is doing an importrc	s�d}d}z2z#t|�D]
}t��|d7}q
t��}|}Wt|�D]}t��q!nt|�D]}t��q-wWntyN|rMtjdkrHt	d�t�
d��w|rVt�
���j|�d�dS)NrFrzRuntimeError in childr)�rangerrrrr�RuntimeErrorrrrrr!)�level�releaseZin_child�ir(�rr&rr�fork_with_import_lockCs0

�
�

�
zDForkTest.test_nested_import_lock_fork.<locals>.fork_with_import_lock�N)r+)r&r1r-rr0r�test_nested_import_lock_fork?s

�z%ForkTest.test_nested_import_lock_forkN)�__name__�
__module__�__qualname__r*r3rrrrrs+rcCst��dS)N)rZ
reap_childrenrrrr�tearDownModule`sr7�__main__)�__doc__�_imprrr#r	rrZunittestZtest.fork_waitr�testrZ
get_attributerr7r4�mainrrrr�<module>s M�