HEX
Server: Apache
System: Linux sh00085.hostgator.com 5.14.0-687.29.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jul 23 16:18:48 EDT 2026 x86_64
User: yqegzjte (1064)
PHP: 8.5.8
Disabled: NONE
Upload Files
File: //usr/libexec/oracle-cloud-agent/plugins/osms/unittest/async_case.pyc
a

���d��@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)�self�
methodName��	__class__��+/usr/lib64/python3.9/unittest/async_case.pyr!sz IsolatedAsyncioTestCase.__init__c�sdSrr�rrrr�
asyncSetUp&sz"IsolatedAsyncioTestCase.asyncSetUpc�sdSrrrrrr�
asyncTearDown)sz%IsolatedAsyncioTestCase.asyncTearDowncOs|j|g|�Ri|��dSr)�
addCleanup)r�func�args�kwargsrrr�addAsyncCleanup,s
z'IsolatedAsyncioTestCase.addAsyncCleanupcCs|��|�|j�dSr)�setUp�
_callAsyncrrrrr�
_callSetUp;sz"IsolatedAsyncioTestCase._callSetUpcCs|�|�dSr��_callMaybeAsync)r�methodrrr�_callTestMethod?sz'IsolatedAsyncioTestCase._callTestMethodcCs|�|j�|��dSr)rr�tearDownrrrr�
_callTearDownBsz%IsolatedAsyncioTestCase._callTearDowncOs|j|g|�Ri|��dSrr)r�functionrrrrr�_callCleanupFsz$IsolatedAsyncioTestCase._callCleanupcOs^|jdusJd��||i|��}t�|�s8J|�d���|j��}|j�||f�|j�|�S)N�$asyncio test loop is not initializedz returned non-awaitable�r	�inspect�isawaitable�
create_futurer
�
put_nowait�run_until_complete�rrrr�ret�futrrrrIs
z"IsolatedAsyncioTestCase._callAsynccOsX|jdusJd��||i|��}t�|�rP|j��}|j�||f�|j�|�S|SdS)Nr$r%r+rrrrQs

z'IsolatedAsyncioTestCase._callMaybeAsyncc
�s�t��|_}|�d�|��IdH}|��|dur:dS|\}}z |IdH}|��s`|�|�Wqttfyz�Yqt	tj
fy�}z|��s�|�|�WYd}~qd}~00qdSr)�asyncio�Queuer
�
set_result�get�	task_done�	cancelled�
SystemExit�KeyboardInterrupt�
BaseException�CancelledError�
set_exception)rr-�queue�query�	awaitabler,�exrrr�_asyncioLoopRunner[s 

z*IsolatedAsyncioTestCase._asyncioLoopRunnercCs\|jdusJd��t��}t�|�|�d�||_|��}|�|�|��|_|�	|�dS)Nz%asyncio test loop already initializedT)
r	r.�new_event_loop�set_event_loop�	set_debugr(�create_taskr=�_asyncioCallsTaskr*)r�loopr-rrr�_setupAsyncioLoopns

z)IsolatedAsyncioTestCase._setupAsyncioLoopc
Cs&|jdusJd��|j}d|_|j�d�|�|j���z�t�|�}|spW|�|���t�d�|�	�dS|D]}|�
�qt|�tj|ddi��|D]0}|��r�q�|�
�dur�|�d|�
�|d��q�|�|���W|�|���t�d�|�	�n"|�|���t�d�|�	�0dS)Nr$�return_exceptionsTz(unhandled exception during test shutdown)�message�	exception�task)r	r
r)r*�joinr.�	all_tasks�shutdown_default_executorr?�close�cancel�gatherr3rG�call_exception_handler�shutdown_asyncgens)rrC�	to_cancelrHrrr�_tearDownAsyncioLoopxsD

�
��


�
z,IsolatedAsyncioTestCase._tearDownAsyncioLoopNcs.|��zt��|�W|��S|��0dSr)rDr�runrR)r�resultr
rrrS�s�zIsolatedAsyncioTestCase.runcs|��t���|��dSr)rDr�debugrRrr
rrrU�s
zIsolatedAsyncioTestCase.debugcCs|jdur|��dSr)r	rRrrrr�__del__�s
zIsolatedAsyncioTestCase.__del__)r)N)�__name__�
__module__�__qualname__rrrrrrr!r#rrr=rDrRrSrUrV�
__classcell__rrr
rrs 

$r)r.r&�caserrrrrr�<module>s