U
    ?h1  ã                   @   s`   d dl Z d dlmZ d dlmZ d dlmZmZ d dlm	Z	 G dd„ deƒZ
edkr\e ¡  dS )	é    N)Úcuda)Údriver)ÚunittestÚContextResettingTestCase)ÚQueuec                   @   s   e Zd Zdd„ ZdS )ÚTestResetDevicec                 C   sZ   dd„ }t ƒ }tj||fd}| ¡  | ¡  g }| ¡ sJ| | ¡ ¡ q2|  |g ¡ d S )Nc              
   S   sl   z:t t ¡ ƒ}t dƒD ] }|D ]}t |¡ t ¡  qqW n, tk
rf } z|  |¡ W 5 d }~X Y nX d S )Né   )Úranger   Zget_device_countr   Zselect_deviceÚcloseÚ	ExceptionÚput)Úexception_queueZdevicesÚ_ÚdÚe© r   ú\/var/www/html/venv/lib/python3.8/site-packages/numba/cuda/tests/cudadrv/test_reset_device.pyÚ	newthread   s    
z4TestResetDevice.test_reset_device.<locals>.newthread)ÚtargetÚargs)	r   Ú	threadingÚThreadÚstartÚjoinÚemptyÚappendÚgetZassertEqual)Úselfr   r   ÚtÚ
exceptionsr   r   r   Útest_reset_device	   s    z!TestResetDevice.test_reset_deviceN)Ú__name__Ú
__module__Ú__qualname__r    r   r   r   r   r      s   r   Ú__main__)r   Znumbar   Znumba.cuda.cudadrv.driverr   Znumba.cuda.testingr   r   Úqueuer   r   r!   Úmainr   r   r   r   Ú<module>   s   