Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/joblib/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/joblib/test/__pycache__/common.cpython-35.pyc



���W �@s|dZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZyddl
Zdd�ZWn$ek
r�dd�ZdZYnXy,dd	lmZd
d�Zdd
�ZWn(ek
r#dd�ZdZZYnXe�Zddd�Zdd�Zdd�Zee�Zdd�Zee�ZdS)z
Small utilities for testing.
�N)�mp)�SkipTest)�
with_setupcCs|S)z*A decorator to skip tests requiring numpy.�)�funcrr�C/opt/alt/python35/lib/python3.5/site-packages/joblib/test/common.py�
with_numpysrcCsdd�}|S)z*A decorator to skip tests requiring numpy.cSstjd��dS)NzTest requires numpy)�noserrrrr�my_funcszwith_numpy.<locals>.my_funcr)rr
rrrrs)�memory_usagecCs|S)z4A decorator to skip tests requiring memory_profiler.r)rrrr�with_memory_profiler%srcOs9tj�t|||fdd�}t|�t|�S)z)Compute memory usage when executing func.�intervalg����MbP?)�gc�collectr�max�min)r�args�kwargsZmem_userrr�memory_used)s
rcCsdd�}|S)z4A decorator to skip tests requiring memory_profiler.cSstjd��dS)NzTest requires memory_profiler.)r	rrrrr�
dummy_func2sz(with_memory_profiler.<locals>.dummy_funcr)rrrrrr0s�cCs`dtjksdtjkr"dSt|�dd�}tj||�t|<}|j�dS)z�Timeout based suiciding thread to kill the test runner process

    If some subprocess dies in an unexpected way we don't want the
    parent process to block indefinitely.
    ZNO_AUTOKILLz--pdbNcSs_tj�}td|�tj|tj�tjd�td|�tj|tj�dS)Nz1Timeout exceeded: terminating stalled process: %dg�?z-Timeout exceeded: killing stalled process: %d)	�os�getpid�print�kill�signal�SIGTERM�time�sleep�SIGKILL)�pidrrr�autokillMs
z setup_autokill.<locals>.autokill)	r�environ�sys�argv�teardown_autokill�	threading�Timer�_KILLER_THREADS�start)�module_name�timeoutr!�trrr�setup_autokill?s

r-cCs)tj|�}|dk	r%|j�dS)z)Cancel a previously started killer threadN)r(�get�cancel)r*Zkillerrrrr%[sr%cCstdkrtd��dS)NzNeed multiprocessing to run)rrrrrr�check_multiprocessingbsr0cCs"tjjd�std��dS)Nz/dev/shmz1This test requires the /dev/shm shared memory fs.)r�path�existsrrrrr�setup_if_has_dev_shmjsr3)�__doc__r&rr	rrr#rZjoblib._multiprocessing_helpersrr�
nose.toolsr�numpy�npr�ImportErrorZmemory_profilerrrr�dictr(r-r%r0Zwith_multiprocessingr3Zwith_dev_shmrrrr�<module>s<