3
Od*                 @   sX   d dl Z d dlZd dlZd dlmZ d dlmZ d dlm	Z	m
Z
mZ dd Zdd ZdS )	    N)assert_)raises)ReentrancyLocknon_reentrantReentrancyErrorc                 s~   t ddgg   fddfddtdD } x| D ]}|j  q>W x| D ]}|j  qTW dj  t    d S )	NZfailureFc                sv   yL> t d   dd< tjd|   t d  dd< W d Q R X W n$ tk
rp    jtjd Y nX d S )Nr   Tg?F   )r   timesleep	Exceptionappend	traceback
format_exc)k)exceptions_raisedfailflaglock W/var/www/html/virt/lib64/python3.6/site-packages/scipy/_lib/tests/test__threadsafety.pyworker   s    z%test_parallel_threads.<locals>.workerc                s$   g | ]}t j|f fd d	dqS )c                s    | S )Nr   )r   )r   r   r   <lambda>!   s    z2test_parallel_threads.<locals>.<listcomp>.<lambda>)target)	threadingThread).0r   )r   r   r   
<listcomp>!   s   z)test_parallel_threads.<locals>.<listcomp>   
)r   rangestartjoinr   )threadstr   )r   r   r   r   r   test_parallel_threads   s    



r"   c                  s"   t   fdd tt d d S )Nc                s    | S )Nr   )x)funcr   r   r$   /   s    ztest_reentering.<locals>.funcr   )r   assert_raisesr   r   r   )r$   r   test_reentering,   s    r&   )r   r   r   Znumpy.testingr   Zpytestr   r%   Zscipy._lib._threadsafetyr   r   r   r"   r&   r   r   r   r   <module>   s   !