HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/unittest/__pycache__/async_case.cpython-310.pyc
o

�N�g��@s0ddlZddlZddlmZGdd�de�ZdS)�N�)�TestCasecs�eZdZd#�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd$�fdd�	Z�fdd �Zd!d"�Z�ZS)%�IsolatedAsyncioTestCase�runTestcst��|�d|_d|_dS�N)�super�__init__�_asyncioTestLoop�_asyncioCallsQueue)�selfZ
methodName��	__class__��9/opt/saltstack/salt/lib/python3.10/unittest/async_case.pyr!s
z IsolatedAsyncioTestCase.__init__c���dSrr�rrrr�
asyncSetUp&��z"IsolatedAsyncioTestCase.asyncSetUpc�rrrrrrr�
asyncTearDown)rz%IsolatedAsyncioTestCase.asyncTearDowncO�|j|g|�Ri|��dSr)Z
addCleanup)r�func�args�kwargsrrr�addAsyncCleanup,s
z'IsolatedAsyncioTestCase.addAsyncCleanupcCs|��|�|j�dSr)ZsetUp�
_callAsyncrrrrr�
_callSetUp;sz"IsolatedAsyncioTestCase._callSetUpcCs|�|�dSr��_callMaybeAsync)r�methodrrr�_callTestMethod?sz'IsolatedAsyncioTestCase._callTestMethodcCs|�|j�|��dSr)rrZtearDownrrrr�
_callTearDownBsz%IsolatedAsyncioTestCase._callTearDowncOrrr)r�functionrrrrr�_callCleanupFsz$IsolatedAsyncioTestCase._callCleanupcOs^|jdus	Jd��||i|��}t�|�sJ|�d���|j��}|j�||f�|j�|�S)N�$asyncio test loop is not initializedz returned non-awaitable�r	�inspectZisawaitable�
create_futurer
�
put_nowait�run_until_complete�rrrr�ret�futrrrrIs
z"IsolatedAsyncioTestCase._callAsynccOsT|jdus	Jd��||i|��}t�|�r(|j��}|j�||f�|j�|�S|S)Nr#r$r)rrrrQs

z'IsolatedAsyncioTestCase._callMaybeAsyncc
�s��t��|_}|�d�	|��IdH}|��|durdS|\}}z|IdH}|��s2|�|�Wn'ttfy=�t	tj
fyZ}z|��sP|�|�WYd}~nd}~wwqr)�asyncio�Queuer
Z
set_result�get�	task_done�	cancelled�
SystemExit�KeyboardInterrupt�
BaseExceptionZCancelledErrorZ
set_exception)rr+�queue�queryZ	awaitabler*�exrrr�_asyncioLoopRunner[s,�


�
���z*IsolatedAsyncioTestCase._asyncioLoopRunnercCs\|jdus	Jd��t��}t�|�|�d�||_|��}|�|�|��|_|�	|�dS)Nz%asyncio test loop already initializedT)
r	r,Znew_event_loop�set_event_loopZ	set_debugr&Zcreate_taskr7Z_asyncioCallsTaskr()r�loopr+rrr�_setupAsyncioLoopns

z)IsolatedAsyncioTestCase._setupAsyncioLoopc
Cs$|jdus	Jd��|j}d|_|j�d�|�|j���zct�|�}|s8W|�|���t�d�|�	�dS|D]}|�
�q:|�tj|ddi��|D]}|��rUqN|�
�durf|�d|�
�|d��qN|�|���W|�|���t�d�|�	�dS|�|���t�d�|�	�w)Nr#Zreturn_exceptionsTz(unhandled exception during test shutdown)�message�	exception�task)r	r
r'r(�joinr,Z	all_tasksZshutdown_default_executorr8�close�cancelZgatherr0r<Zcall_exception_handlerZshutdown_asyncgens)rr9Z	to_cancelr=rrr�_tearDownAsyncioLoopxsD

�
���
�

z,IsolatedAsyncioTestCase._tearDownAsyncioLoopNcs*|��zt��|�W|��S|��wr)r:r�runrA)r�resultrrrrB�szIsolatedAsyncioTestCase.runcs|��t���|��dSr)r:r�debugrArrrrrD�s
zIsolatedAsyncioTestCase.debugcCs|jdur|��dSdSr)r	rArrrr�__del__�s
�zIsolatedAsyncioTestCase.__del__)rr)�__name__�
__module__�__qualname__rrrrrrr r"rrr7r:rArBrDrE�
__classcell__rrrrrs"

$r)r,r%�caserrrrrr�<module>s