HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/test_asyncio/__pycache__/test_waitfor.cpython-310.pyc
o

�i�!�@s\ddlZddlZddlZdd�ZdZGdd�d�ZGdd�dej�Zed	kr,e�	�dSdS)
�NcCst�d�dS�N)�asyncioZset_event_loop_policy�rr�;/usr/local/lib/python3.10/test/test_asyncio/test_waitfor.py�tearDownModulesrg-C��6?c@s$eZdZdZdZdd�Zdd�ZdS)�SlowTaskz? Task will run for this defined time, ignoring cancel requests 皙�����?cCs
d|_dS)NF)�exited��selfrrr�__init__s
zSlowTask.__init__c�s^�t��|j}	|t��}|dkrnz
t�|�IdHWn
tjy(Ynwq	d|_dS)NTr)�time�	monotonic�TASK_TIMEOUTr�sleep�CancelledErrorr	)rZexitatZtosleeprrr�runs���

zSlowTask.runN)�__name__�
__module__�__qualname__�__doc__rrrrrrrrs
rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�AsyncioWaitForTestc�s^�t�}t�t�|��|jd��}t�d�IdH|��t�|h�IdH|�	|j
�dS)N�r)rr�create_task�wait_forrrr�cancel�wait�
assertTruer	)r�tZwaitfortaskrrr�test_asyncio_wait_for_cancelled)s��z2AsyncioWaitForTest.test_asyncio_wait_for_cancelledc�sN�t�}zt�|��|jd�IdHWn
tjyYnw|�|j�dS)Nr)rrrrr�TimeoutErrorrr	)rrrrr�test_asyncio_wait_for_timeout4s� �z0AsyncioWaitForTest.test_asyncio_wait_for_timeoutc�sl�t��}|��}|�d�|��}t�|d�IdH}|��}|�|d�|�|���|�	||d�dS)N�doner皙�����?)
r�get_running_loop�
create_future�
set_resultr
r�assertEqualrr"�
assertLess)r�loop�fut�t0�ret�t1rrr�2test_wait_for_timeout_less_then_0_or_0_future_done>s�
zEAsyncioWaitForTest.test_wait_for_timeout_less_then_0_or_0_future_donec�s��t��}d��fdd�}|�tj��|��}t�|�d�IdHWd�n1s,wY|��}|��d�|�||d�dS)NFc�s
�d�dS)NTrr�Zfoo_startedrr�fooQs�z_AsyncioWaitForTest.test_wait_for_timeout_less_then_0_or_0_coroutine_do_not_started.<locals>.foorr#)rr$�assertRaisesr r
rr'r()rr)r0r+r-rr/r�?test_wait_for_timeout_less_then_0_or_0_coroutine_do_not_startedLs��zRAsyncioWaitForTest.test_wait_for_timeout_less_then_0_or_0_coroutine_do_not_startedc
�s��t��}dD]s}|j|d��cd�|�����fdd�}t�|��}�IdH|�tj��|��}t�||�IdHWd�n1sFwY|��}|�	|�
��|�	|���|��d�|�
||d�Wd�n1suwYqdS)N)r�����timeoutc�s2�d���d�z
t�d�IdHWd�dSd�w�NT�
Fr")r&rrr��foo_running�startedrrr0es�
�zFAsyncioWaitForTest.test_wait_for_timeout_less_then_0_or_0.<locals>.fooFr#)rr$ZsubTestr%rr1r r
rrr"�	cancelledr'r()rr)r5r0r*r+r-rr8r�&test_wait_for_timeout_less_then_0_or_0]s*�

����z9AsyncioWaitForTest.test_wait_for_timeout_less_then_0_or_0c�s��t��}d��fdd�}t�|��}|�tj��|��}t�|d�IdHWd�n1s1wY|��}|�|���|�|�	��|�
||d�|��d�dS)Nc�s(�d�z
t�d�IdHWd�dSd�wr6�rrr�r9rrr0�s��z-AsyncioWaitForTest.test_wait_for.<locals>.foor#g�?F)rr$rr1r r
rrr"r;r(r')rr)r0r*r+r-rr>r�
test_wait_for}s�	�z AsyncioWaitForTest.test_wait_forc�s0�dd�}tj|�dd�IdH}|�|d�dS)Nc�s�dS)Nr"rrrrr�coro�s�z7AsyncioWaitForTest.test_wait_for_blocking.<locals>.coror4r"�rrr')rr@�resrrr�test_wait_for_blocking�s�z)AsyncioWaitForTest.test_wait_for_blockingc�sJ�t��}|��}tj|dd�}|�d|jd�|IdH}|�|d�dS)Nrr4r#�ok)rr$r%rZ
call_laterr&r')rr)r*�taskrBrrr�test_wait_for_race_condition�s�
z/AsyncioWaitForTest.test_wait_for_race_conditionc�s4��fdd�}tj|�dd�IdH}��|d�dS)Nc�sD���tj��t�d�IdHWd�dS1swYdS)N�)r1rrrrr
rr�inner�s�
��zKAsyncioWaitForTest.test_wait_for_cancellation_race_condition.<locals>.innerg{�G�z�?r4rGrA)rrH�resultrr
r�)test_wait_for_cancellation_race_condition�s�z<AsyncioWaitForTest.test_wait_for_cancellation_race_conditionc�s��d��fdd�}t�|��}|�tj��}tj|td�IdHWd�n1s*wY|���|jj}|�	t
|�tj�dS)NFc��L�z!z
t�d�IdHWntjyt�t�IdH�wWd�dSd�w�Nr7T�rrr�_EPSILONr��	task_donerrrH�����zKAsyncioWaitForTest.test_wait_for_waits_for_task_cancellation.<locals>.innerr4)rrr1r rrNr�	exception�__context__r'�typer)rrH�
inner_task�cm�chainedrrOr�)test_wait_for_waits_for_task_cancellation�s�
�
z<AsyncioWaitForTest.test_wait_for_waits_for_task_cancellationc�sr�d��fdd�}|�tj��}|�IdHWd�n1s wY|���|jj}|�t|�tj�dS)NFc�sB��fdd�}t�|��}t�t�IdHtj|dd�IdHdS)Nc�rKrLrMrrOrrrH�rQzdAsyncioWaitForTest.test_wait_for_waits_for_task_cancellation_w_timeout_0.<locals>.foo.<locals>.innerrr4)rrrrNr�rHrUrOrrr0�s
�
zUAsyncioWaitForTest.test_wait_for_waits_for_task_cancellation_w_timeout_0.<locals>.foo)	r1rr rrRrSr'rTr)rr0rVrWrrOr�5test_wait_for_waits_for_task_cancellation_w_timeout_0�s��
zHAsyncioWaitForTest.test_wait_for_waits_for_task_cancellation_w_timeout_0c�sZ�Gdd�dt���fdd�}|����|�IdHWd�dS1s&wYdS)Nc@seZdZdS)z]AsyncioWaitForTest.test_wait_for_reraises_exception_during_cancellation.<locals>.FooExceptionN)rrrrrrr�FooException�sr[c�s2��fdd�}t�|��}tj|td�IdHdS)Nc�s�zt�d�IdHW����)Nrr=r�r[rrrH�s�zcAsyncioWaitForTest.test_wait_for_reraises_exception_during_cancellation.<locals>.foo.<locals>.innerr4)rrrrNrYr\rrr0�s�zTAsyncioWaitForTest.test_wait_for_reraises_exception_during_cancellation.<locals>.foo)�	Exceptionr1)rr0rr\r�4test_wait_for_reraises_exception_during_cancellation�s�"�zGAsyncioWaitForTest.test_wait_for_reraises_exception_during_cancellationc�s��dd�}t�|��}tj|dd�}t�|�}t�d�IdH|��|�tj��
|IdHWd�n1s9wY|�|IdHd�dS)Nc�sl�zt�d�IdHWdStjy5zt�d�IdHWYdStjy4t�d�IdHYYdSww)Ng333333�?�*)rrrrrrrrH�s�����zAAsyncioWaitForTest.test_wait_for_self_cancellation.<locals>.innerr#r4rr_)rrrrrr1rr')rrHrUrrErrr�test_wait_for_self_cancellation�s�
�z2AsyncioWaitForTest.test_wait_for_self_cancellationc�s��t����fdd�}t�|��}t�t�||��}��|j�|�tj��
|IdHWd�n1s6wY|�|�	��dS)Nc�s����}|IdHdSr)r%)r*�r)rr�blocking_coroutines�zDAsyncioWaitForTest._test_cancel_wait_for.<locals>.blocking_coroutine)
rr$rrZ	call_soonrr1rrr;)rr5rbrErrrar�_test_cancel_wait_fors��z(AsyncioWaitForTest._test_cancel_wait_forc�s�|�d�IdHdSr�rcr
rrr�test_cancel_blocking_wait_for��z0AsyncioWaitForTest.test_cancel_blocking_wait_forc�s�|�d�IdHdS)NgN@rdr
rrr�test_cancel_wait_for!rfz'AsyncioWaitForTest.test_cancel_wait_forN)rrrrr!r.r2r<r?rCrFrJrXrZr^r`rcrergrrrrr's"
 		r�__main__)
rZunittestr
rrNrZIsolatedAsyncioTestCaserr�mainrrrr�<module>s�