Your IP : 216.73.216.196


Current Path : /opt/alt/python37/lib64/python3.7/test/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/test/__pycache__/test_fork1.cpython-37.pyc

B

� f��@s�dZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZm
Z
mZmZe
ed�Gdd�de
�Zdd	�Zed
kr�e��dS)z.This test checks for correct fork() behavior.
�N)�ForkWait)�
reap_children�
get_attribute�
import_module�verbose�forkc@s$eZdZdd�Zdd�Zdd�ZdS)�ForkTestcCsrt��d}x6t��|krBt�|tj�\}}||kr6Pt�d�qW|�||�|�|dd|d@|d?f�dS)Ng$@g�������?rzcause = %d, exit = %d��)�timeZ	monotonic�os�waitpid�WNOHANG�sleepZassertEqual)�selfZcpidZdeadlineZspidZstatus�r�4/opt/alt/python37/lib64/python3.7/test/test_fork1.py�	wait_implszForkTest.wait_implcs�t���d�d�d�����fdd�}tj|d�}|�����t��}zR|s�t��}|�krlt�d�q�t	dkr|t
d	�t�d�n|��|�|�Wd
yt�
|tj�Wntk
r�YnXXd
S)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�setrr�release_lockr)�complete_module�fake_module_name�import_started�partial_modulerr�importer(s


z9ForkTest.test_threaded_import_lock_fork.<locals>.importer)�targetr�z Child encountered partial moduleN)�	threadingZEventZThread�start�waitrr�
__import__�_exitr�print�joinr�kill�signal�SIGKILL�OSError)rr�t�pid�mr)rrrrr�test_threaded_import_lock_fork"s.z'ForkTest.test_threaded_import_lock_forkcs*�fdd�}xtd�D]}||�qWdS)zJCheck fork() in main thread works while the main thread is doing an importc	s�d}d}yVz4x t|�D]}t��|d7}qWt��}|}Wdxt|�D]}t��qJWXWn4tk
r�|r�tdkr�td�t�	d��YnX|r�t�	d���
|�dS)NrFr!zRuntimeError in child)�rangerrrrr�RuntimeErrorrr'r&r)�level�releaseZin_child�ir.)rrr�fork_with_import_lockOs(


zDForkTest.test_nested_import_lock_fork.<locals>.fork_with_import_lock�N)r1)rr6r3r)rr�test_nested_import_lock_forkLsz%ForkTest.test_nested_import_lock_forkN)�__name__�
__module__�__qualname__rr0r8rrrrrs
*rcCs
t�dS)N)rrrrr�tearDownModulelsr<�__main__)�__doc__�_imprrr*rr"rZunittestZtest.fork_waitrZtest.supportrrrrrr<r9�mainrrrr�<module>s
X