Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/test/test_asyncio/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/test/test_asyncio/__pycache__/test_waitfor.cpython-312.pyc

�

(ΜgD*����ddlZddlZddlZddlmZd�ZdZGd�d�ZGd�dej�Z	Gd	�d
ej�Z
edk(rej�yy)�N)�supportc�.�tjd�y�N)�asyncio�set_event_loop_policy���;/usr/local/lib/python3.12/test/test_asyncio/test_waitfor.py�tearDownModulers���!�!�$�'r	g-C��6?c� �eZdZdZdZd�Zd�Zy)�SlowTaskz? Task will run for this defined time, ignoring cancel requests 皙�����?c��d|_y)NF)�exited��selfs r
�__init__zSlowTask.__init__s	����r	c��K�tj�|jz}	|tj�z
}|dkr		d|_y	tj|��d{����D7�#tj
$rY�wxYw�w)NTr)�time�	monotonic�TASK_TIMEOUTr�sleep�CancelledErrorr)r�exitat�tosleeps   r
�runzSlowTask.runs|�������!�D�$5�$5�5����t�~�~�/�/�G��!�|�����
��m�m�G�,�,�,�
�-���)�)�
��
�s<�AB�A+�#A)�$A+�(B�)A+�+B�>B�B�BN)�__name__�
__module__�__qualname__�__doc__rrrrr	r
r
r
s��I��L��
r	r
c�r�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zy)�AsyncioWaitForTestc��|K�t�}tjtj|j	�|j
dz��}tjd��d{���|j�tj|h��d{���|j|j�y7�N7�"�w)N�r)r
r�create_task�wait_forrrr�cancel�wait�
assertTruer)r�t�waitfortasks   r
�test_asyncio_wait_for_cancelledz2AsyncioWaitForTest.test_asyncio_wait_for_cancelled*s������J���)�)����Q�U�U�W�a�n�n�q�&8�9�;���m�m�A���������l�l�K�=�)�)�)�������!�		��)�s$�A'B<�)B8�*-B<�B:�!B<�:B<c��K�t�}	tj|j�|jdz��d{���|j
|j�y7� #tj
$rY�3wxYw�w)Nr$)r
rr&rr�TimeoutErrorr)r)rr*s  r
�test_asyncio_wait_for_timeoutz0AsyncioWaitForTest.test_asyncio_wait_for_timeout5sf�����J��	��"�"�1�5�5�7�A�N�N�Q�,>�?�?�?�	
������!�	
@���#�#�	��	�s:�A>�4A%�A#�A%�A>�#A%�%A;�8A>�:A;�;A>c��K�tj�}|j�}|jd�tj|d��d{���}|j|d�|j
|j��y7�6�w)N�doner)r�get_running_loop�
create_future�
set_resultr&�assertEqualr)r1)r�loop�fut�rets    r
�2test_wait_for_timeout_less_then_0_or_0_future_donezEAsyncioWaitForTest.test_wait_for_timeout_less_then_0_or_0_future_done?sj�����'�'�)��� � �"�����v���$�$�S�!�,�,������f�%�������
�#�-�s�AB
�B�7B
c����K�d��fd�}|jtj�5tj|�d��d{���ddd�|j	�d�y7�#1swY�xYw�w)NFc���K�d�y�w)NTr)�foo_starteds�r
�fooz_AsyncioWaitForTest.test_wait_for_timeout_less_then_0_or_0_coroutine_do_not_started.<locals>.fooMs������K�s�r)�assertRaisesrr.r&r5)rr=r<s  @r
�?test_wait_for_timeout_less_then_0_or_0_coroutine_do_not_startedzRAsyncioWaitForTest.test_wait_for_timeout_less_then_0_or_0_coroutine_do_not_startedJsd�������	��
�
�w�3�3�
4��"�"�3�5�!�,�,�,�5�	
����e�,�
-��5�
4�s.�'A7�A+�	A)�
A+�A7�)A+�+A4�0A7c��Z��K�tj�}dD]�}|j|��5d�|j����fd�}tj|��}��d{���|jtj�5tj||��d{���ddd�|j|j��|j|j��|j�d�ddd���y7��7�i#1swY�hxYw#1swY��
xYw�w)N)r�����timeoutc���K�d��jd�	tjd��d{���d�y7�#d�wxYw�w)NT�
Fr1)r4rr)�foo_running�starteds��r
r=zFAsyncioWaitForTest.test_wait_for_timeout_less_then_0_or_0.<locals>.foo^sD�����"&�K��&�&�t�,�,�%�m�m�B�/�/�/�&+��!�0��&+��s#�A�:�8�:�A�:�>�AF)rr2�subTestr3r%r>r.r&r)r1�	cancelledr5)rr6rCr=r7rFrGs     @@r
�&test_wait_for_timeout_less_then_0_or_0z9AsyncioWaitForTest.test_wait_for_timeout_less_then_0_or_0Vs�������'�'�)���G����g��.�"���,�,�.��"��)�)�#�%�0���
�
��&�&�w�';�';�<�!�*�*�3��8�8�8�=�������
�+�����
�
��0�� � ��e�4�//�.�� ��9��=�<��#/�.�sY�,D+�8D�(D�)#D�D�&D
�'D�+AD�D+�D�D�D�D�D(	�#D+c���K�d��fd�}tj|��}|jtj�5tj|d��d{���ddd�|j|j
��|j|j��|j�d�y7�]#1swY�\xYw�w)Nc���K�d�	tjtj��d{���d�y7�#d�wxYw�w)NTFr1)rrr�LONG_TIMEOUT)rFs�r
r=z-AsyncioWaitForTest.test_wait_for.<locals>.foovs<������K�
$��m�m�G�$8�$8�9�9�9�#���:��#��s �>�&7�5�7�>�7�;�>皙�����?F)	rr%r>r.r&r)r1rIr5)rr=r7rFs   @r
�
test_wait_forz AsyncioWaitForTest.test_wait_forss��������	��!�!�#�%�(��
�
�
�w�3�3�
4��"�"�3��,�,�,�5�������
�#�����
�
��(�����e�,�	
-��5�
4�s1�AC
�B>�B<�B>�#AC
�<B>�>C�C
c��K�d�}tj|�d���d{���}|j|d�y7��w)Nc��K�y�w�Nr1rrr	r
�coroz7AsyncioWaitForTest.test_wait_for_blocking.<locals>.coro��	�������rBr1�rr&r5)rrS�ress   r
�test_wait_for_blockingz)AsyncioWaitForTest.test_wait_for_blocking�s9����	��$�$�T�V�T�:�:������f�%�;���#?�=�?c��K�tj�}|j�}tj|d��}|j	|j
d�|�d{���}|j
|d�y7��w)NrrB�ok)rr2r3r&�	call_soonr4r5)rr6r7�taskrWs     r
�test_wait_for_race_conditionz/AsyncioWaitForTest.test_wait_for_race_condition�sb�����'�'�)��� � �"������S�1�����s�~�~�t�,��j������d�#��s�AA9�A7� A9c���K��fd�}tj|�d���d{���}�j|d�y7��w)Nc���K��jtj�5tjd��d{���ddd�y7�
#1swYyxYw�w)N�)r>rrrrs�r
�innerzKAsyncioWaitForTest.test_wait_for_cancellation_race_condition.<locals>.inner�sC������"�"�7�#9�#9�:��m�m�A�&�&�&�;��'��;��s,� A�A�A
�A�	A�
A�A�A�{�G�z�?rBrarV)rrb�results`  r
�)test_wait_for_cancellation_race_conditionz<AsyncioWaitForTest.test_wait_for_cancellation_race_condition�s:�����	�
�'�'����=�=�������#�>�s�%A�A�Ac���K�d��fd�}tj|��}|jtj�5}tj|t
���d{���ddd�|j
��jj}|jt|�tj�y7�]#1swY�\xYw�w)NFc����K�	tjd��d{���d�y7�#tj$r$tjt��d{���7�wxYw#d�wxYw�w�NrET�rrr�_EPSILON��	task_dones�r
rbzKAsyncioWaitForTest.test_wait_for_waits_for_task_cancellation.<locals>.inner�s[�����
!��m�m�B�'�'�'�
!�	�(���)�)�
��m�m�H�-�-�-��
��!�	��=�A(�'�%�'�A(�'�/A�A�A�A!�!A%�%A(rB)rr%r>r.r&rjr)�	exception�__context__r5�typer)rrb�
inner_task�cm�chainedrls     @r
�)test_wait_for_waits_for_task_cancellationz<AsyncioWaitForTest.test_wait_for_waits_for_task_cancellation�s�������	�	!��(�(���1�
�
�
�
�w�3�3�
4���"�"�:�x�@�@�@�5�	
���	�"��,�,�*�*������g���(>�(>�?�	
A��5�
4�s1�AC�C�#C�$C�(AC�C�C�Cc��F�K�d��fd�}|jtj�5}|��d{���ddd�|j��jj
}|j
t|�tj�y7�]#1swY�\xYw�w)NFc����K��fd�}tj|��}tjt��d{���tj|d���d{���y7�$7��w)Nc����K�	tjd��d{���d�y7�#tj$r$tjt��d{���7�wxYw#d�wxYw�wrhrirks�r
rbzdAsyncioWaitForTest.test_wait_for_waits_for_task_cancellation_w_timeout_0.<locals>.foo.<locals>.inner�s[�����%�!�-�-��+�+�+�
!%�I�,���-�-��!�-�-��1�1�1����!%�I�rmrrB)rr%rrjr&)rbrqrls  �r
r=zUAsyncioWaitForTest.test_wait_for_waits_for_task_cancellation_w_timeout_0.<locals>.foo�sQ�����
%�!�,�,�U�W�5�J��-�-��)�)�)��"�"�:�q�9�9�9�
*��9�s"�<A(�A$�A(�A&�A(�&A()	r>rr.r)rnror5rpr)rr=rrrsrls    @r
�5test_wait_for_waits_for_task_cancellation_w_timeout_0zHAsyncioWaitForTest.test_wait_for_waits_for_task_cancellation_w_timeout_0�s|������	�
	:��
�
�w�3�3�
4���%�K�K�5�	
���	�"��,�,�*�*������g���(>�(>�?�	
��5�
4�s,�'B!�B�B�B�AB!�B�B�B!c���K�Gd�dt���fd�}|j��5|��d{���ddd�y7�
#1swYyxYw�w)Nc��eZdZy)�]AsyncioWaitForTest.test_wait_for_reraises_exception_during_cancellation.<locals>.FooExceptionN)rrrrr	r
�FooExceptionr{�s��r	r|c���K��fd�}tj|��}tj|t���d{���y7��w)Nc��\�K�	tjd��d{�����7�#��xYw�w)Nr�rr)r|s�r
rbzcAsyncioWaitForTest.test_wait_for_reraises_exception_during_cancellation.<locals>.foo.<locals>.inner�s0�����'�!�-�-��,�,�,�&�&�-��&�&�s �,�&�$�&�,�&�)�,rB)rr%r&rj)rbrqr|s  �r
r=zTAsyncioWaitForTest.test_wait_for_reraises_exception_during_cancellation.<locals>.foo�s6�����
'�!�,�,�U�W�5�J��"�"�:�x�@�@�@�s�>A	�A�A	)�	Exceptionr>)rr=r|s  @r
�4test_wait_for_reraises_exception_during_cancellationzGAsyncioWaitForTest.test_wait_for_reraises_exception_during_cancellation�sF�����	�9�	�		A��
�
�|�
,��%�K�K�-�
,���-�
,�s+�&A�A�A�A�	A�A�A
�	Ac���K�tj���fd�}tj|��}tjtj||��}�j	|j
�|j
tj�5|�d{���ddd�|j|j��y7�,#1swY�+xYw�w)Nc��F�K��j�}|�d{���y7��wr)r3)r7r6s �r
�blocking_coroutinezDAsyncioWaitForTest._test_cancel_wait_for.<locals>.blocking_coroutine�s������$�$�&�C��I�I�s�!��!)
rr2r%r&r\r'r>rr)rI)rrCr�r]r(r6s     @r
�_test_cancel_wait_forz(AsyncioWaitForTest._test_cancel_wait_for�s�������'�'�)��	�
�"�"�#5�#7�8���"�"�7�#3�#3�D�'�#B�C�����t�{�{�#�
�
�
�w�5�5�
6��J�J�7�	
������(�)�
��7�
6�s0�BC�C� C
�!C�%(C�
C�C�Cc��BK�|jd��d{���y7��wr�r�rs r
�test_cancel_blocking_wait_forz0AsyncioWaitForTest.test_cancel_blocking_wait_for�������(�(��.�.�.�����c��BK�|jd��d{���y7��w)NgN@r�rs r
�test_cancel_wait_forz'AsyncioWaitForTest.test_cancel_wait_for�r�r�c��K�d�}tj|�d���d{���}|j|d�y7��w)Nc��~K�	tjd��d{���y7�#tj$rYywxYw�w)NrE�*)rrrrr	r
�	return_42zEAsyncioWaitForTest.test_wait_for_cancel_suppressed.<locals>.return_42s4����
��m�m�B�'�'�'���)�)�
��
�s(�=�$�"�$�=�$�:�=�:�=rNrBr�rV)rr�rWs   r
�test_wait_for_cancel_suppressedz2AsyncioWaitForTest.test_wait_for_cancel_suppressed�s9����	��$�$�Y�[�#�>�>������b�!�?�rYc��B��K�d�}tj|���d���fd�}tj|��}|j|j��tjd��d{���|j�|j
tj�5|�d{���ddd�|j�j��|j��d{���d�|j��y7��7�Y#1swY�XxYw7�+�w)Nc��K�y�wrRrrr	r
rbz:AsyncioWaitForTest.test_wait_for_issue86296.<locals>.innerrTrUFc���K�tj�d���d{���tjd��d{���d�y7�$7�	�w)N�drBraT)rr&r)rq�reached_ends��r
�
wait_for_corozBAsyncioWaitForTest.test_wait_for_issue86296.<locals>.wait_for_coros=������"�"�:�s�;�;�;��-�-��"�"�"��K�
<��"�s�A�A�A�A�A�Arr1)
rr%�assertFalser1rr'r>rr)r5)rrbr�r]rqr�s    @@r
�test_wait_for_issue86296z+AsyncioWaitForTest.test_wait_for_issue86296s������
	��(�(���1�
���	��"�"�=�?�3���������%��m�m�A�������
�
�
�
�w�5�5�
6��J�J�7����
���)�*����z�)�6�2�����%�
	��
��7�
6��*�sH�A7D�;D
�<3D�/D�5D�6D�:7D�1D�2D�D�D�DN)rrrr,r/r9r?rJrOrXr^rertrxr�r�r�r�r�r�rr	r
r"r"(sY��	"�"�	$�
-�5�:-�*&�$�$�@�,@�2�$*�&/�/�
"� &r	r"c��eZdZd�Zd�Zd�Zy)�WaitForShieldTestsc��PK�d�}tj|��}|jtj�5tj|�}tj
|d���d{���ddd�|j
|j��|j
|j��|jj��tjd��d{���|j|j��y7��#1swY��xYw7�2�w)Nc��JK�tjd��d{���y7��w)Nrcr1rrr	r
rSz2WaitForShieldTests.test_zero_timeout.<locals>.coro1s �����-�-��%�%�%��
&���#�!�#rrBrN)rr%r>r.�shieldr&r�r1rIr)r)rrSr]�
shielded_tasks    r
�test_zero_timeoutz$WaitForShieldTests.test_zero_timeout*s�����	��"�"�4�6�*��
�
�
�w�3�3�
4�#�N�N�4�0�M��"�"�=�!�<�<�<�5�
	
�������%�������)�*����
�/�/�1�2��m�m�C� � � �����	�	��$�
=��5�
4��	!�s;�=D&�0D�/D�0D�4A=D&�1D$�2$D&�D�D!�D&c��$K�d�}tj|��}tjtj|�d���d{���|j	|j��|j
|�d{���d�y7�>7��w)Nc��JK�tjd��d{���y7��w�NrNr1rrr	r
rSz2WaitForShieldTests.test_none_timeout.<locals>.coroG� �����-�-��$�$�$��
%�r�rBr1)rr%r&r�r)r1r5�rrSr]s   r
�test_none_timeoutz$WaitForShieldTests.test_none_timeoutDsn����	��"�"�4�6�*�����w�~�~�d�3�T�B�B�B�����	�	��$����t��V�,�	C��$�s$�AB�
B�3B�B�B�Bc���K�d�}tj|��}|jtj�5tjtj
|�d���d{���ddd�|j
|j��|j
|j��|j|�d{���d�y7�e#1swY�dxYw7��w)Nc��JK�tjd��d{���y7��wr�rrr	r
rSz6WaitForShieldTests.test_shielded_timeout.<locals>.coroSr�r�rcrBr1)
rr%r>r.r&r�r�r1rIr5r�s   r
�test_shielded_timeoutz(WaitForShieldTests.test_shielded_timeoutQs�����	��"�"�4�6�*��
�
�
�w�3�3�
4��"�"�7�>�>�$�#7��F�F�F�5�	
�������%�������)�*����t��V�,�	
G��5�
4��
$�s;�=C#�.C�-C�.C�2AC#�C!�	
C#�C�C�C#N)rrrr�r�r�rr	r
r�r�(s��%�4-�-r	r��__main__)
r�unittestr�testrrrjr
�IsolatedAsyncioTestCaser"r�r�mainrr	r
�<module>r�si������(�����.}&��9�9�}&�@5-��9�9�5-�p�z���H�M�M�O�r	

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists