Your IP : 216.73.216.60


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_fork1.cpython-35.opt-1.pyc



��Yf��@s�dZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
mZe
d�Zeed�Gdd�de	�Zd	d
�Zedkr�ej�dS)z.This test checks for correct fork() behavior.
�N)�ForkWait)�
reap_children�
get_attribute�
import_module�verbose�	threading�forkc@s4eZdZdd�Zdd�Zdd�ZdS)�ForkTestcCs�tj�d}xKtj�|kr]tj|tj�\}}||krMPtjd�qW|j||�|j|dd|d@|d?f�dS)Ng$@g�������?rzcause = %d, exit = %d��)�timeZ	monotonic�os�waitpid�WNOHANG�sleepZassertEqual)�selfZcpidZdeadlineZspidZstatus�r�4/opt/alt/python35/lib64/python3.5/test/test_fork1.py�	wait_implszForkTest.wait_implcstj��d�d�d�����fdd�}tjd|�}|j��j�tj�}zo|s�t��}|�kr�tjd�q�t	dkr�t
d	�tjd�n|j�|j|�Wd
ytj
|tj�Wntk
rYnXXd
S)zFCheck fork() in main thread works while a subthread is doing an importzfake test module�partialZcompletecsItj��tj�<�j�tjd��tj�<tj�dS)Ng{�G�z�?)�imp�acquire_lock�sys�modules�setrr�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)rZEventZThread�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_forkcs7�fdd�}xtd�D]}||�qWdS)zJCheck fork() in main thread works while the main thread is doing an importcs�d}d}ykzBx(t|�D]}tj�|d7}qWtj�}|}Wdxt|�D]}tj�qaWXWn>tk
r�|r�tdkr�td�tj	d��YnX|r�tj	d��j
|�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_forkLsz%ForkTest.test_nested_import_lock_forkN)�__name__�
__module__�__qualname__rr0r8rrrrr	s
*r	cCst�dS)N)rrrrr�tearDownModulelsr<�__main__)�__doc__�_imprr
r*rrZunittestZtest.fork_waitrZtest.supportrrrrrr	r<r9�mainrrrr�<module>s"
X