Your IP : 216.73.216.213


Current Path : /opt/alt/python311/lib64/python3.11/test/test_asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/test/test_asyncio/__pycache__/test_waitfor.cpython-311.pyc

�

�0�i1 ���ddlZddlZddlZddlmZd�ZdZGd�d��ZGd�dej��Z	e
d	krej��dSdS)
�N)�supportc�.�tjd��dS�N)�asyncio�set_event_loop_policy���E/opt/alt/python311/lib64/python3.11/test/test_asyncio/test_waitfor.py�tearDownModulers���!�$�'�'�'�'�'r	g-C��6?c�"�eZdZdZdZd�Zd�ZdS)�SlowTaskz? Task will run for this defined time, ignoring cancel requests 皙�����?c��d|_dS)NF)�exited��selfs r
�__init__zSlowTask.__init__s
������r	c���K�tj��|jz}	|tj��z
}|dkrn2	tj|���d{V��n#tj$rYnwxYw�Od|_dS)NTr)�time�	monotonic�TASK_TIMEOUTr�sleep�CancelledErrorr)r�exitat�tosleeps   r
�runzSlowTask.runs�������!�!�D�$5�5��	��t�~�/�/�/�G��!�|�|��
��m�G�,�,�,�,�,�,�,�,�,�,���)�
�
�
���
����	�����s�A�A*�)A*N)�__name__�
__module__�__qualname__�__doc__rrrrr	r
r
r
s=������I�I��L����
�
�
�
�
r	r
c�n�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�ZdS)�AsyncioWaitForTestc��nK�t��}tjtj|���|jdz����}tjd���d{V��|���tj|h���d{V��|�	|j
��dS)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�J���)���Q�U�U�W�W�a�n�q�&8�9�9�;�;���m�A�����������������l�K�=�)�)�)�)�)�)�)�)�)������!�!�!�!�!r	c���K�t��}	tj|���|jdz���d{V��n#tj$rYnwxYw|�|j��dS)Nr$)r
rr&rr�TimeoutErrorr)r)rr*s  r
�test_asyncio_wait_for_timeoutz0AsyncioWaitForTest.test_asyncio_wait_for_timeout5s������J�J��	��"�1�5�5�7�7�A�N�Q�,>�?�?�?�?�?�?�?�?�?�?���#�	�	�	��D�	����	
�����!�!�!�!�!s�5A�A�Ac��2K�tj��}|���}|�d��tj|d���d{V��}|�|d��|�|�����dS)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?s������'�)�)��� � �"�"�����v�����$�S�!�,�,�,�,�,�,�,�,������f�%�%�%�������
�
�#�#�#�#�#r	c���K�d��fd�}|�tj��5tj|��d���d{V��ddd��n#1swxYwY|��d��dS)NFc���K�d�dS)NTr)�foo_starteds�r
�fooz_AsyncioWaitForTest.test_wait_for_timeout_less_then_0_or_0_coroutine_do_not_started.<locals>.fooMs������K�K�Kr	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_startedJs��������	�	�	�	�	��
�
�w�3�
4�
4�	-�	-��"�3�3�5�5�!�,�,�,�,�,�,�,�,�,�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�	
����e�,�,�,�,�,s�$A�A�!Ac����K�tj��}dD�]'}|�|���5d�|������fd�}tj|����}��d{V��|�tj��5tj||���d{V��ddd��n#1swxYwY|�|�	����|�|�
����|��d��ddd��n#1swxYwY��)dS)N)r�����timeoutc���K�d���d��	tjd���d{V��d�n#d�wxYwdS)NT�
Fr1)r4rr)�foo_running�starteds��r
r=zFAsyncioWaitForTest.test_wait_for_timeout_less_then_0_or_0.<locals>.foo^sd�����"&�K��&�&�t�,�,�,�,�%�m�B�/�/�/�/�/�/�/�/�/�&+����e��+�+�+�+�!�6s�9�=F)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��������'�)�)���	5�	5�G����g��.�.�
5�
5�"���,�,�.�.��"�"�"�"�"�"��)�#�#�%�%�0�0���
�
�
�
�
�
�
��&�&�w�';�<�<�9�9�!�*�3��8�8�8�8�8�8�8�8�8�9�9�9�9�9�9�9�9�9�9�9����9�9�9�9�������
�
�+�+�+�����
�
���0�0�0�� � ��e�4�4�4�/
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5����
5�
5�
5�
5��	5�	5s7�A D6�B;�/D6�;B?�?D6�B?�A'D6�6D:	�=D:	c���K�d��fd�}tj|����}|�tj��5tj|d���d{V��ddd��n#1swxYwY|�|�����|�|�����|��d��dS)Nc��n�K�d�	tjtj���d{V��d�n#d�wxYwdS)NTFr1)rrr�LONG_TIMEOUT)rFs�r
r=z-AsyncioWaitForTest.test_wait_for.<locals>.foovsS������K�
$��m�G�$8�9�9�9�9�9�9�9�9�9�#����e��#�#�#�#��6s�$.�2皙�����?F)	rr%r>r.r&r)r1rIr5)rr=r7rFs   @r
�
test_wait_forz AsyncioWaitForTest.test_wait_forss�������	�	�	�	�	��!�#�#�%�%�(�(��
�
�
�w�3�
4�
4�	-�	-��"�3��,�,�,�,�,�,�,�,�,�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�������
�
�#�#�#�����
�
���(�(�(�����e�,�,�,�,�,s�A.�.A2�5A2c��K�d�}tj|��d����d{V��}|�|d��dS)Nc��
K�dS)Nr1rrr	r
�coroz7AsyncioWaitForTest.test_wait_for_blocking.<locals>.coro�s�����6r	rBr1�rr&r5)rrR�ress   r
�test_wait_for_blockingz)AsyncioWaitForTest.test_wait_for_blocking�s`����	�	�	��$�T�T�V�V�T�:�:�:�:�:�:�:�:�:������f�%�%�%�%�%r	c��K�tj��}|���}tj|d���}|�d|jd��|�d{V��}|�|d��dS)NrrBrN�ok)rr2r3r&�
call_laterr4r5)rr6r7�taskrTs     r
�test_wait_for_race_conditionz/AsyncioWaitForTest.test_wait_for_race_condition�s�����'�)�)��� � �"�"�����S�1�1�1������S�^�T�2�2�2��j�j�j�j�j�j������d�#�#�#�#�#r	c���K��fd�}tj|��d����d{V��}��|d��dS)Nc���K���tj��5tjd���d{V��ddd��n#1swxYwYdS)N�)r>rrrrs�r
�innerzKAsyncioWaitForTest.test_wait_for_cancellation_race_condition.<locals>.inner�s�������"�"�7�#9�:�:�
'�
'��m�A�&�&�&�&�&�&�&�&�&�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'����
'�
'�
'�
'��1s�A
�
A�Ag{�G�z�?rBr]rS)rr^�results`  r
�)test_wait_for_cancellation_race_conditionz<AsyncioWaitForTest.test_wait_for_cancellation_race_condition�sk�����	�	�	�	�	�
�'������=�=�=�=�=�=�=�=�=�������#�#�#�#�#r	c���K�d��fd�}tj|����}|�tj��5}tj|t
����d{V��ddd��n#1swxYwY|����|jj}|�	t|��tj��dS)NFc���K�	tjd���d{V��n3#tj$r!tjt���d{V���wxYw	d�dS#d�wxYw�NrET�rrr�_EPSILON��	task_dones�r
r^zKAsyncioWaitForTest.test_wait_for_waits_for_task_cancellation.<locals>.inner�s������
!��m�B�'�'�'�'�'�'�'�'�'�'���)�
�
�
��m�H�-�-�-�-�-�-�-�-�-��
����(�
!�	�	�	��D�	� � � � �� �A�0A�A�ArB)rr%r>r.r&rer)�	exception�__context__r5�typer)rr^�
inner_task�cm�chainedrgs     @r
�)test_wait_for_waits_for_task_cancellationz<AsyncioWaitForTest.test_wait_for_waits_for_task_cancellation�s!������	�	!�	!�	!�	!�	!��(�����1�1�
�
�
�
�w�3�
4�
4�	A���"�:�x�@�@�@�@�@�@�@�@�@�@�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A����	A�	A�	A�	A�	
���	�"�"�"��,�*������g����(>�?�?�?�?�?s�"A4�4A8�;A8c��D�K�d��fd�}|�tj��5}|���d{V��ddd��n#1swxYwY|����|jj}|�t|��tj��dS)NFc����K��fd�}tj|����}tjt���d{V��tj|d����d{V��dS)Nc���K�	tjd���d{V��n3#tj$r!tjt���d{V���wxYw	d�dS#d�wxYwrcrdrfs�r
r^zdAsyncioWaitForTest.test_wait_for_waits_for_task_cancellation_w_timeout_0.<locals>.foo.<locals>.inner�s������%�!�-��+�+�+�+�+�+�+�+�+�+���-����!�-��1�1�1�1�1�1�1�1�1������,�
!%�I�I�I���I�$�$�$�$rhrrB)rr%rrer&)r^rlrgs  �r
r=zUAsyncioWaitForTest.test_wait_for_waits_for_task_cancellation_w_timeout_0.<locals>.foo�s������
%�
%�
%�
%�
%�!�,�U�U�W�W�5�5�J��-��)�)�)�)�)�)�)�)�)��"�:�q�9�9�9�9�9�9�9�9�9�9�9�9r	)	r>rr.r)rirjr5rkr)rr=rmrnrgs    @r
�5test_wait_for_waits_for_task_cancellation_w_timeout_0zHAsyncioWaitForTest.test_wait_for_waits_for_task_cancellation_w_timeout_0�s�������	�
	:�
	:�
	:�
	:�
	:��
�
�w�3�
4�
4�	���#�%�%�K�K�K�K�K�K�K�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	
���	�"�"�"��,�*������g����(>�?�?�?�?�?s�A�A�Ac���K�Gd�dt����fd�}|����5|���d{V��ddd��dS#1swxYwYdS)Nc��eZdZdS)�]AsyncioWaitForTest.test_wait_for_reraises_exception_during_cancellation.<locals>.FooExceptionN)rrrrr	r
�FooExceptionrv�s�������Dr	rwc���K��fd�}tj|����}tj|t����d{V��dS)Nc��N�K�	tjd���d{V����#��xYw)Nr)rr)rws�r
r^zcAsyncioWaitForTest.test_wait_for_reraises_exception_during_cancellation.<locals>.foo.<locals>.inner�sC�����'�!�-��,�,�,�,�,�,�,�,�,�&�&��,�&�&�&�&s�!�$rB)rr%r&re)r^rlrws  �r
r=zTAsyncioWaitForTest.test_wait_for_reraises_exception_during_cancellation.<locals>.foo�sf�����
'�
'�
'�
'�
'�!�,�U�U�W�W�5�5�J��"�:�x�@�@�@�@�@�@�@�@�@�@�@�@r	)�	Exceptionr>)rr=rws  @r
�4test_wait_for_reraises_exception_during_cancellationzGAsyncioWaitForTest.test_wait_for_reraises_exception_during_cancellation�s������	�	�	�	�	�9�	�	�	�		A�		A�		A�		A�		A��
�
�|�
,�
,�	�	��#�%�%�K�K�K�K�K�K�K�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�A�A�Ac��K�d�}tj|����}tj|d���}tj|��}tjd���d{V��|���|�tj��5|�d{V��ddd��n#1swxYwY|�|�d{V��d��dS)Nc��K�	tjd���d{V��n`#tj$rN	tjd���d{V��n/#tj$rtjd���d{V��YnwxYwYnwxYwdS)Ng333333�?�*)rrrrr	r
r^zAAsyncioWaitForTest.test_wait_for_self_cancellation.<locals>.inner�s�����
-��m�C�(�(�(�(�(�(�(�(�(�(���)�
-�
-�
-�-�!�-��,�,�,�,�,�,�,�,�,�,���-�-�-�-�!�-��,�,�,�,�,�,�,�,�,�,�,�-������
-�����2s2��A<�A
�	A<�
)A6�3A<�5A6�6A<�;A<rNrBrr~)rr%r&rr'r>rr5)rr^rlr(rYs     r
�test_wait_for_self_cancellationz2AsyncioWaitForTest.test_wait_for_self_cancellation�s0����		�		�		��(�����1�1�
���
�C�8�8�8���"�4�(�(���m�C� � � � � � � � � ����
�
�
�
�
�
�w�5�
6�
6�	�	��J�J�J�J�J�J�J�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	
���z�)�)�)�)�)�)�2�.�.�.�.�.s�	B.�.B2�5B2c����K�tj����fd�}tj|����}tjtj||����}��|j��|�tj��5|�d{V��ddd��n#1swxYwY|�|�	����dS)Nc��D�K�����}|�d{V��dSr)r3)r7r6s �r
�blocking_coroutinezDAsyncioWaitForTest._test_cancel_wait_for.<locals>.blocking_coroutines-������$�$�&�&�C��I�I�I�I�I�I�I�I�Ir	)
rr2r%r&�	call_soonr'r>rr)rI)rrCr�rYr(r6s     @r
�_test_cancel_wait_forz(AsyncioWaitForTest._test_cancel_wait_for�s������'�)�)��	�	�	�	�	�
�"�#5�#5�#7�#7�8�8���"�7�#3�D�'�#B�#B�C�C�����t�{�#�#�#�
�
�
�w�5�
6�
6�	�	��J�J�J�J�J�J�J�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	
������(�(�)�)�)�)�)s�	B-�-B1�4B1c��@K�|�d���d{V��dSr�r�rs r
�test_cancel_blocking_wait_forz0AsyncioWaitForTest.test_cancel_blocking_wait_for�2�����(�(��.�.�.�.�.�.�.�.�.�.�.r	c��@K�|�d���d{V��dS)NgN@r�rs r
�test_cancel_wait_forz'AsyncioWaitForTest.test_cancel_wait_forr�r	N)rrrr,r/r9r?rJrOrUrZr`rorsr{rr�r�r�rr	r
r"r"(s
������	"�	"�	"�"�"�"�	$�	$�	$�
-�
-�
-�5�5�5�:-�-�-�*&�&�&�$�$�$�$�$�$�@�@�@�,@�@�@�2���$/�/�/�6*�*�*�&/�/�/�/�/�/�/�/r	r"�__main__)r�unittestr�testrrrer
�IsolatedAsyncioTestCaser"r�mainrr	r
�<module>r�s���������������������(�(�(�����������.l/�l/�l/�l/�l/��9�l/�l/�l/�^�z����H�M�O�O�O�O�O��r