403Webshell
Server IP : 54.37.205.81  /  Your IP : 216.73.216.76
Web Server : nginx/1.22.1
System : Linux vps-249481fa 6.1.0-50-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.176-1 (2026-07-02) x86_64
User : debian ( 1000)
PHP Version : 8.2.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/tornado/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/tornado/test/__pycache__/ioloop_test.cpython-311.pyc
�

��b�m��Z�ddlZddlmZddlmZddlmZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZddlZddlmZddlmZddlmZmZmZdd	lmZdd
lmZmZmZm Z m!Z!ddl"m#Z#m$Z$m%Z%ddl&m'Z'ddl(Z(e(j)rdd
l(m*Z*Gd�de��Z+Gd�dej,��Z-Gd�de��Z.Gd�de��Z/Gd�dej,��Z0Gd�dej,��Z1Gd�de��Z2Gd�dej,��Z3e4dkrej5��dSdS)�N)�ThreadPoolExecutor)�futures)�	Generator)�mock)�
native_str)�gen)�IOLoop�TimeoutError�PeriodicCallback)�app_log)�
AsyncTestCase�bind_unused_port�	ExpectLog�gen_test�setup_with_context_manager)�ignore_deprecation�
skipIfNonUnix�skipOnTravis)�Future)�Listc��eZdZd�Zed���Zed���Zd�Zd�Zd�Z	d�Z
d�Zd	�Ze
d
���Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Ze
d���Ze
ed�����Z d�Z!dS)�
TestIOLoopc����d|_|j}|�|j���fd�}tj||��|_|�d���|�d���|�t
jd���|j��|�	��|�
|jd��dS)Nrc�@���xjdz
c_�|g|�Ri|��dS�N���calls)�self�callback�args�kwargs�old_add_callback�tests    ���:/usr/lib/python3/dist-packages/tornado/test/ioloop_test.py�add_callbackzBTestIOLoop.test_add_callback_return_sequence.<locals>.add_callback2s9����J�J�!�O�J�J���X�7��7�7�7��7�7�7�7�7�c��iS�N�r*r'r%�<lambda>z>TestIOLoop.test_add_callback_return_sequence.<locals>.<lambda>7���"�r'c��gSr)r*r*r'r%r+z>TestIOLoop.test_add_callback_return_sequence.<locals>.<lambda>8r,r'�2)�milliseconds�
)r�io_loopr&�types�
MethodType�add_timeout�datetime�	timedelta�stop�start�
assertLess)r�loopr&r#r$s   @@r%�!test_add_callback_return_sequencez,TestIOLoop.test_add_callback_return_sequence*s�������
��|�����,��	8�	8�	8�	8�	8�	8�"�,�\�4�@�@������*�*�%�%�%����*�*�%�%�%�����+��<�<�<�d�i�H�H�H��
�
��������
�B�'�'�'�'�'r'c�<����fd����fd�}�j��j���|��������tj���jd������j��dS)Nc�>��d�_����dS�NT)�calledr7�rs�r%r z5TestIOLoop.test_add_callback_wakeup.<locals>.callbackAs����D�K��I�I�K�K�K�K�Kr'c�z��d�_�j����tj���_dS�NF)r?r1r&�time�
start_time)r rs��r%�schedule_callbackz>TestIOLoop.test_add_callback_wakeup.<locals>.schedule_callbackEs1����D�K��L�%�%�h�/�/�/�"�i�k�k�D�O�O�Or'�)�places)r1r4rC�wait�assertAlmostEqualrD�
assertTruer?)rrEr s` @r%�test_add_callback_wakeupz#TestIOLoop.test_add_callback_wakeup=s�����	�	�	�	�	�	*�	*�	*�	*�	*�	*�	
�� � ���!2�!2�!4�!4�6G�H�H�H��	�	�������t�y�{�{�D�O�A��F�F�F������$�$�$�$�$r'c�,���fd�}tj|���}�j�|j������t
j���jz
}��|d��|�	��dS)Nc���tjd��tj���_�j��j��dS)N�{�G�z�?)rC�sleep�	stop_timer1r&r7r@s�r%�targetz@TestIOLoop.test_add_callback_wakeup_other_thread.<locals>.targetRs>����J�t����!�Y�[�[�D�N��L�%�%�d�i�0�0�0�0�0r'�rQ皙�����?)
�	threading�Threadr1r&r8rHrCrPr9�join)rrQ�thread�deltas`   r%�%test_add_callback_wakeup_other_threadz0TestIOLoop.test_add_callback_wakeup_other_threadPs����	1�	1�	1�	1�	1��!��0�0�0����!�!�&�,�/�/�/��	�	�����	���d�n�,������s�#�#�#����
�
�
�
�
r'c��|j�tjd���|j��|���dS)Nr)�microseconds)r1r4r5r6r7rHr@s r%�test_add_timeout_timedeltaz%TestIOLoop.test_add_timeout_timedelta_s;���� � ��!3��!C�!C�!C�T�Y�O�O�O��	�	�����r'c�0�t��\}}	|j�|���d�tj��|�t|jj|���d�tj��|j�|�����|�	��dS#|j�|�����|�	��wxYw)Nc��dSr)r*��fd�eventss  r%r+z.TestIOLoop.test_multiple_add.<locals>.<lambda>gs��$�r'c��dSr)r*r_s  r%r+z.TestIOLoop.test_multiple_add.<locals>.<lambda>os��4�r')
rr1�add_handler�filenor	�READ�assertRaises�	Exception�remove_handler�close�r�sock�ports   r%�test_multiple_addzTestIOLoop.test_multiple_addcs���%�'�'�
��d�	��L�$�$����
�
�6�6���
�
�
�

������(����
�
�'�'���
�
�
�
�L�'�'����
�
�6�6�6��J�J�L�L�L�L�L��
�L�'�'����
�
�6�6�6��J�J�L�L�L�L���s
�A>C�ADc���t��\}}	|j�|�����|���dS#|���wxYwr))rr1rhrdrirjs   r%�test_remove_without_addz"TestIOLoop.test_remove_without_addvsY��&�'�'�
��d�	��L�'�'����
�
�6�6�6��J�J�L�L�L�L�L��D�J�J�L�L�L�L���s�,A�A+c�l�|j�|j��|���dSr))r1�add_callback_from_signalr7rHr@s r%�test_add_callback_from_signalz(TestIOLoop.test_add_callback_from_signals-��	
��-�-�d�i�8�8�8��	�	�����r'c��t��}tj|j���}|���|�|j��|���|���dS)NrR)r	rTrUr8rqr7rVri)r�other_iolooprWs   r%�*test_add_callback_from_signal_other_threadz5TestIOLoop.test_add_callback_from_signal_other_thread�sl���x�x���!��);�<�<�<���������-�-�l�.?�@�@�@����
�
�
��������r'c�"���tj�����fd�}t���tj|���}|�������t
d��D]}��d����dS)Nc������j������������d���dS)NT��all_fds)r&r7r8�setri)�closingrts��r%rQz:TestIOLoop.test_add_callback_while_closing.<locals>.target�sV����%�%�l�&7�8�8�8���� � � ��K�K�M�M�M����t��,�,�,�,�,r'rR��c��dSr)r*r*r'r%r+z<TestIOLoop.test_add_callback_while_closing.<locals>.<lambda>�s��d�r')rT�Eventr	rUr8rH�ranger&)rrQrW�ir{rts    @@r%�test_add_callback_while_closingz*TestIOLoop.test_add_callback_while_closing�s������/�#�#��	-�	-�	-�	-�	-�	-��x�x���!��0�0�0���������������t���	4�	4�A��%�%�l�l�3�3�3�3�	4�	4r'c�t��tj��\}}	�fd�}�j�|���|t
j���j��j���dztj
|jd���������j�
|�����|���|���dS#|���|���wxYw)Nc�p����|tj������dSr))�assertEqualr	rer7)r`rars  �r%�handlerz5TestIOLoop.test_read_while_writeable.<locals>.handler�s,���� � ����5�5�5��	�	�����r'rNsasdf)�socket�
socketpairr1rcrdr	rer4rC�	functools�partial�sendrHrhri)r�client�serverr�s`   r%�test_read_while_writeablez$TestIOLoop.test_read_while_writeable�s	���
 �*�,�,����	�
�
�
�
�
�
�L�$�$�V�]�]�_�_�g�v�{�K�K�K��L�$�$���!�!�#�#�d�*�I�,=�f�k�7�,S�,S�
�
�
�
�I�I�K�K�K��L�'�'��
�
���8�8�8��L�L�N�N�N��L�L�N�N�N�N�N��
�L�L�N�N�N��L�L�N�N�N�N���s�C
D
�
*D7c���|j�|j���|j��}|���|j�|��dSr))r1r4rCr7rH�remove_timeout�r�handles  r%�test_remove_timeout_after_firez)TestIOLoop.test_remove_timeout_after_fire�sR����)�)�$�,�*;�*;�*=�*=�t�y�I�I���	�	������#�#�F�+�+�+�+�+r'c�.��td��D]R}�j��j���dzd���}�j�|���S�j��fd�������dS)Ni�ic��dSr)r*r*r'r%r+z8TestIOLoop.test_remove_timeout_cleanup.<locals>.<lambda>�s��SW�r'c�B���j��j��Sr)�r1r&r7r@s�r%r+z8TestIOLoop.test_remove_timeout_cleanup.<locals>.<lambda>�s���$�,�*C�*C�D�I�*N�*N�r')rr1r4rCr�r&rH)rr��timeouts`  r%�test_remove_timeout_cleanupz&TestIOLoop.test_remove_timeout_cleanup�s�����t���	1�	1�A��l�.�.�t�|�/@�/@�/B�/B�T�/I�<�<�X�X�G��L�'�'��0�0�0�0���!�!�"N�"N�"N�"N�O�O�O��	�	�����r'c�����ddg��j���}���fd�}�j�|dz|���fd�}�j�|dz|����j�|dz�j��tjd���������ddg��dS)NFc�F��d�d<�j����dS�NTr)r1r�)rr�	t2_handles���r%�t1z7TestIOLoop.test_remove_timeout_from_timeout.<locals>.t1�s(����E�!�H��L�'�'�	�2�2�2�2�2r'rNc���d�d<dS)NTrr*rs�r%�t2z7TestIOLoop.test_remove_timeout_from_timeout.<locals>.t2�s����E�!�H�H�Hr'g{�G�z�?g���Q��?T)r1rCr4r7rOrHr�)r�nowr�r�rr�s`   @@r%� test_remove_timeout_from_timeoutz+TestIOLoop.test_remove_timeout_from_timeout�s����������
�l���!�!��	3�	3�	3�	3�	3�	3�	3�	
�� � ��t��R�0�0�0�	�	�	�	�	��L�,�,�S�4�Z��<�<�	��� � ��t��T�Y�7�7�7��
�4�����	�	���������u�
�.�.�.�.�.r'c�F�g}|j�|j���|jd��|j�t	jd���|jd��|j�|j���|jd��|j�d|jd��|j�d|j��|�	��|�
t|��gd���dS)Nrr)�secondsrF��)rrFr�r�)r1r4rC�appendr5r6�call_at�
call_laterr7rHr��sorted)r�resultss  r%�test_timeout_with_argumentsz&TestIOLoop.test_timeout_with_arguments�s������� � ���!2�!2�!4�!4�g�n�a�H�H�H��� � ��!3�A�!>�!>�!>���PQ�R�R�R�����T�\�.�.�0�0�'�.�!�D�D�D������7�>�1�5�5�5������4�9�-�-�-��	�	����	
�������,�,�,�7�7�7�7�7r'c���|j�|j���d���}|�|du��|j�|��dS)Nc��dSr)r*r*r'r%r+z4TestIOLoop.test_add_timeout_return.<locals>.<lambda>�s��t�r')r1r4rC�assertFalser�r�s  r%�test_add_timeout_returnz"TestIOLoop.test_add_timeout_return�s_����)�)�$�,�*;�*;�*=�*=�|�|�L�L������4��(�(�(���#�#�F�+�+�+�+�+r'c���|j�|j���d���}|�|du��|j�|��dS)Nc��dSr)r*r*r'r%r+z0TestIOLoop.test_call_at_return.<locals>.<lambda>�s��4�r')r1r�rCr�r�r�s  r%�test_call_at_returnzTestIOLoop.test_call_at_return�s]����%�%�d�l�&7�&7�&9�&9�<�<�H�H������4��(�(�(���#�#�F�+�+�+�+�+r'c��|j�dd���}|�|du��|j�|��dS)Nrc��dSr)r*r*r'r%r+z3TestIOLoop.test_call_later_return.<locals>.<lambda>�s��D�r')r1r�r�r�r�s  r%�test_call_later_returnz!TestIOLoop.test_call_later_return�sO����(�(��L�L�9�9������4��(�(�(���#�#�F�+�+�+�+�+r'c�$�Gd�dt��}t��\}}||��}t��}|�|d�tj��|�d���|�|j��dS)z�When a file object is used instead of a numeric file descriptor,
        the object should be closed (by IOLoop.close(all_fds=True),
        not just the fd.
        c� �eZdZd�Zd�Zd�ZdS)�8TestIOLoop.test_close_file_object.<locals>.SocketWrapperc�"�||_d|_dSrB)�sockobj�closed)rr�s  r%�__init__zATestIOLoop.test_close_file_object.<locals>.SocketWrapper.__init__
s��&���#����r'c�4�|j���Sr))r�rdr@s r%rdz?TestIOLoop.test_close_file_object.<locals>.SocketWrapper.filenos���|�*�*�,�,�,r'c�F�d|_|j���dSr>)r�r�rir@s r%riz>TestIOLoop.test_close_file_object.<locals>.SocketWrapper.closes#��"�����"�"�$�$�$�$�$r'N)�__name__�
__module__�__qualname__r�rdrir*r'r%�
SocketWrapperr�	sA������
$�
$�
$�
-�
-�
-�
%�
%�
%�
%�
%r'r�c��dSr)r*r_s  r%r+z3TestIOLoop.test_close_file_object.<locals>.<lambda>s��t�r'TrxN)�objectrr	rcrerirJr�)rr�r�rl�socket_wrapperr1s      r%�test_close_file_objectz!TestIOLoop.test_close_file_objects���
	%�
	%�
	%�
	%�
	%�F�
	%�
	%�
	%�)�*�*�
���&��w�/�/���(�(�����N�,C�,C�V�[�Q�Q�Q��
�
�d�
�#�#�#�����-�.�.�.�.�.r'c������t��\�}g����fd�}�j��|tj��tjtj����5}|�d|f����	��ddd��n#1swxYwY�j�
����j�����|tj��tjtj����5}|�d|f����	��ddd��n#1swxYwY���d�����
�d�������j�
����������dS)z>The handler callback receives the same fd object it passed in.c�����|������\}}|�������dSr))r��acceptrir7)r`ra�conn�addr�fdsr�server_socks    ���r%�handle_connectionzGTestIOLoop.test_handler_callback_file_object.<locals>.handle_connection!sE����J�J�r�N�N�N�$�+�+�-�-�J�D�$��J�J�L�L�L��I�I�K�K�K�K�Kr'z	127.0.0.1Nrr)rr1rcr	re�
contextlibr{r��connectrHrhrd�assertIsr�ri)rrlr��client_sockr�r�s`   @@r%�!test_handler_callback_file_objectz,TestIOLoop.test_handler_callback_file_objects5�����,�.�.���T���	�	�	�	�	�	�	�	
�� � ��.?���M�M�M�
�
��
���
0�
0�	�K�����d� 3�4�4�4��I�I�K�K�K�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	
��#�#�K�0�0�0��� � ��!3�!3�!5�!5�7H�&�+�V�V�V�
�
��
���
0�
0�	�K�����d� 3�4�4�4��I�I�K�K�K�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	
�
�
�c�!�f�k�*�*�*�����Q���!3�!3�!5�!5�6�6�6���#�#�K�$6�$6�$8�$8�9�9�9��������s$�),B!�!B%�(B%�#,E�E�"Ec���t��\}}d�}|j�||tj��|�t��5|j�|���|tj��ddd��n#1swxYwY|j�|�����|�	��dS)Nc��dSr)r*r_s  r%�fz+TestIOLoop.test_mixed_fd_fileobj.<locals>.f8s���Dr')
rr1rcr	rerfrgrdrhri)rr�rlr�s    r%�test_mixed_fd_fileobjz TestIOLoop.test_mixed_fd_fileobj5s��,�.�.���T�	�	�	�	
�� � ��a���=�=�=�
�
�
�y�
)�
)�	K�	K�
�L�$�$�[�%7�%7�%9�%9�1�f�k�J�J�J�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K����	K�	K�	K�	K�	
��#�#�K�$6�$6�$8�$8�9�9�9��������s�9B�B�!Bc������dg�dg����fd�}�j�|���������d�����d��dS)z:Calling start() twice should raise an error, not deadlock.Fc���	�j���d�d<n#t$rd�d<YnwxYw����dSr�)r1r8rgr7)�
got_exception�returned_from_startrs���r%r z+TestIOLoop.test_reentrant.<locals>.callbackHsf���
(���"�"�$�$�$�)-�#�A�&�&���
(�
(�
(�#'�
�a� � � �
(�����I�I�K�K�K�K�Ks�"�4�4rN)r1r&rHrJr�)rr r�r�s` @@r%�test_reentrantzTestIOLoop.test_reentrantCs������$�g����
�	�	�	�	�	�	�	�	
��!�!�(�+�+�+��	�	�������
�a�(�)�)�)����,�Q�/�0�0�0�0�0r'c��|j�d���|j�|j��ttd��5|���ddd��dS#1swxYwYdS)z-Uncaught exceptions get logged by the IOLoop.c��ddzS�Nrrr*r*r'r%r+z3TestIOLoop.test_exception_logging.<locals>.<lambda>W�
��!�a�%�r'�Exception in callbackN)r1r&r7rrrHr@s r%�test_exception_loggingz!TestIOLoop.test_exception_loggingUs�����!�!�-�-�0�0�0���!�!�$�)�,�,�,�
�w� 7�
8�
8�	�	��I�I�K�K�K�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�A2�2A6�9A6c����tj�fd���}�j�|��t	t
d��5����ddd��dS#1swxYwYdS)z:The IOLoop examines exceptions from Futures and logs them.c�P���j��j��ddzdSr�r�r@s�r%r z:TestIOLoop.test_exception_logging_future.<locals>.callback_s(����L�%�%�d�i�0�0�0�
��E�E�E�Er'r�N)r�	coroutiner1r&rrrH�rr s` r%�test_exception_logging_futurez(TestIOLoop.test_exception_logging_future\s����

��	�	�	�	�
��	�	
��!�!�(�+�+�+�
�w� 7�
8�
8�	�	��I�I�K�K�K�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�A*�*A.�1A.c�����fd�}�j�|��ttd��5����ddd��dS#1swxYwYdS)z=The IOLoop examines exceptions from awaitables and logs them.c��j�K��j��jj�j��ddzdSr�r�r@s�r%r z?TestIOLoop.test_exception_logging_native_coro.<locals>.callbackks5�����
�L�%�%�d�l�&?���K�K�K�
��E�E�E�Er'r�N)r1r&rrrHr�s` r%�"test_exception_logging_native_coroz-TestIOLoop.test_exception_logging_native_corohs����	�	�	�	�	�	
��!�!�(�+�+�+�
�w� 7�
8�
8�	�	��I�I�K�K�K�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�A�A�Ac���|j�d���|j�|j��ttd��5|���ddd��n#1swxYwY|j�d���|j�|j��ttd��5|���ddd��dS#1swxYwYdS)Nc��ddzSr�r*r*r'r%r+z0TestIOLoop.test_spawn_callback.<locals>.<lambda>xr�r'r�c��ddzSr�r*r*r'r%r+z0TestIOLoop.test_spawn_callback.<locals>.<lambda>~s
��A��E�r')r1r&r7rrrH�spawn_callbackr@s r%�test_spawn_callbackzTestIOLoop.test_spawn_callbackus[��	
��!�!�-�-�0�0�0���!�!�$�)�,�,�,�
�w� 7�
8�
8�	�	��I�I�K�K�K�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	
��#�#�M�M�2�2�2���!�!�$�)�,�,�,�
�w� 7�
8�
8�	�	��I�I�K�K�K�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s$�A1�1A5�8A5�C-�-C1�4C1c�|�����tj��\��	��d����d��g�����fd�}�j��|�jj���j��|�jj���j�d�j��������	�dg����
����
��dS#��
����
��wxYw)Nsabcc������|�d����|�ur�j����dS�j����dS)Ni)r��recvr1rh)r`ra�chunksr�rr�s  ����r%�handle_readz@TestIOLoop.test_remove_handler_from_handler.<locals>.handle_read�s`����
�
�b�g�g�d�m�m�,�,�,���<�<��L�/�/��7�7�7�7�7��L�/�/��7�7�7�7�7r'rS)r�r�r�r1rcrer�r7rHr�ri)rr�r�r�r�s` @@@r%� test_remove_handler_from_handlerz+TestIOLoop.test_remove_handler_from_handler�s3������ �*�,�,����	��K�K������K�K������F�
8�
8�
8�
8�
8�
8�
8�
8�
�L�$�$�V�[�$�,�:K�L�L�L��L�$�$�V�[�$�,�:K�L�L�L��L�#�#�C���3�3�3��I�I�K�K�K�
���V�f�X�.�.�.��L�L�N�N�N��L�L�N�N�N�N�N��
�L�L�N�N�N��L�L�N�N�N�N���s�CD�*D;c#�t��K�d��tj��fd�td��D����V�dS)Nc�r�td��D]&}td���}|����'dS)Nr0F��make_current)rr	ri)r�r:s  r%r�z*TestIOLoop.test_init_close_race.<locals>.f�s@���2�Y�Y�
�
���5�1�1�1���
�
�����
�
r'c�F��g|]}�j�d�����Sr))r1�run_in_executor)�.0r�r�rs  ��r%�
<listcomp>z3TestIOLoop.test_init_close_race.<locals>.<listcomp>�s+���Q�Q�Q�1���5�5�d�A�>�>�Q�Q�Qr'rF)r�multir�rr�s`@r%�test_init_close_racezTestIOLoop.test_init_close_race�sS������	�	�	�
�i�Q�Q�Q�Q�Q��a���Q�Q�Q�R�R�R�R�R�R�Rr'c��tj��}t|d���}|j|usJ�|�t
��5t|d���ddd��n#1swxYwY|���dS)NF)�asyncio_loopr�)�asyncio�new_event_loopr	rrf�RuntimeErrorri)rrr:s   r%�test_explicit_asyncio_loopz%TestIOLoop.test_explicit_asyncio_loop�s����-�/�/���<�e�D�D�D��� �L�0�0�0�0�
�
�
�|�
,�
,�	B�	B���5�A�A�A�A�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B����	B�	B�	B�	B�	
�
�
�����s�
A(�(A,�/A,N)"r�r�r�r;rrKrYr\rmrorrrur�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr*r'r%rr)s������(�(�(�&�%�%��\�%�$����\��������&������	�	�	�4�4�4�&����]��*,�,�,����/�/�/�.8�8�8�,�,�,�,�,�,�
,�,�,�
/�/�/�6���2���1�1�1�$���
�
�
�����������]��8�
�S�S��X��]�S�����r'rc�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�TestIOLoopCurrentc�r�t|t����d|_tj��dSr))rrr1r	�
clear_currentr@s r%�setUpzTestIOLoopCurrent.setUp�s5��"�4�);�)=�)=�>�>�>����������r'c�J�|j�|j���dSdSr)�r1rir@s r%�tearDownzTestIOLoopCurrent.tearDown�s,���<�#��L��� � � � � �$�#r'c� �t��|_|�|jtj����t��}|�|jtj����|���dSr))r	r1r��currentri)r�io_loop2s  r%�test_default_currentz&TestIOLoopCurrent.test_default_current�sh���x�x����
�
�d�l�F�N�$4�$4�5�5�5��8�8���
�
�d�l�F�N�$4�$4�5�5�5��������r'c���td����_��tjd�����t	d��D]�}�fd�}�j�|���j������j�j����tjd�������dS)NFr�)�instancer�c�|��tj���_�j�J��j���dSr))r	r�current_io_loopr1r7r@s�r%r�z-TestIOLoopCurrent.test_non_current.<locals>.f�s;���'-�~�'7�'7��$��|�/�/�/���!�!�#�#�#�#�#r')	r	r1�assertIsNonerrr&r8r�r)rr�r�s`  r%�test_non_currentz"TestIOLoopCurrent.test_non_current�s�����5�1�1�1������&�.�%�8�8�8�9�9�9��q���	>�	>�A�
$�
$�
$�
$�
$�

�L�%�%�a�(�(�(��L��� � � ��M�M�$�.���=�=�=����f�n�e�<�<�<�=�=�=�=�	>�	>r'c�d�td���|_|�|jtj����|�t
��5td���ddd��n#1swxYwY|�|jtj����dS)NTr�)r	r1r�rrfrr@s r%�test_force_currentz$TestIOLoopCurrent.test_force_current�s����4�0�0�0����
�
�d�l�F�N�$4�$4�5�5�5�
�
�
�|�
,�
,�	&�	&���%�%�%�%�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&�	
�
�
�d�l�F�N�$4�$4�5�5�5�5�5s�A9�9A=�A=N)r�r�r�rrrrrr*r'r%rr�s_���������
!�!�!����>�>�>�&6�6�6�6�6r'rc�4��eZdZ�fd�Zed���Z�xZS)�TestIOLoopCurrentAsyncc���t�����t|t����dSr))�superrrr)r�	__class__s �r%rzTestIOLoopCurrentAsync.setUp�s1���
���
�
����"�4�);�)=�)=�>�>�>�>�>r'c#�K�td��5}|�tj��V�ddd��dS#1swxYwYdSr)r�submitr	r
)r�es  r%�test_clear_without_currentz1TestIOLoopCurrentAsync.test_clear_without_current�s�����
 ��
"�
"�	1�a��(�(�6�/�0�0�0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�	1�	1s�"A�A�A)r�r�r�rrr#�
__classcell__)rs@r%rr�sS�������?�?�?�?�?��1�1��X�1�1�1�1�1r'rc�V�eZdZd�Zed���Zed���Zed���ZdS)�TestIOLoopFuturesc���tjd��5}d�}�j�|�|���fd�������}��|�������|���du��ddd��dS#1swxYwYdS)Nrc��dSr)r*r*r'r%�dummyz8TestIOLoopFutures.test_add_future_threads.<locals>.dummy�s���r'c�.����|��Sr)�r7)�futurers �r%r+z;TestIOLoopFutures.test_add_future_threads.<locals>.<lambda>s���4�9�9�V�3D�3D�r')	rrr1�
add_futurer!rHrJ�done�result)r�poolr)r,s`   r%�test_add_future_threadsz)TestIOLoopFutures.test_add_future_threads�s���
�
'��
*�
*�
	5�d�
�
�
�
�L�#�#����E�"�"�$D�$D�$D�$D�
�
�
��Y�Y�[�[�F��O�O�F�K�K�M�M�*�*�*��O�O�F�M�M�O�O�t�3�4�4�4�
	5�
	5�
	5�
	5�
	5�
	5�
	5�
	5�
	5�
	5�
	5�
	5����
	5�
	5�
	5�
	5�
	5�
	5s�BB<�<C�Cc#�4K�tj��}tj��}d�}tj���d|||��tj���d|||��gV�}|�||g|��dS)Nc�V�|���|���|Sr)�rzrH��
self_event�other_events  r%�	sync_funcz=TestIOLoopFutures.test_run_in_executor_gen.<locals>.sync_funcs,���N�N�����������r')rTr~r	rr�r�)r�event1�event2r8�ress     r%�test_run_in_executor_genz*TestIOLoopFutures.test_run_in_executor_gens�������"�"����"�"��	�	�	�
�N���,�,�T�9�f�f�M�M��N���,�,�T�9�f�f�M�M�
�
�
��
	
���&�&�)�3�/�/�/�/�/r'c#���K�tj��}tj��}d���fd�}|||��|||��gV�}|�||g|��dS)Nc�V�|���|���|Sr)r4r5s  r%r8z@TestIOLoopFutures.test_run_in_executor_native.<locals>.sync_func"s*���N�N�����������r'c��f�K�tj���d�||���d{V��Sr))r	rr�)r6r7r8s  �r%�
async_wrapperzDTestIOLoopFutures.test_run_in_executor_native.<locals>.async_wrapper*sN�������)�)�9�9��i��[���������
r')rTr~r�)rr9r:r@r;r8s     @r%�test_run_in_executor_nativez-TestIOLoopFutures.test_run_in_executor_natives��������"�"����"�"��	�	�	�	�	�	�	�	�
#�]�6�6�2�2�M�M�&�&�4Q�4Q�R�R�R�����&�&�)�3�/�/�/�/�/r'c#���K�dg�G�fd�dtj��}tj����fd�}|d��}t	j��}|�|��|�d|��V�|�d�d��|�	��
����dS)Nrc�"���eZdZ��fd�Z�xZS)�?TestIOLoopFutures.test_set_default_executor.<locals>.MyExecutorc�X���dxxdz
cc<t��j|g|�R�S)Nrr)rr!)r�funcr!r�counts   ��r%r!zFTestIOLoopFutures.test_set_default_executor.<locals>.MyExecutor.submit8s6����a����A�
����%�u�w�w�~�d�2�T�2�2�2�2r')r�r�r�r!r$)rrGs@�r%�
MyExecutorrD7s>��������
3�
3�
3�
3�
3�
3�
3�
3�
3�
3r'rHc�0������dSr))rz)�events�r%r8z>TestIOLoopFutures.test_set_default_executor.<locals>.sync_func>s����I�I�K�K�K�K�Kr'r)rrrTr~r	r�set_default_executorr�r�rJ�is_set)rrHr8�executorr:rGrJs     @@r%�test_set_default_executorz+TestIOLoopFutures.test_set_default_executor3s����������	3�	3�	3�	3�	3�	3�	3��3�	3�	3�	3�
��!�!��	�	�	�	�	��:�a�=�=���~�����!�!�(�+�+�+��"�"�4��3�3�3�3�3�����E�!�H�%�%�%���������'�'�'�'�'r'N)r�r�r�r1rr<rArNr*r'r%r&r&�st������5�5�5��0�0��X�0�*�0�0��X�0�*�(�(��X�(�(�(r'r&c�D�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
S)�TestIOLoopRunSyncc�0�td���|_dS)NFr�)r	r1r@s r%rzTestIOLoopRunSync.setUpJs���5�1�1�1����r'c�8�|j���dSr)r
r@s r%rzTestIOLoopRunSync.tearDownMs����������r'c��|�tj��5|j�d���ddd��dS#1swxYwYdS)Nc��dS�N�*r*r*r'r%r+z4TestIOLoopRunSync.test_sync_result.<locals>.<lambda>Rs��"�r')rfr�
BadYieldErrorr1�run_syncr@s r%�test_sync_resultz"TestIOLoopRunSync.test_sync_resultPs���
�
�
�s�0�
1�
1�	.�	.��L�!�!�*�*�-�-�-�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�	.�	.s�A	�	A
�A
c��|�t��5|j�d���ddd��dS#1swxYwYdS)Nc��ddzSr�r*r*r'r%r+z7TestIOLoopRunSync.test_sync_exception.<locals>.<lambda>Vr�r')rf�ZeroDivisionErrorr1rXr@s r%�test_sync_exceptionz%TestIOLoopRunSync.test_sync_exceptionTs���
�
�
�0�
1�
1�	1�	1��L�!�!�-�-�0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�	1�	1s�A�A�Ac��tjd���}|�|j�|��d��dS)Nc3�JK�tjV�tjd���rU)r�moment�Returnr*r'r%r�z.TestIOLoopRunSync.test_async_result.<locals>.fYs"�����*�����*�R�.�.� r'rV)rr�r�r1rXr�s  r%�test_async_resultz#TestIOLoopRunSync.test_async_resultXsK��	��	!�	!�
��	!�	
�����.�.�q�1�1�2�6�6�6�6�6r'c���tjd���}|�t��5|j�|��ddd��dS#1swxYwYdS)Nc3�0K�tjV�ddzdSr��rr`r*r'r%r�z1TestIOLoopRunSync.test_async_exception.<locals>.fas!�����*����
��E�E�E�Er')rr�rfr\r1rXr�s  r%�test_async_exceptionz&TestIOLoopRunSync.test_async_exception`s���	��	�	�
��	��
�
�0�
1�
1�	%�	%��L�!�!�!�$�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�	%�	%s�A�A�Ac�F���fd�}�j�|��dS)Nc�`����tj���j��dSr))r�r	rr1r@s�r%r�z)TestIOLoopRunSync.test_current.<locals>.fjs'����M�M�&�.�*�*�D�L�9�9�9�9�9r')r1rXr�s` r%�test_currentzTestIOLoopRunSync.test_currentis:���	:�	:�	:�	:�	:�	
����a� � � � � r'c��tjd���}|�t|jj|d���dS)Nc3�6K�tjd��V�dSr)rrOr*r'r%r�z)TestIOLoopRunSync.test_timeout.<locals>.fps �����)�A�,�,�����r'rN)r�)rr�rfr
r1rXr�s  r%�test_timeoutzTestIOLoopRunSync.test_timeoutosG��	��	�	�
��	�	
���,���(=�q�$��O�O�O�O�Or'c�p��tjd�����fd�}|j�|��dS)Nc3�&K�tjV�dSr)rer*r'r%�f1z3TestIOLoopRunSync.test_native_coroutine.<locals>.f1ws�����*�����r'c��,�K�����d{V��dSr)r*)ros�r%�f2z3TestIOLoopRunSync.test_native_coroutine.<locals>.f2{s"������"�$�$�J�J�J�J�J�J�J�J�Jr')rr�r1rX)rrqros  @r%�test_native_coroutinez'TestIOLoopRunSync.test_native_coroutinevsU���	��	�	�
��	�	�	�	�	�	�	
����b�!�!�!�!�!r'N)r�r�r�rrrYr]rbrfrirlrrr*r'r%rPrPIs�������2�2�2����.�.�.�1�1�1�7�7�7�%�%�%�!�!�!�P�P�P�"�"�"�"�"r'rPc�8�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	dS)	�TestPeriodicCallbackMathc��g}d}||_|D];}|�|��|�|j��|j|z}�<|S)a9Simulate a series of calls to the PeriodicCallback.

        Pass a list of call durations in seconds (negative values
        work to simulate clock adjustments during the call, or more or
        less equivalently, between calls). This method returns the
        times at which each call would be made.
        r|)�
_next_timeout�_update_nextr�)r�pc�	durationsrr��ds      r%�simulate_callsz'TestPeriodicCallbackMath.simulate_calls�s`����������	'�	'�A��O�O�C� � � ��L�L��)�*�*�*��"�Q�&�C�C��r'c��dSr)r*r@s r%r)zTestPeriodicCallbackMath.dummy�s���r'c��t|jd��}|�|�|dgdz��gd���dS)N�'r������i��rr)r�r{�rrxs  r%�
test_basicz#TestPeriodicCallbackMath.test_basic�sW��
�d�j�%�
0�
0���������Q�C�!�G�,�,�.L�.L�.L�	
�	
�	
�	
�	
r'c��gd�}gd�}t|jd��}|�|�||��|��dS)N)�	r�r0��r��#r�rrr)r�r�r�r�i.iLiji�i�i�i�r~r�)r�call_durations�expectedrxs    r%�test_overrunz%TestPeriodicCallbackMath.test_overrun�s`��A�@�@��
�
�
���d�j�%�
0�
0������,�,�R��@�@�(�K�K�K�K�Kr'c���t|jd��}|�|�|gd���gd���|�|�|gd���gd���dS)Nr~)���������r�rr�)i����rr)r�r�r�r�r�s  r%�test_clock_backwardsz-TestPeriodicCallbackMath.test_clock_backwards�s���
�d�j�%�
0�
0��
	
�������$7�$7�$7�8�8�:X�:X�:X�	
�	
�	
�	
����,�,�R����>�>�@R�@R�@R�S�S�S�S�Sr'c�&��gd��gd�}dgt���z}t|jdd���}�fd�}tjd|��5|�|�||��|��ddd��dS#1swxYwYdS)	N)��?rrg�?)r�g�@r�gE�@rr~r�)�jitterc�.����d��S)Nr)�pop)�random_timess�r%�mock_randomz9TestPeriodicCallbackMath.test_jitter.<locals>.mock_random�s����#�#�A�&�&�&r'z
random.random)�lenrr)r�patchr�r{)rr�r�rxr�r�s     @r%�test_jitterz$TestPeriodicCallbackMath.test_jitter�s���(�(�(��0�0�0����s�<�0�0�0��
�d�j�%��
<�
<�
<��	'�	'�	'�	'�	'��Z���
5�
5�	P�	P����T�0�0��^�D�D�h�O�O�O�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P����	P�	P�	P�	P�	P�	Ps�+B�B
�
B
c��td�tjdd�����}d}|�|j|��dS)Nc��dSr)r*r*r'r%r+z9TestPeriodicCallbackMath.test_timedelta.<locals>.<lambda>�s��d�r'r�)�minutesr�i8D)rr5r6r��
callback_time)rrx�expected_callback_times   r%�test_timedeltaz'TestPeriodicCallbackMath.test_timedelta�sJ��
�l�l�H�,>�q�RT�,U�,U�,U�
V�
V��!&������)�+A�B�B�B�B�Br'N)
r�r�r�r{r)r�r�r�r�r�r*r'r%rtrt�s����������"
�
�
�
�
�
�L�L�L�*T�T�T�"
P�
P�
P�C�C�C�C�Cr'rtc�$�eZdZd�Zdd�Zdd�ZdS)�TestPeriodicCallbackAsyncc�����d�d��fd�}t|d��}|�������|������d��dS)Nr�returnc�J���dz
��dkr����dSdS)Nrr�r+)rGrs��r%r z?TestPeriodicCallbackAsync.test_periodic_plain.<locals>.callback�s-����Q�J�E���z�z��	�	�������zr'r0r��r�N)rr8rHr7r�)rr rxrGs`  @r%�test_periodic_plainz-TestPeriodicCallbackAsync.test_periodic_plain�s�������	�	�	�	�	�	�	��h��
+�
+��
���
�
�
��	�	����
���	�	�	������"�"�"�"�"r'r�Nc�(����ddg�tjd���fd���}t|d��������������dd�����dd��dS)	Nrr��%Generator[Future[None], object, None]c3��K��dxxdz
cc<tjd��V��dxxdz
cc<�ddkr5�����j��j��dSdS�Nrrg�������?r��rrOr7r1r&��countsrxrs���r%r z>TestPeriodicCallbackAsync.test_periodic_coro.<locals>.callback�s�������1�I�I�I��N�I�I�I��)�E�"�"�"�"�"��1�I�I�I��N�I�I�I��a�y�A�~�~����	�	�	���)�)�$�)�4�4�4�4�4��~r'r0r�r)r�r�)rr�rr8rHr��rr r�rxs` @@r%�test_periodic_coroz,TestPeriodicCallbackAsync.test_periodic_coro�s�������Q���	��	5�	5�	5�	5�	5�	5�	5�
��	5��h��
+�
+��
���
�
�
��	�	����������A�&�&�&�������A�&�&�&�&�&r'c�����ddg�d���fd�}t|d��������������dd�����dd��dS)Nrr�c���K��dxxdz
cc<tjd���d{V���dxxdz
cc<�ddkr5�����j��j��dSdSr�r�r�s���r%r z?TestPeriodicCallbackAsync.test_periodic_async.<locals>.callback�s�������1�I�I�I��N�I�I�I��)�E�"�"�"�"�"�"�"�"�"��1�I�I�I��N�I�I�I��a�y�A�~�~����	�	�	���)�)�$�)�4�4�4�4�4��~r'r0r�rr�)rr8rHr�r�s` @@r%�test_periodic_asyncz-TestPeriodicCallbackAsync.test_periodic_async�s�������Q���	5�	5�	5�	5�	5�	5�	5�	5��h��
+�
+��
���
�
�
��	�	����������A�&�&�&�������A�&�&�&�&�&r'r�)r�r�r�r�r�r�r*r'r%r�r��sK������
#�
#�
#�'�'�'�'�$'�'�'�'�'�'r'r�c�&�eZdZd�Zd�Zd�Zd�ZdS)�TestIOLoopConfigurationc���ddgt|��z}tjdd�|��g}t	tj|�������S)Nz!from tornado.ioloop import IOLoopz*classname = lambda x: x.__class__.__name__z-cz; )�list�sys�
executablerVr�
subprocess�check_output�strip)r�
statements�	stmt_listr!s    r%�
run_pythonz"TestIOLoopConfiguration.run_python	sb��/�8�
�
�����	����d�i�i�	�&:�&:�;���*�1�$�7�7�8�8�>�>�@�@�@r'c��|�d��}|�|d��|�d��}|�|d��dS)N�"print(classname(IOLoop.current()))�AsyncIOMainLoopzprint(classname(IOLoop()))�AsyncIOLoop�r�r��r�clss  r%�test_defaultz$TestIOLoopConfiguration.test_defaultsY���o�o�B�C�C������/�0�0�0��o�o�:�;�;������m�,�,�,�,�,r'c�^�|�dd��}|�|d��dS)Nz8IOLoop.configure("tornado.platform.asyncio.AsyncIOLoop")r�r�r�r�s  r%�test_asyncioz$TestIOLoopConfiguration.test_asyncios:���o�o�F�0�
�
��	
����/�0�0�0�0�0r'c�`�|�ddd��}|�|d��dS)Nz4from tornado.platform.asyncio import AsyncIOMainLoopzAsyncIOMainLoop().install()r�r�r�r�s  r%�test_asyncio_mainz)TestIOLoopConfiguration.test_asyncio_mains=���o�o�B�)�0�
�
��
	
����/�0�0�0�0�0r'N)r�r�r�r�r�r�r�r*r'r%r�r�sS������A�A�A�-�-�-�1�1�1�1�1�1�1�1r'r��__main__)6r�concurrent.futuresr�
concurrentr�collections.abcrr�r5r�r�r�r�rTrCr2�unittestr�tornado.escaper�tornador�tornado.ioloopr	r
r�tornado.logr�tornado.testingr
rrrr�tornado.test.utilrrr�tornado.concurrentr�typing�
TYPE_CHECKINGrr�TestCaserrr&rPrtr�r�r��mainr*r'r%�<module>r�sk������1�1�1�1�1�1�������%�%�%�%�%�%�������������
�
�
�
�����
�
�
�
�����������������������%�%�%�%�%�%�������A�A�A�A�A�A�A�A�A�A�������������������������������
&�%�%�%�%�%�
�
�
�
�	���������M�M�M�M�M��M�M�M�d-6�-6�-6�-6�-6��)�-6�-6�-6�`1�1�1�1�1�]�1�1�1�M(�M(�M(�M(�M(�
�M(�M(�M(�`5"�5"�5"�5"�5"��)�5"�5"�5"�pPC�PC�PC�PC�PC�x�0�PC�PC�PC�f1'�1'�1'�1'�1'�
�1'�1'�1'�h1�1�1�1�1�h�/�1�1�1�@�z����H�M�O�O�O�O�O��r'

Youez - 2016 - github.com/yon3zu
LinuXploit