Your IP : 216.73.216.213


Current Path : /proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/test_fork1.cpython-34.pyo

�
f f��@s�dZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZm
Z
mZe
d�Zeed�Gdd�de�Zd	d
�Zedkr�e�ndS)z.This test checks for correct fork() behavior.
�N)�ForkWait)�run_unittest�
reap_children�
get_attribute�
import_module�verbose�	threading�forkc@s4eZdZdd�Zdd�Zdd�ZdS)�ForkTestcCs�xLtd�D]>}tj|tj�\}}||kr>Pntjd�q
W|j||�|j|dd|d@|d?f�dS)N�
g�?rzcause = %d, exit = %d��)�range�os�waitpid�WNOHANG�time�sleepZassertEqual)�selfZcpid�iZspidZstatus�r�4/opt/alt/python34/lib64/python3.4/test/test_fork1.py�	wait_implszForkTest.wait_implcstj��d�d�d�����fdd�}tjd|�}|j��j�tj�}zr|s�t��}|�kr�tjd�q�t	dkr�t
d	�ntjd�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�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)rZEventZThread�start�waitrr	�
__import__�_exitr�print�joinr�kill�signal�SIGKILL�OSError)rr$�t�pid�mr)r r!r"r#r�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�qaWXWnDtk
r�|r�tdkr�td�ntj	d�n�YnX|r�tj	d�n�j
|�dS)NrFr&zRuntimeError in child)rrrrr	r�RuntimeErrorrr+r*r)�level�releaseZin_childrr2)rrr�fork_with_import_lockMs(


zDForkTest.test_nested_import_lock_fork.<locals>.fork_with_import_lock�N)r)rr8r6r)rr�test_nested_import_lock_forkJsz%ForkTest.test_nested_import_lock_forkN)�__name__�
__module__�__qualname__rr4r:rrrrr
s*r
cCstt�t�dS)N)rr
rrrrr�	test_mainjs
r>�__main__)�__doc__�_imprrr.rrZtest.fork_waitrZtest.supportrrrrrrr
r>r;rrrr�<module>s(
W