AlkantarClanX12

Your IP : 3.133.108.172


Current Path : /opt/alt/python311/lib64/python3.11/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/asyncio/__pycache__/base_events.cpython-311.opt-1.pyc

�

c��fx&��6�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZ	ddlZn
#e$rdZYnwxYwddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlm Z ddl!m"Z"dZ#dZ$dZ%e&e
d��Z'dZ(d�Z)d�Z*d�Z+d%d�Z,d&d�Z-d�Z.e&e
d��rd�Z/nd�Z/d�Z0Gd�d ej1��Z2Gd!�d"ej3��Z4Gd#�d$ej5��Z6dS)'a�Base implementation of event loop.

The event loop can be broken up into a multiplexer (the part
responsible for notifying us of I/O events) and the event loop proper,
which wraps a multiplexer with functionality for scheduling callbacks,
immediately or at a given time in the future.

Whenever a public API takes a callback, subsequent positional
arguments will be passed to the callback if/when it is called.  This
avoids the proliferation of trivial lambdas implementing closures.
Keyword arguments for the callback are not supported; this is a
conscious design decision, leaving the door open for keyword arguments
to modify the meaning of the API call itself.
�N�)�	constants)�
coroutines)�events)�
exceptions)�futures)�	protocols)�sslproto)�	staggered)�tasks)�
transports)�trsock)�logger)�
BaseEventLoop�Server�dg�?�AF_INET6i�Qc��|j}tt|dd��tj��rt|j��St|��S)N�__self__)�	_callback�
isinstance�getattrr�Task�reprr�str)�handle�cbs  �:/opt/alt/python311/lib64/python3.11/asyncio/base_events.py�_format_handlerGsF��	�	�B��'�"�j�$�/�/���<�<���B�K� � � ��6�{�{��c�h�|tjkrdS|tjkrdSt|��S)Nz<pipe>z<stdout>)�
subprocess�PIPE�STDOUTr)�fds r�_format_piper&Ps2��	�Z�_����x�	�z� �	 �	 ��z��B�x�x�r c���ttd��std���	|�tjtjd��dS#t$rtd���wxYw)N�SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)�hasattr�socket�
ValueError�
setsockopt�
SOL_SOCKETr(�OSError��socks r�_set_reuseportr1Ys����6�>�*�*�J��D�E�E�E�	J��O�O�F�-�v�/B�A�F�F�F�F�F���	J�	J�	J��I�J�J�
J�	J���s�+A�A-c	�^�ttd��sdS|dtjtjhvs|�dS|tjkr
tj}n|tjkr
tj}ndS|�d}net
|t��r	|dkrd}nGt
|t��r	|dkrd}n)	t|��}n#ttf$rYdSwxYw|tjkr4tj
g}tr|�tj��n|g}t
|t��r|�d��}d|vrdS|D]V}	tj||��tr|tjkr
|||d||||ffcS|||d||ffcS#t&$rY�SwxYwdS)N�	inet_ptonrr ��idna�%)r)r*�IPPROTO_TCP�IPPROTO_UDP�SOCK_STREAM�
SOCK_DGRAMr�bytesr�int�	TypeErrorr+�	AF_UNSPEC�AF_INET�	_HAS_IPv6�appendr�decoder3r.)	�host�port�family�type�proto�flowinfo�scopeid�afs�afs	         r�_ipaddr_inforLds���6�;�'�'�����Q��*�F�,>�?�?�?��L��t��v�!�!�!��"���	
��"�	"�	"��"����t��|����	�D�%�	 �	 �	�T�S�[�[����	�D�#�	�	��4�2�:�:����	��t�9�9�D�D���:�&�	�	�	��4�4�	������!�!�!��~����	(��J�J�v��'�'�'���h���$����#��{�{�6�"�"��
�d�{�{��t��	�	��	���R��&�&�&��
9�R�6�?�2�2��4���T�4��7�,K�K�K�K�K��4���T�4�L�8�8�8�8���	�	�	��D�	�����4s*�5C�C�C�6F�F�
F*�)F*c���tj��}|D].}|d}||vrg||<||�|���/t|�����}g}|dkr4|�|dd|dz
���|dd|dz
�=|�d�tj�t
j	|���D����|S)z-Interleave list of addrinfo tuples by family.rrNc3�K�|]}|�|V��	dS�N�)�.0�as  r�	<genexpr>z(_interleave_addrinfos.<locals>.<genexpr>�s0�������
�]�	
�
�]�]�]��r )
�collections�OrderedDictrA�list�values�extend�	itertools�chain�
from_iterable�zip_longest)�	addrinfos�first_address_family_count�addrinfos_by_family�addrrE�addrinfos_lists�	reordereds       r�_interleave_addrinfosrc�s$��&�1�3�3���1�1���a����,�,�,�*,���'��F�#�*�*�4�0�0�0�0��.�5�5�7�7�8�8�O��I�!�A�%�%������+�,K�-G�!�-K�,K�L�M�M�M��A��>� :�Q� >�>�?�
������?�0�0��!�?�3�
�
��������r c���|���s2|���}t|ttf��rdStj|�����dSrO)�	cancelled�	exceptionr�
SystemExit�KeyboardInterruptr�	_get_loop�stop)�fut�excs  r�_run_until_complete_cbrm�sa���=�=�?�?���m�m�o�o���c�J�(9�:�;�;�	�
�F���c�����!�!�!�!�!r �TCP_NODELAYc��|jtjtjhvrW|jtjkrD|jtjkr1|�tjtj	d��dSdSdSdS�Nr)
rEr*r?rrFr9rGr7r,rnr/s r�_set_nodelayrq�sn���K�F�N�F�O�<�<�<��	�V�/�/�/��
�f�0�0�0��O�O�F�.��0B�A�F�F�F�F�F�
=�<�/�/�0�0r c��dSrOrPr/s rrqrq�s���r c�j�t�)t|tj��rtd���dSdS)Nz"Socket cannot be of type SSLSocket)�sslr�	SSLSocketr=r/s r�_check_ssl_socketrv�s1��
��:�d�C�M�:�:���<�=�=�=����r c�D�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
S)�_SendfileFallbackProtocolc��t|tj��std���||_|���|_|���|_|j	|_
|���|�|��|j
r%|jj
���|_dSd|_dS)Nz.transport should be _FlowControlMixin instance)rr
�_FlowControlMixinr=�
_transport�get_protocol�_proto�
is_reading�_should_resume_reading�_protocol_paused�_should_resume_writing�
pause_reading�set_protocol�_loop�
create_future�_write_ready_fut)�self�transps  r�__init__z"_SendfileFallbackProtocol.__init__�s����&�*�">�?�?�	N��L�M�M�M� ����)�)�+�+���&,�&7�&7�&9�&9��#�&,�&=��#����������D�!�!�!��&�	)�$(�O�$9�$G�$G�$I�$I�D�!�!�!�$(�D�!�!�!r c��K�|j���rtd���|j}|�dS|�d{V��dS)NzConnection closed by peer)r{�
is_closing�ConnectionErrorr�)r�rks  r�drainz_SendfileFallbackProtocol.drain�sR�����?�%�%�'�'�	?�!�"=�>�>�>��#���;��F��	�	�	�	�	�	�	�	�	r c� �td���)Nz?Invalid state: connection should have been established already.��RuntimeError)r��	transports  r�connection_madez)_SendfileFallbackProtocol.connection_made�s���N�O�O�	Or c���|j�D|�(|j�td����n|j�|��|j�|��dS)NzConnection is closed by peer)r��
set_exceptionr�r}�connection_lost)r�rls  rr�z)_SendfileFallbackProtocol.connection_lost�sw��� �,��{��%�3�3�#�$B�C�C�E�E�E�E��%�3�3�C�8�8�8���#�#�C�(�(�(�(�(r c�^�|j�dS|jj���|_dSrO)r�r{r�r��r�s r�
pause_writingz'_SendfileFallbackProtocol.pause_writing�s/��� �,��F� $�� 5� C� C� E� E����r c�Z�|j�dS|j�d��d|_dS)NF)r��
set_resultr�s r�resume_writingz(_SendfileFallbackProtocol.resume_writing�s5��� �(��F���(�(��/�/�/� $����r c� �td����Nz'Invalid state: reading should be pausedr�)r��datas  r�
data_receivedz'_SendfileFallbackProtocol.data_received����D�E�E�Er c� �td���r�r�r�s r�eof_receivedz&_SendfileFallbackProtocol.eof_receivedr�r c��K�|j�|j��|jr|j���|j�|j���|jr|j���dSdSrO)	r{r�r}r�resume_readingr��cancelr�r�r�s r�restorez!_SendfileFallbackProtocol.restores�������$�$�T�[�1�1�1��&�	-��O�*�*�,�,�,�� �,�
�!�(�(�*�*�*��&�	)��K�&�&�(�(�(�(�(�	)�	)r N)�__name__�
__module__�__qualname__r�r�r�r�r�r�r�r�r�rPr rrxrx�s�������)�)�)����O�O�O�	)�	)�	)�F�F�F�
%�%�%�F�F�F�F�F�F�
)�
)�
)�
)�
)r rxc�p�eZdZ	dd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
ed
���Zd�Z
d�Zd
�Zd�ZdS)rNc��||_||_d|_g|_||_||_||_||_||_d|_	d|_
dS)NrF)r��_sockets�
_active_count�_waiters�_protocol_factory�_backlog�_ssl_context�_ssl_handshake_timeout�_ssl_shutdown_timeout�_serving�_serving_forever_fut)r��loop�sockets�protocol_factory�ssl_context�backlog�ssl_handshake_timeout�ssl_shutdown_timeouts        rr�zServer.__init__s[����
���
������
�!1�����
�'���&;��#�%9��"���
�$(��!�!�!r c�2�d|jj�d|j�d�S)N�<z	 sockets=�>)�	__class__r�r�r�s r�__repr__zServer.__repr__#s"��F�4�>�*�F�F�T�\�F�F�F�Fr c�&�|xjdz
c_dSrp)r�r�s r�_attachzServer._attach&s�����a�����r c�z�|xjdzc_|jdkr|j�|���dSdSdS)Nrr)r�r��_wakeupr�s r�_detachzServer._detach*sJ�����a�������"�"�t�}�'<��L�L�N�N�N�N�N�#�"�'<�'<r c�~�|j}d|_|D]+}|���s|�|���,dSrO)r��doner�)r��waiters�waiters   rr�zServer._wakeup0sN���-����
��	*�	*�F��;�;�=�=�
*��!�!�&�)�)�)��	*�	*r c
���|jrdSd|_|jD]U}|�|j��|j�|j||j||j|j|j	���VdS)NT)
r�r��listenr�r��_start_servingr�r�r�r�)r�r0s  rr�zServer._start_serving7s����=�	��F���
��M�	,�	,�D��K�K��
�&�&�&��J�%�%��&��d�.?��d�m�T�%@��*�
,�
,�
,�
,�	,�	,r c��|jSrO)r�r�s r�get_loopzServer.get_loopBs
���z�r c��|jSrO)r�r�s r�
is_servingzServer.is_servingEs
���}�r c�P�|j�dStd�|jD����S)NrPc3�>K�|]}tj|��V��dSrO)r�TransportSocket)rQ�ss  rrSz!Server.sockets.<locals>.<genexpr>Ls-����F�F�1�V�+�A�.�.�F�F�F�F�F�Fr )r��tupler�s rr�zServer.socketsHs.���=� ��2��F�F��
�F�F�F�F�F�Fr c�8�|j}|�dSd|_|D]}|j�|���d|_|j�9|j���s |j���d|_|jdkr|���dSdS)NFr)	r�r��
_stop_servingr�r�r�r�r�r�)r�r�r0s   r�closezServer.closeNs����-���?��F���
��	+�	+�D��J�$�$�T�*�*�*�*���
��%�1��-�2�2�4�4�
2��%�,�,�.�.�.�(,�D�%����"�"��L�L�N�N�N�N�N�#�"r c��fK�|���tjd���d{V��dS)Nr)r�r�sleepr�s r�
start_servingzServer.start_servingas@�����������k�!�n�n���������r c��K�|j�td|�d����|j�td|�d����|���|j���|_	|j�d{V��nH#tj$r6	|���|�	���d{V���#�xYwwxYw	d|_dS#d|_wxYw)Nzserver z, is already being awaited on serve_forever()z
 is closed)
r�r�r�r�r�r�r�CancelledErrorr��wait_closedr�s r�
serve_foreverzServer.serve_forevergs(�����$�0��N�$�N�N�N�P�P�
P��=� ��;��;�;�;�<�<�<�������$(�J�$<�$<�$>�$>��!�		-��+�+�+�+�+�+�+�+�+���(�	�	�	�
��
�
�����&�&�(�(�(�(�(�(�(�(�(�������	����
,�)-�D�%�%�%���D�%�,�,�,�,s6�*
A8�7C
�8B=�.B7�6B=�7B9�9B=�=C
�
	Cc��K�|j�|j�dS|j���}|j�|��|�d{V��dSrO)r�r�r�r�rA)r�r�s  rr�zServer.wait_closed|sX�����=� �D�M�$9��F���)�)�+�+���
���V�$�$�$����������r rO)r�r�r�r�r�r�r�r�r�r�r��propertyr�r�r�r�r�rPr rrrs�������>B�)�)�)�)�G�G�G� � � ����*�*�*�	,�	,�	,��������G�G��X�G�
���&���-�-�-�*����r rc
�J�eZdZd�Zd�Zd�Zddd�d�Zd�Zd�Zd\ddd	�d
�Z		d\dddddddd
�d�Z
	d]d�Z		d^d�Z		d^d�Z
	d\d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd �Zd!�Zejfd"�Z d#�Z!d$�Z"dd%�d&�Z#dd%�d'�Z$dd%�d(�Z%d)�Z&d*�Z'd+�Z(dd%�d,�Z)d-�Z*d.�Z+d/�Z,d0d0d0d0d1�d2�Z-d_d3�Z.d`dd4�d5�Z/d6�Z0d7�Z1d8�Z2d\d9�Z3	d^dd0d0d0dddddddd:�d;�Z4			dad<�Z5d`dd4�d=�Z6d>�Z7d?�Z8ddddd@�dA�Z9	d^d0d0d0ddddB�dC�Z:d0e;j<d0d0d1�dD�Z=dE�Z>	d^e;j?e;j@ddFdddddddG�
dH�ZAddddI�dJ�ZBdK�ZCdL�ZDdM�ZEeFjGeFjGeFjGddd0ddddN�	dO�ZHeFjGeFjGeFjGddd0ddddN�	dP�ZIdQ�ZJdR�ZKdS�ZLdT�ZMdU�ZNdV�ZOdW�ZPdX�ZQdY�ZRdZ�ZSd[�ZTdS)brc��d|_d|_d|_tj��|_g|_d|_d|_d|_	tjd��j|_
d|_|�t!j����d|_d|_d|_d|_d|_t/j��|_d|_d|_dS)NrF�	monotonicg�������?)�_timer_cancelled_count�_closed�	_stoppingrT�deque�_ready�
_scheduled�_default_executor�
_internal_fds�
_thread_id�time�get_clock_info�
resolution�_clock_resolution�_exception_handler�	set_debugr�_is_debug_mode�slow_callback_duration�_current_handle�
_task_factory�"_coroutine_origin_tracking_enabled�&_coroutine_origin_tracking_saved_depth�weakref�WeakSet�
_asyncgens�_asyncgens_shutdown_called�_executor_shutdown_calledr�s rr�zBaseEventLoop.__init__�s���&'��#�������!�'�)�)������!%���������!%�!4�[�!A�!A�!L���"&������z�0�2�2�3�3�3�'*��#�#���!���27��/�6:��3�"�/�+�+���*/��'�).��&�&�&r c	��d|jj�d|����d|����d|����d�	S)Nr�z	 running=z closed=z debug=r�)r�r��
is_running�	is_closed�	get_debugr�s rr�zBaseEventLoop.__repr__�sp��
C���'�
C�
C�$�/�/�2C�2C�
C�
C��n�n�&�&�
C�
C�/3�~�~�/?�/?�
C�
C�
C�	
r c�,�tj|���S)z,Create a Future object attached to the loop.�r�)r�Futurer�s rr�zBaseEventLoop.create_future�s���~�4�(�(�(�(r N)�name�contextc��|���|j�(tj||||���}|jr|jd=nF|�|�||��}n|�|||���}tj||��|S)zDSchedule a coroutine object.

        Return a task object.
        N)r�rr����r)�
_check_closedr�rr�_source_traceback�_set_task_name)r��cororr�tasks     r�create_taskzBaseEventLoop.create_task�s���
	
��������%��:�d��D�'�J�J�J�D��%�
/��*�2�.�����)�)�$��5�5����)�)�$��g�)�F�F��� ��t�,�,�,��r c�T�|�t|��std���||_dS)awSet a task factory that will be used by loop.create_task().

        If factory is None the default task factory will be set.

        If factory is a callable, it should have a signature matching
        '(loop, coro)', where 'loop' will be a reference to the active
        event loop, 'coro' will be a coroutine object.  The callable
        must return a Future.
        Nz'task factory must be a callable or None)�callabler=r�)r��factorys  r�set_task_factoryzBaseEventLoop.set_task_factory�s4����x��'8�'8���E�F�F�F�$����r c��|jS)z<Return a task factory, or None if the default one is in use.)r�r�s r�get_task_factoryzBaseEventLoop.get_task_factory�s���!�!r )�extra�serverc��t�)zCreate socket transport.��NotImplementedError)r�r0�protocolr�rrs      r�_make_socket_transportz$BaseEventLoop._make_socket_transport��
��"�!r FT)�server_side�server_hostnamerrr�r��call_connection_madec��t�)zCreate SSL transport.r)r��rawsockr�
sslcontextr�r r!rrr�r�r"s            r�_make_ssl_transportz!BaseEventLoop._make_ssl_transport�s
��"�!r c��t�)zCreate datagram transport.r)r�r0r�addressr�rs      r�_make_datagram_transportz&BaseEventLoop._make_datagram_transport�rr c��t�)zCreate read pipe transport.r�r��piperr�rs     r�_make_read_pipe_transportz'BaseEventLoop._make_read_pipe_transport�rr c��t�)zCreate write pipe transport.rr+s     r�_make_write_pipe_transportz(BaseEventLoop._make_write_pipe_transport�rr c	��K�t�)zCreate subprocess transport.r)
r�r�args�shell�stdin�stdout�stderr�bufsizer�kwargss
          r�_make_subprocess_transportz(BaseEventLoop._make_subprocess_transport�s����"�!r c��t�)z�Write a byte to self-pipe, to wake up the event loop.

        This may be called from a different thread.

        The subclass is responsible for implementing the self-pipe.
        rr�s r�_write_to_selfzBaseEventLoop._write_to_self�s
��"�!r c��t�)zProcess selector events.r)r��
event_lists  r�_process_eventszBaseEventLoop._process_eventss��!�!r c�2�|jrtd���dS)NzEvent loop is closed)r�r�r�s rrzBaseEventLoop._check_closeds%���<�	7��5�6�6�6�	7�	7r c�2�|jrtd���dS)Nz!Executor shutdown has been called)r�r�r�s r�_check_default_executorz%BaseEventLoop._check_default_executor
s)���)�	D��B�C�C�C�	D�	Dr c��|j�|��|���s/|�|j|�����dSdSrO)r��discardr�call_soon_threadsafer�aclose�r��agens  r�_asyncgen_finalizer_hookz&BaseEventLoop._asyncgen_finalizer_hooks^�������%�%�%��~�~���	G��%�%�d�&6����
�
�F�F�F�F�F�	G�	Gr c��|jr tjd|�d�t|���|j�|��dS)Nzasynchronous generator z3 was scheduled after loop.shutdown_asyncgens() call��source)r��warnings�warn�ResourceWarningr��addrEs  r�_asyncgen_firstiter_hookz&BaseEventLoop._asyncgen_firstiter_hooks_���*�	.��M�2�$�2�2�2���
.�
.�
.�
.�
	
����D�!�!�!�!�!r c��nK�d|_t|j��sdSt|j��}|j���tjd�|D��ddi��d{V��}t||��D]6\}}t|t��r|�
d|��||d����7dS)z,Shutdown all active asynchronous generators.TNc�6�g|]}|�����SrP)rD)rQ�ags  r�
<listcomp>z4BaseEventLoop.shutdown_asyncgens.<locals>.<listcomp>)s ��
2�
2�
2�b�b�i�i�k�k�
2�
2�
2r �return_exceptionsz;an error occurred during closing of asynchronous generator )�messagerf�asyncgen)r��lenr�rV�clearr�gather�zipr�	Exception�call_exception_handler)r��
closing_agens�results�resultrFs     r�shutdown_asyncgensz BaseEventLoop.shutdown_asyncgenss����*.��'��4�?�#�#�	�
�F��T�_�-�-�
����������
2�
2�M�
2�
2�
2�$�"�$�$�$�$�$�$�$�$�� ���7�7�	�	�L�F�D��&�)�,�,�
��+�+� B�9=� B� B�!'� $�	-�-�����	�	r c��K�d|_|j�dS|���}tj|j|f���}|���	|�d{V��|���dS#|���wxYw)z.Schedule the shutdown of the default executor.TN)�targetr1)r�r�r��	threading�Thread�_do_shutdown�start�join)r��future�threads   r�shutdown_default_executorz'BaseEventLoop.shutdown_default_executor5s�����)-��&��!�)��F��#�#�%�%���!��):�&��K�K�K��������	��L�L�L�L�L�L�L��K�K�M�M�M�M�M��F�K�K�M�M�M�M���s�A6�6Bc�:�	|j�d���|���s|�|jd��dSdS#t
$r@}|���s!|�|j|��Yd}~dSYd}~dSd}~wwxYw)NT��wait)r��shutdownrrCr�r[r�)r�rh�exs   rrezBaseEventLoop._do_shutdownBs���	D��"�+�+��+�6�6�6��>�>�#�#�
C��)�)�&�*;�T�B�B�B�B�B�
C�
C���	D�	D�	D��>�>�#�#�
D��)�)�&�*>��C�C�C�C�C�C�C�C�C�
D�
D�
D�
D�
D�
D�����	D���s�A
A�
B�/B�Bc��|���rtd���tj���td���dS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)rr�r�_get_running_loopr�s r�_check_runningzBaseEventLoop._check_runningKsS���?�?���	E��C�D�D�D��#�%�%�1��I�K�K�
K�2�1r c��|���|���|�|j��t	j��}	t
j��|_t	j	|j
|j���tj
|��	|���|jrn�	d|_d|_tj
d��|�d��t	j	|�dS#d|_d|_tj
d��|�d��t	j	|�wxYw)zRun until stop() is called.)�	firstiter�	finalizerTFN)rrr�_set_coroutine_origin_tracking�_debug�sys�get_asyncgen_hooksrc�	get_identr��set_asyncgen_hooksrOrGr�_set_running_loop�	_run_oncer�)r��old_agen_hookss  r�run_foreverzBaseEventLoop.run_foreverRsX���������������+�+�D�K�8�8�8��/�1�1��	4�'�1�3�3�D�O��"�T�-J�-1�-J�
L�
L�
L�
L�
�$�T�*�*�*�
���� � � ��>���
��"�D�N�"�D�O��$�T�*�*�*��/�/��6�6�6��"�N�3�3�3�3��	#�D�N�"�D�O��$�T�*�*�*��/�/��6�6�6��"�N�3�3�3���s�A*D	�	AEc��|���|���tj|��}t	j||���}|rd|_|�t��	|�	��nD#|r<|�
��r(|���s|����xYw	|�
t��n#|�
t��wxYw|�
��std���|���S)a\Run until the Future is done.

        If the argument is a coroutine, it is wrapped in a Task.

        WARNING: It would be disastrous to call run_until_complete()
        with the same coroutine twice -- it would wrap it in two
        different Tasks and that can't be good.

        Return the Future's result, or raise its exception.
        rFz+Event loop stopped before Future completed.)rrrr�isfuturer�
ensure_future�_log_destroy_pending�add_done_callbackrmrr�rerf�remove_done_callbackr�r_)r�rh�new_tasks   r�run_until_completez BaseEventLoop.run_until_completejsD��	
�������������'��/�/�/���$�V�$�7�7�7���	0�+0�F�'�� � �!7�8�8�8�
	@���������	��
#�F�K�K�M�M�
#�&�2B�2B�2D�2D�
#�� � �"�"�"�����
�
�'�'�(>�?�?�?�?��F�'�'�(>�?�?�?�?�����{�{�}�}�	N��L�M�M�M��}�}���s�8B
�C-�
AC�C-�-D	c��d|_dS)z�Stop running the event loop.

        Every callback already scheduled will still run.  This simply informs
        run_forever to stop looping after a complete iteration.
        TN)r�r�s rrjzBaseEventLoop.stop�s������r c�f�|���rtd���|jrdS|jrt	jd|��d|_|j���|j���d|_	|j
}|�d|_
|�d���dSdS)z�Close the event loop.

        This clears the queues and shuts down the executor,
        but does not wait for the executor to finish.

        The event loop must not be running.
        z!Cannot close a running event loopNzClose %rTFrl)rr�r�rwr�debugr�rXr�r�r�rn�r��executors  rr�zBaseEventLoop.close�s����?�?���	D��B�C�C�C��<�	��F��;�	+��L��T�*�*�*������������������)-��&��)����%)�D�"����5��)�)�)�)�)� �r c��|jS)z*Returns True if the event loop was closed.)r�r�s rrzBaseEventLoop.is_closed�s
���|�r c��|���s@|d|��t|���|���s|���dSdSdS)Nzunclosed event loop rI)rrMrr�)r��_warns  r�__del__zBaseEventLoop.__del__�sk���~�~���	��E�1��1�1�?�4�P�P�P�P��?�?�$�$�
��
�
������	�	�
�
r c��|jduS)z*Returns True if the event loop is running.N)r�r�s rrzBaseEventLoop.is_running�s����t�+�,r c�(�tj��S)z�Return the time according to the event loop's clock.

        This is a float expressed in seconds since an epoch, but the
        epoch, precision, accuracy and drift are unspecified and may
        differ per event loop.
        )r�r�r�s rr�zBaseEventLoop.time�s���~���r rc��|�td���|j|���|z|g|�Rd|i�}|jr|jd=|S)a;Arrange for a callback to be called at a given time.

        Return a Handle: an opaque object with a cancel() method that
        can be used to cancel the call.

        The delay can be an int or float, expressed in seconds.  It is
        always relative to the current time.

        Each callback will be called exactly once.  If two callbacks
        are scheduled for exactly the same time, it is undefined which
        will be called first.

        Any positional arguments after the callback will be passed to
        the callback when it is called.
        Nzdelay must not be Nonerr
)r=�call_atr�r
)r��delay�callbackrr1�timers      r�
call_laterzBaseEventLoop.call_later�sp�� �=��4�5�5�5����T�Y�Y�[�[�5�0�(�.�T�.�.�.�%,�.�.���"�	,��'��+��r c�B�|�td���|���|jr*|���|�|d��tj|||||��}|jr|jd=tj	|j
|��d|_
|S)z|Like call_later(), but uses an absolute time.

        Absolute time corresponds to the event loop's time() method.
        Nzwhen cannot be Noner�r
T)r=rrw�
_check_thread�_check_callbackr�TimerHandler
�heapq�heappushr�)r��whenr�rr1r�s      rr�zBaseEventLoop.call_at�s���
�<��1�2�2�2��������;�	6���� � � �� � ��9�5�5�5��"�4��4��w�G�G���"�	,��'��+�
��t���.�.�.�����r c���|���|jr*|���|�|d��|�|||��}|jr|jd=|S)aTArrange for a callback to be called as soon as possible.

        This operates as a FIFO queue: callbacks are called in the
        order in which they are registered.  Each callback will be
        called exactly once.

        Any positional arguments after the callback will be passed to
        the callback when it is called.
        �	call_soonr
)rrwr�r��
_call_soonr
�r�r�rr1rs     rr�zBaseEventLoop.call_soon�sx��	
�������;�	8���� � � �� � ��;�7�7�7�����4��9�9���#�	-��(��,��
r c���tj|��stj|��rtd|�d����t	|��std|�d|�����dS)Nzcoroutines cannot be used with z()z"a callable object was expected by z(), got )r�iscoroutine�iscoroutinefunctionr=r)r�r��methods   rr�zBaseEventLoop._check_callbacks����"�8�,�,�	>��.�x�8�8�	>��<�&�<�<�<�>�>�
>���!�!�	%��$�V�$�$��$�$�%�%�
%�	%�	%r c��tj||||��}|jr|jd=|j�|��|S)Nr
)r�Handler
r�rA)r�r�r1rrs     rr�zBaseEventLoop._call_soon
sH����x��t�W�=�=���#�	-��(��,�����6�"�"�"��
r c�r�|j�dStj��}||jkrtd���dS)aoCheck that the current thread is the thread running the event loop.

        Non-thread-safe methods of this class make this assumption and will
        likely behave incorrectly when the assumption is violated.

        Should only be called when (self._debug == True).  The caller is
        responsible for checking this condition for performance reasons.
        NzMNon-thread-safe operation invoked on an event loop other than the current one)r�rcrzr�)r��	thread_ids  rr�zBaseEventLoop._check_threadsK���?�"��F��'�)�)�	����'�'��'�(�(�
(�(�'r c���|���|jr|�|d��|�|||��}|jr|jd=|���|S)z"Like call_soon(), but thread-safe.rCr
)rrwr�r�r
r:r�s     rrCz"BaseEventLoop.call_soon_threadsafe%sx���������;�	C�� � ��+A�B�B�B�����4��9�9���#�	-��(��,��������
r c�4�|���|jr|�|d��|�D|j}|���|�'t
j�d���}||_t
j|j	|g|�R�|���S)N�run_in_executor�asyncio)�thread_name_prefixr)
rrwr�r�r@�
concurrentr�ThreadPoolExecutor�wrap_future�submit)r�r��funcr1s    rr�zBaseEventLoop.run_in_executor0s����������;�	:�� � ��'8�9�9�9����-�H��(�(�*�*�*���%�-�@�@�'0�A����*2��&��"��H�O�D�(�4�(�(�(�t�5�5�5�	5r c�p�t|tjj��st	d���||_dS)Nz,executor must be ThreadPoolExecutor instance)rr�rr�r=r�r�s  r�set_default_executorz"BaseEventLoop.set_default_executor@s8���(�J�$6�$I�J�J�	L��J�K�K�K�!)����r c�H�|�d|��g}|r|�d|����|r|�d|����|r|�d|����|r|�d|����d�|��}tjd|��|���}tj||||||��}	|���|z
}
d|�d	|
d
zd�d|	��}|
|jkrtj|��ntj|��|	S)
N�:zfamily=ztype=zproto=zflags=�, zGet address info %szGetting address info z took g@�@z.3fzms: )	rArgrr�r�r*�getaddrinfor��info)r�rCrDrErFrG�flags�msg�t0�addrinfo�dts           r�_getaddrinfo_debugz BaseEventLoop._getaddrinfo_debugEsY���!�!��!�!�"���	-��J�J�+��+�+�,�,�,��	)��J�J�'�t�'�'�(�(�(��	+��J�J�)��)�)�*�*�*��	+��J�J�)��)�)�*�*�*��i�i��n�n����*�C�0�0�0�
�Y�Y�[�[���%�d�D�&�$��u�M�M��
�Y�Y�[�[�2�
��O�c�O�O��c��O�O�O�8�O�O��
��,�,�,��K�������L������r r�rErFrGr�c
��K�|jr|j}ntj}|�d|||||||���d{V��SrO)rwr�r*r�r�)r�rCrDrErFrGr��getaddr_funcs        rr�zBaseEventLoop.getaddrinfo]sr�����;�	.��2�L�L�!�-�L��)�)��,��d�F�D�%��H�H�H�H�H�H�H�H�	Hr c��VK�|�dtj||���d{V��SrO)r�r*�getnameinfo)r��sockaddrr�s   rr�zBaseEventLoop.getnameinfogsH�����)�)��&�$�h��7�7�7�7�7�7�7�7�	7r )�fallbackc��hK�|jr'|���dkrtd���t|��|�||||��	|�||||���d{V��S#tj$r
}|s�Yd}~nd}~wwxYw|�||||���d{V��S)Nrzthe socket must be non-blocking)	rw�
gettimeoutr+rv�_check_sendfile_params�_sock_sendfile_nativer�SendfileNotAvailableError�_sock_sendfile_fallback)r�r0�file�offset�countr�rls       r�
sock_sendfilezBaseEventLoop.sock_sendfileks9�����;�	@�4�?�?�,�,��1�1��>�?�?�?��$�����#�#�D�$���>�>�>�	��3�3�D�$�4:�E�C�C�C�C�C�C�C�C�
C���3�	�	�	��
��
�
�
�
�
�����	�����1�1�$��28�%�A�A�A�A�A�A�A�A�	As�A7�7B�B�Bc��<K�tjd|�d|�d����)Nz-syscall sendfile is not available for socket z
 and file z combination�rr��r�r0r�r�r�s     rr�z#BaseEventLoop._sock_sendfile_nativezs@�����2�
-�D�
-�
-��
-�
-�
-�.�.�	.r c��|K�|r|�|��|rt|tj��ntj}t	|��}d}		|rt||z
|��}|dkrnft|��d|�}|�d|j|���d{V��}	|	sn*|�||d|	����d{V��||	z
}��||dkr)t|d��r|�||z��SSS#|dkr)t|d��r|�||z��wwwxYw)NrT�seek)
r��minr�!SENDFILE_FALLBACK_READBUFFER_SIZE�	bytearray�
memoryviewr��readinto�sock_sendallr))
r�r0r�r�r��	blocksize�buf�
total_sent�view�reads
          rr�z%BaseEventLoop._sock_sendfile_fallback�s������	��I�I�f�����
F�C��y�B�C�C�C�#�E�	��	�"�"���
�	/�

#��� #�E�J�$6�	� B� B�I� �A�~�~��!�#���z�	�z�2��!�1�1�$��
�t�L�L�L�L�L�L�L�L������'�'��d�5�D�5�k�:�:�:�:�:�:�:�:�:��d�"�
�

#���A�~�~�'�$��"7�"7�~��	�	�&�:�-�.�.�.�.��~��z�A�~�~�'�$��"7�"7�~��	�	�&�:�-�.�.�.�.��~���s
�BD	�	2D;c��dt|dd��vrtd���|jtjkstd���|�_t|t��s"td�|�����|dkr"td�|�����t|t��s"td�|�����|dkr"td�|�����dS)N�b�modez$file should be opened in binary modez+only SOCK_STREAM type sockets are supportedz+count must be a positive integer (got {!r})rz0offset must be a non-negative integer (got {!r}))	rr+rFr*r9rr<r=�formatr�s     rr�z$BaseEventLoop._check_sendfile_params�s)���g�d�F�C�0�0�0�0��C�D�D�D��y�F�.�.�.��J�K�K�K����e�S�)�)�
Q��A�H�H��O�O�Q�Q�Q���z�z� �A�H�H��O�O�Q�Q�Q��&�#�&�&�	��B�I�I������
��A�:�:��B�I�I������
��:r c��K�g}|j|��|\}}}}}	d}
	tj|||���}
|
�d��|��|D]�\}}}}}||kr�	|
�|��n�#t$rS}
d|�d|
j�����}t	|
j|��}
|�|
��Yd}
~
�d}
~
wwxYw|r|����t	d|�d����|�	|
|	���d{V��|
dx}}S#t$r1}
|�|
��|
�|
�
���d}
~
w|
�|
�
���xYw#dx}}wxYw)z$Create, bind and connect one socket.N�rErFrGF�*error while attempting to bind on address �: z&no matching local address with family=z found)rAr*�setblocking�bindr.�strerror�lower�errno�pop�sock_connectr�)r�r�	addr_info�local_addr_infos�
my_exceptionsrE�type_rG�_r(r0�lfamily�laddrrlr�s               r�
_connect_sockzBaseEventLoop._connect_sock�s�����
��
��-�(�(�(�+4�(���u�a����$	.��=��U�%�H�H�H�D����U�#�#�#��+�/?�Y�Y�+�G�Q��1�e��&�(�(� �
2��	�	�%�(�(�(����"�2�2�2�6�',�6�6�"�|�1�1�3�3�6�6��
&�c�i��5�5��%�,�,�S�1�1�1�1�1�1�1�1�����2����%�Y�+�/�/�1�1�1�%�&W��&W�&W�&W�X�X�X��#�#�D�'�2�2�2�2�2�2�2�2�2��*.�-�J�����	�	�	�� � ��%�%�%����
�
���������	����
�
���������)-�-�J��-�-�-�-sO�?D"� A7�5D"�7
C�A	C�
D"�C�A	D"�"
E4�,,E�E4�4E7�7E=)rtrErGr�r0�
local_addrr!r�r��happy_eyeballs_delay�
interleavec��v����K�|
�|std���|
�|r|std���|}
|�|std���|�|std���|�t|��|
�|�d}|�|���|�td�����||f|tj||�����d{V��}|std	���|	�=��|	|tj||�����d{V����std	���nd�|rt
||��}g�|
�5|D]1}	���|����d{V��}n#t
$rY�.wxYwn/tj	���fd
�|D��|
�����d{V��\}}}|��d��D���	t���dkr�d
�t�d
���t�fd��D����r�d
�td�
d�d��D���������#d�wxYwn8|�td���|jtjkrtd|�������||||
||����d{V��\}}�jr.|�d��}t'jd|||||��||fS)a�Connect to a TCP server.

        Create a streaming transport connection to a given internet host and
        port: socket family AF_INET or socket.AF_INET6 depending on host (or
        family if specified), socket type SOCK_STREAM. protocol_factory must be
        a callable returning a protocol instance.

        This method is a coroutine which will try to establish the connection
        in the background.  When successful, the coroutine returns a
        (transport, protocol) pair.
        Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a host�1ssl_handshake_timeout is only meaningful with ssl�0ssl_shutdown_timeout is only meaningful with sslr�8host/port and sock can not be specified at the same time�rErFrGr�r��!getaddrinfo() returned empty listc3�P�K�|] }tj�j�|���V��!dSrO)�	functools�partialr�)rQr�r�laddr_infosr�s  ���rrSz2BaseEventLoop.create_connection.<locals>.<genexpr>5sR�����,�,�!��&�t�'9�'1�8�[�J�J�,�,�,�,�,�,r rc��g|]	}|D]}|���
SrPrP)rQ�subrls   rrSz3BaseEventLoop.create_connection.<locals>.<listcomp>;s%��G�G�G�c�3�G�G�C�c�G�G�G�Gr rc3�>�K�|]}t|���kV��dSrO�r)rQrl�models  �rrSz2BaseEventLoop.create_connection.<locals>.<genexpr>Bs.�����G�G�S�s�3�x�x�5�0�G�G�G�G�G�Gr zMultiple exceptions: {}r�c3�4K�|]}t|��V��dSrOr)rQrls  rrSz2BaseEventLoop.create_connection.<locals>.<genexpr>Gs(����%E�%E�3�c�#�h�h�%E�%E�%E�%E�%E�%Er z5host and port was not specified and no sock specified�"A Stream Socket was expected, got )r�r�r*z%r connected to %s:%r: (%r, %r))r+rv�_ensure_resolvedr*r9r.rcr�r�staggered_racerWr�allr�rgrF�_create_connection_transportrw�get_extra_inforr�)r�r�rCrDrtrErGr�r0r�r!r�r�r�r��infosr�r�r�rrrrs`                   @@@r�create_connectionzBaseEventLoop.create_connection�s���������&�&�s�&��J�K�K�K��"�s�"��
B� �"A�B�B�B�"�O� �,�S�,��C�E�E�
E� �+�C�+��B�D�D�
D����d�#�#�#��+�
�0B��J���t�/��� �N�P�P�P��/�/��t��V��'�u�E��0�N�N�N�N�N�N�N�N�E��
C��A�B�B�B��%�$(�$9�$9��v��+�5��d�%:�%,�%,�,�,�,�,�,�,��#�G�!�"E�F�F�F�G�#���
A�-�e�Z�@�@���J�#�+� %�!�!�H�!�%)�%7�%7�&��+�&?�&?� ?� ?� ?� ?� ?� ?�����"�!�!�!� ��!�����$-�#;�,�,�,�,�,�,�%*�,�,�,�)�t�	$5�$5�$5�5�5�5�5�5�5�
��a���|�G�G�Z�G�G�G�
�
&��:���!�+�+�(��m�+�!$�J�q�M� 2� 2���G�G�G�G�J�G�G�G�G�G�0�",�Q�-�/�&�&?�&F�&F� �I�I�%E�%E�*�%E�%E�%E�E�E�'G�'G�H�H�H��"&�J�%�%�%�%��$�|� �K�M�M�M��y�F�.�.�.�!�A��A�A�C�C�C�%)�$E�$E��"�C��"7�!5�%F�%7�%7�7�7�7�7�7�7��	�8��;�	@��+�+�H�5�5�D��L�:��t�T�9�h�
@�
@�
@��(�"�"s�D=�=
E
�	E
�BH�H"c
��\K�|�d��|��}|���}	|r7t|t��rdn|}
|�|||
|	||||���}n|�|||	��}	|	�d{V��n#|����xYw||fS)NF�r r!r�r�)r�r�r�boolr&rr�)r�r0r�rtr!r r�r�rr�r%r�s            rrz*BaseEventLoop._create_connection_transportes�����	
�������#�#�%�%���#�#�%�%���	L�!+�C��!6�!6�?���C�J��0�0��h�
�F�'��&;�%9�	1�;�;�I�I��3�3�D�(�F�K�K�I�	��L�L�L�L�L�L�L�L��	��O�O���������(�"�"s�B�B'c���K�|���rtd���t|dtjj��}|tjjurtd|�����|tjjur>	|�||||���d{V��S#tj	$r
}|s�Yd}~nd}~wwxYw|std|�����|�
||||���d{V��S)a�Send a file to transport.

        Return the total number of bytes which were sent.

        The method uses high-performance os.sendfile if available.

        file must be a regular file object opened in binary mode.

        offset tells from where to start reading the file. If specified,
        count is the total number of bytes to transmit as opposed to
        sending the file until EOF is reached. File position is updated on
        return or also in case of error in which case file.tell()
        can be used to figure out the number of bytes
        which were sent.

        fallback set to True makes asyncio to manually read and send
        the file when the platform does not support the sendfile syscall
        (e.g. Windows or SSL socket on Unix).

        Raise SendfileNotAvailableError if the system does not support
        sendfile syscall and fallback is False.
        zTransport is closing�_sendfile_compatiblez(sendfile is not supported for transport NzHfallback is disabled and native sendfile is not supported for transport )r�r�rr�
_SendfileMode�UNSUPPORTED�
TRY_NATIVE�_sendfile_nativerr��_sendfile_fallback)r�r�r�r�r�r�r�rls        r�sendfilezBaseEventLoop.sendfile�s�����0���!�!�	7��5�6�6�6��y�"8� �.�:�<�<���9�*�6�6�6��H�9�H�H�J�J�
J��9�*�5�5�5�
�!�2�2�9�d�39�5�B�B�B�B�B�B�B�B�B���7�
�
�
�������������
�����	:��9�+4�9�9�:�:�
:��,�,�Y��-3�U�<�<�<�<�<�<�<�<�	<s�?B�B9�,B4�4B9c��.K�tjd���)Nz!sendfile syscall is not supportedr�)r�r�r�r�r�s     rrzBaseEventLoop._sendfile_native�s�����2�/�1�1�	1r c��K�|r|�|��|rt|d��nd}t|��}d}t|��}		|rct||z
|��}|dkrJ||dkr(t	|d��r|�||z��|����d{V��St
|��d|�}	|�d|j|	���d{V��}
|
sJ||dkr(t	|d��r|�||z��|����d{V��S|�	���d{V��|�
|	d|
���||
z
}��(#|dkr(t	|d��r|�||z��|����d{V��wxYw)Ni@rTr�)r�r�r�rxr)r�r�r�r�r��write)r�r�r�r�r�r�r�r�rGr�r�s           rrz BaseEventLoop._sendfile_fallback�s�����	��I�I�f����).�9�C��u�%�%�%�E�	��	�"�"���
�)�&�1�1��	"�
#��*� #�E�J�$6�	� B� B�I� �A�~�~�)��A�~�~�'�$��"7�"7�~��	�	�&�:�-�.�.�.��-�-�/�/�!�!�!�!�!�!�!�!�"�#���z�	�z�2��!�1�1�$��
�t�L�L�L�L�L�L�L�L���&�%�
�A�~�~�'�$��"7�"7�~��	�	�&�:�-�.�.�.��-�-�/�/�!�!�!�!�!�!�!�!�
�k�k�m�m�#�#�#�#�#�#�#����T�%�4�%�[�)�)�)��d�"�
�
#���A�~�~�'�$��"7�"7�~��	�	�&�:�-�.�.�.��-�-�/�/�!�!�!�!�!�!�!�!���s�E8�5<E8�:>E8�8A
Grc��K�t�td���t|tj��st	d|�����t|dd��st	d|�d����|���}tj||||||||d��	�	}	|�	��|�
|	��|�|	j|��}
|�|j
��}	|�d{V��nK#t$r>|���|
���|����wxYw|	jS)	zzUpgrade transport to TLS.

        Return a new transport that *protocol* should start using
        immediately.
        Nz"Python ssl module is not availablez@sslcontext is expected to be an instance of ssl.SSLContext, got �_start_tls_compatibleFz
transport z  is not supported by start_tls())r�r�r")rtr�r�
SSLContextr=rr�r
�SSLProtocolr�r�r�r�r��
BaseExceptionr�r��_app_transport)r�r�rr%r r!r�r�r��ssl_protocol�
conmade_cb�	resume_cbs            r�	start_tlszBaseEventLoop.start_tls�s������;��C�D�D�D��*�c�n�5�5�	'��&�!�&�&�'�'�
'��y�"9�5�A�A�	L��J�Y�J�J�J�L�L�
L��#�#�%�%���+��(�J����"7�!5�!&�(�(�(��	���!�!�!����|�,�,�,��^�^�L�$@�)�L�L�
��N�N�9�#;�<�<�	�	��L�L�L�L�L�L�L�L���	�	�	��O�O�����������������		�����*�*s
�9D�AE
)rErGr��
reuse_port�allow_broadcastr0c	����K�|	��|	jtjkrtd|	������s�s
|s|s|s|s|rZt	��|||||���}
d�d�|
���D����}td|�d����|	�d��d}�n��s �s|d	krtd
���||fdff}
�n�ttd��r�|tj	kr���fD](}|�$t|t��std
����)�r��d	dvry	tjtj
���j��rtj���n8#t$$rYn,t&$r }t)jd�|��Yd}~nd}~wwxYw||f��fff}
n�i}d	�fd�ffD]�\}}|��t|t,��rt/|��dkstd���|�||tj|||����d{V��}|st'd���|D]"\}}}}}||f}||vrddg||<||||<�#����fd�|���D��}
|
std���g}|
D�]\\}}\}}d}	d}	tj|tj|���}	|rt5|	��|r+|	�tjtjd��|	�d���r|	�|���r |s|�|	|���d{V��|}n\#t&$r0}|	�|	� ��|j!|��Yd}~��d}~w|	�|	� ���xYw|d	�|��}|�"��}|�#|	|||��}|j$r2�rt)j%d��||��nt)j&d�||��	|�d{V��n#|� ���xYw||fS)zCreate datagram connection.Nz$A datagram socket was expected, got )r��remote_addrrErGr�r.r/r�c3�.K�|]\}}|�|�d|��V��dS)�=NrP)rQ�k�vs   rrSz9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>s5����$N�$N�D�A�q�A�$N��Z�Z�A�Z�Z�$N�$N�$N�$N�$N�$Nr zKsocket modifier keyword arguments can not be used when sock is specified. (�)Frzunexpected address family�NN�AF_UNIXzstring is expected)r�z2Unable to check or remove stale UNIX socket %r: %rr�z2-tuple is expectedrrc�F��g|]\}}�r|d��r|d�||f��S)rNrrP)rQ�key�	addr_pairr�r1s   ��rrSz:BaseEventLoop.create_datagram_endpoint.<locals>.<listcomp>BsU���#E�#E�#E�)7��i�'�#E�,5�a�L�,@�(�-A�-6�q�\�-A��)�$�-A�-A�-Ar zcan not get address informationr�z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))'rFr*r9r+�dictrg�itemsr�r)r8rrr=�stat�S_ISSOCK�os�st_mode�remove�FileNotFoundErrorr.r�errorr�rWrr:r1r,r-�SO_BROADCASTr�r�r�rAr�r)rwr�r�)r�r�r�r1rErGr�r.r/r0�opts�problems�r_addr�addr_pairs_infor`�err�
addr_infos�idxr�famr��pror(r<r�
local_address�remote_addressrlrr�r�s  ``                           r�create_datagram_endpointz&BaseEventLoop.create_datagram_endpoint�sO���������y�F�.�.�.� �C�4�C�C�E�E�E��
=�k�
=��
=�#�
=�',�
=��
=�"1�
=��z�{�#)��e�'1�,;�=�=�=�� �9�9�$N�$N�D�J�J�L�L�$N�$N�$N�N�N�� �<�08�<�<�<�=�=�=�
���U�#�#�#��F�F��2
H�+�2
H��Q�;�;�$�%@�A�A�A�%+�U�O�\�#B�"D������+�+�.
H��&�.�0H�0H�'��5�>�>�D��'�
�4��0E�0E�'�'�(<�=�=�=���
6�*�Q�-�{�"B�"B�	6��=����)<�)<�)D�E�E�2��I�j�1�1�1���,������"�6�6�6���&5�%/��6�6�6�6�6�6�6�6�����6����&,�U�O�%/��$=�$?�#B��� �
�#$�j�/�A�{�3C�!D�;�;�I�C���'� *�4�� 7� 7�C�C��I�I��N�N�"+�,A�"B�"B�B�&*�&;�&;� ��f�6G�"'�u�4�'<�'A�'A�!A�!A�!A�!A�!A�!A�� %�O�")�*M�"N�"N�N�7<�;�;�3�C��C��G�#&��*�C�"�*�4�4�37��,�
�3��3:�J�s�O�C�0�0��#E�#E�#E�#E�#E�;E�;K�;K�;M�;M�#E�#E�#E��
'�H�$�%F�G�G�G��J�6E�
$�
$�2��&�%�0�-�������!�=�%�F�,=�U�L�L�L�D�!�-�&�t�,�,�,�&�G����"�-�v�/B�A�G�G�G��$�$�U�+�+�+�!�1��	�	�-�0�0�0�"�0�.�J�"&�"3�"3�D�.�"I�"I�I�I�I�I�I�I�I�!/���E���+�+�+��'��
�
����%�J�%�c�*�*�*�*�*�*�*�*�������'��
�
��������!��m�#�#�#�%�%���#�#�%�%���1�1��(�F�F�,�,�	��;�	?��
?���0�&��Y��J�J�J�J���(�(�)�X�?�?�?�	��L�L�L�L�L�L�L�L��	��O�O���������(�"�"sC�0?E0�0
F%�<	F%�F � F%�#B-M�
N#�&N�N#�P'�'P>c��K�|dd�\}}t|||||g|dd��R�}	|	�|	gS|�||||||����d{V��S)Nr:r�)rLr�)
r�r(rErFrGr�r�rCrDr�s
          rrzBaseEventLoop._ensure_resolved�s������R�a�R�[�
��d��D�$���e�J�g�a�b�b�k�J�J�J�����6�M��)�)�$��V�$�05�U�*�D�D�D�D�D�D�D�D�
Dr c��K�|�||f|tj||����d{V��}|std|�d����|S)N)rErFr�r�zgetaddrinfo(z) returned empty list)rr*r9r.)r�rCrDrEr�rs      r�_create_server_getaddrinfoz(BaseEventLoop._create_server_getaddrinfo�s������+�+�T�4�L��17�1C�27�d�,�D�D�D�D�D�D�D�D���	H��F��F�F�F�G�G�G��r r)
rEr�r0r�rt�
reuse_addressr.r�r�r�c
	������K�t|t��rtd���|�|�td���|�|�td���|�t	|��|�����|�td���|	� t
jdkotjdk}	g}|dkrdg}n:t|t��st|tjj��s|g}n|}����fd	�|D��}tj|��d{V��}tt j�|����}d
}	|D�]�}|\}}}}}	t'j|||��}n5#t&j$r#�jrt-jd|||d�
��Y�TwxYw|�|��|	r+|�t&jt&jd��|
rt9|��t:rP|t&jkr@t?t&d��r+|�t&j t&j!d��	|�"|����#tF$r�}d|�d|j$�%����}|j&tLj'krI|�(��|�)���jrt-j|��Yd}~���tG|j&|��d�d}~wwxYw|stGdd�|D�������d}|s|D]}|�)���n\#|s|D]}|�)���wwxYw|�td���|j*t&j+krtd|�����|g}|D]}|�,d
���t[�||||||��}|
r.|�.��tj/d���d{V���jrt-j0d|��|S)a1Create a TCP server.

        The host parameter can be a string, in that case the TCP server is
        bound to host and port.

        The host parameter can also be a sequence of strings and in that case
        the TCP server is bound to all hosts of the sequence. If a host
        appears multiple times (possibly indirectly e.g. when hostnames
        resolve to the same IP address), the server is only bound once to that
        host.

        Return a Server object which can be used to stop the service.

        This method is a coroutine.
        z*ssl argument must be an SSLContext or NoneNr�rr�posix�cygwinr4c�B��g|]}��|��������S))rEr�)rV)rQrCrEr�rDr�s  ����rrSz/BaseEventLoop.create_server.<locals>.<listcomp>�sG���%�%�%���1�1�$��V�8=�2�?�?�%�%�%r Fz:create_server() failed to create socket.socket(%r, %r, %r)T��exc_info�IPPROTO_IPV6r�r�z%could not bind on any address out of c��g|]
}|d��S)�rP)rQr�s  rrSz/BaseEventLoop.create_server.<locals>.<listcomp>s��%@�%@�%@�$�d�1�g�%@�%@�%@r z)Neither host/port nor sock were specifiedrrz
%r is serving)1rrr=r+rvrBrrx�platformrrT�abc�IterablerrY�setrYrZr[r*rFrwr�warningrAr,r-�SO_REUSEADDRr1r@rr)r^�IPV6_V6ONLYr�r.r�r�r��
EADDRNOTAVAILr�r�rFr9r�rr�r�r�)r�r�rCrDrEr�r0r�rtrWr.r�r�r�r��hosts�fsr�	completed�resrK�socktyperG�	canonname�sarLr�rs`  ```                      r�
create_serverzBaseEventLoop.create_server�s-��������8�c�4� � �	J��H�I�I�I� �,����C�E�E�
E� �+����B�D�D�
D����d�#�#�#���t�/��� �N�P�P�P��$� "��7� 2� O�s�|�x�7O�
��G��r�z�z������T�3�'�'�
� ��{��'?�@�@�
�������%�%�%�%�%�%�%�#�%�%�%�B� �,��+�+�+�+�+�+�+�E��	��5�5�e�<�<�=�=�E��I�2
%� �'@�'@�C�9<�6�B��%��B�!�%�}�R��5�A�A����!�<�!�!�!��;�O�"�N�,G�+-�x���O�O�O�O�!��
!�����N�N�4�(�(�(�$�J����"�-�v�/B�D�J�J�J�!�-�&�t�,�,�,�"�.��&�/�1�1�#�F�N�;�;�2�����(;�(.�(:�(,�.�.�.�
@��	�	�"�
�
�
�
��"�@�@�@�@�#%�"�"�c�l�&8�&8�&:�&:�&:� <���9��(;�;�;�#�K�K�M�M�M� �J�J�L�L�L�#�{�4� &��s� 3� 3� 3�$�H�H�H�H�%�c�i��5�5�4�?�����@�����D�!�'�%@�%@�%�%@�%@�%@�%@�#C�D�D�D�!�	� �%� '�%�%���
�
�������!�%� '�%�%���
�
�����%�%�����|� �!L�M�M�M��y�F�.�.�.� �!N�d�!N�!N�O�O�O��f�G��	$�	$�D����U�#�#�#�#���g�'7��W�&;�,�.�.���	!��!�!�#�#�#��+�a�.�.� � � � � � � ��;�	1��K���0�0�0��
sb�4
L1�E�L1�/F�L1�
F�B-L1�9I�L1�
K2�A7K-�L1�K-�-K2�2#L1�1M)rtr�r�c	��zK�|jtjkrtd|�����|�|std���|�|std���|�t	|��|�|||dd||����d{V��\}}|jr,|�d��}tj	d|||��||fS)	Nrr�rr4T)r r�r�r*z%r handled: (%r, %r))
rFr*r9r+rvrrwrrr�)r�r�r0rtr�r�r�rs        r�connect_accepted_socketz%BaseEventLoop.connect_accepted_socket"s!����
�9��*�*�*��J�$�J�J�K�K�K� �,�S�,��C�E�E�
E� �+�C�+��B�D�D�
D����d�#�#�#�$(�$E�$E��"�C���"7�!5�%F�%7�%7�7�7�7�7�7�7��	�8��;�	L��+�+�H�5�5�D��L�/��y�(�K�K�K��(�"�"r c�� K�|��}|���}|�|||��}	|�d{V��n#|����xYw|jr)t	jd|���||��||fS)Nz Read pipe %r connected: (%r, %r))r�r-r�rwrr��fileno�r�r�r,rr�r�s      r�connect_read_pipezBaseEventLoop.connect_read_pipe@s�����#�#�%�%���#�#�%�%���2�2�4��6�J�J�	�	��L�L�L�L�L�L�L�L��	��O�O���������;�	=��L�;������	�8�
=�
=�
=��(�"�"��A�Ac�� K�|��}|���}|�|||��}	|�d{V��n#|����xYw|jr)t	jd|���||��||fS)Nz!Write pipe %r connected: (%r, %r))r�r/r�rwrr�rtrus      r�connect_write_pipez BaseEventLoop.connect_write_pipePs�����#�#�%�%���#�#�%�%���3�3�D�(�F�K�K�	�	��L�L�L�L�L�L�L�L��	��O�O���������;�	=��L�<������	�8�
=�
=�
=��(�"�"rwc��|g}|�%|�dt|������|�6|tjkr&|�dt|������nN|�%|�dt|������|�%|�dt|������t	jd�|����dS)Nzstdin=zstdout=stderr=zstdout=zstderr=� )rAr&r"r$rr�rg)r�r�r3r4r5r�s      r�_log_subprocesszBaseEventLoop._log_subprocess`s����u�����K�K�6��e�!4�!4�6�6�7�7�7���&�J�,=�"=�"=��K�K�?��f�)=�)=�?�?�@�@�@�@��!����<�l�6�&:�&:�<�<�=�=�=��!����<�l�6�&:�&:�<�<�=�=�=���S�X�X�d�^�^�$�$�$�$�$r )	r3r4r5�universal_newlinesr2r6�encoding�errors�textc		��
K�t|ttf��std���|rtd���|std���|dkrtd���|rtd���|	�td���|
�td���|��}
d}|jrd	|z}|�||||��|j|
|d
||||fi|���d{V��}|jr|�tjd||��||
fS)Nzcmd must be a string� universal_newlines must be Falsezshell must be Truer�bufsize must be 0�text must be False�encoding must be None�errors must be Nonezrun shell command %rT�%s: %r)	rr;rr+rwr|r8rr�)r�r��cmdr3r4r5r}r2r6r~rr�r7r�	debug_logr�s                r�subprocess_shellzBaseEventLoop.subprocess_shellms�����#��s�|�,�,�	5��3�4�4�4��	A��?�@�@�@��	3��1�2�2�2��a�<�<��0�1�1�1��	3��1�2�2�2����4�5�5�5����2�3�3�3�#�#�%�%���	��;�	C�/��4�I�� � ��E�6�6�B�B�B�9�$�9��c�4�����K�K�CI�K�K�K�K�K�K�K�K�	��;�	8�9�0��K��)�Y�7�7�7��(�"�"r c		��K�|rtd���|rtd���|dkrtd���|rtd���|	�td���|
�td���|f|z}|��}d}|jrd|��}|�||||��|j||d	||||fi|
���d{V��}|jr|�t	jd
||��||fS)Nr�zshell must be Falserr�r�r�r�zexecute program Fr�)r+rwr|r8rr�)r�r��programr3r4r5r}r2r6r~rr�r1r7�
popen_argsrr�r�s                  r�subprocess_execzBaseEventLoop.subprocess_exec�sb�����	A��?�@�@�@��	4��2�3�3�3��a�<�<��0�1�1�1��	3��1�2�2�2����4�5�5�5����2�3�3�3��Z�$�&�
�#�#�%�%���	��;�	C�7�7�6�6�I�� � ��E�6�6�B�B�B�9�$�9��j�%����������������	��;�	8�9�0��K��)�Y�7�7�7��(�"�"r c��|jS)zKReturn an exception handler, or None if the default one is in use.
        )r�r�s r�get_exception_handlerz#BaseEventLoop.get_exception_handler�s
���&�&r c�Z�|�!t|��std|�����||_dS)a�Set handler as the new event loop exception handler.

        If handler is None, the default exception handler will
        be set.

        If handler is a callable object, it should have a
        signature matching '(loop, context)', where 'loop'
        will be a reference to the active event loop, 'context'
        will be a dict object (see `call_exception_handler()`
        documentation for details about context).
        Nz+A callable object or None is expected, got )rr=r�)r��handlers  r�set_exception_handlerz#BaseEventLoop.set_exception_handler�sI����x��'8�'8���/�#*�/�/�0�0�
0�")����r c���|�d��}|sd}|�d��}|�t|��||jf}nd}d|vr"|j�|jjr|jj|d<|g}t|��D]�}|dvr�||}|dkrAd	�tj|����}d
}||�	��z
}nV|dkrAd	�tj|����}d}||�	��z
}nt|��}|�|�d|������tj
d
�|��|���dS)aEDefault exception handler.

        This is called when an exception occurs and no exception
        handler is set, and can be called by a custom exception
        handler that wants to defer to the default behavior.

        This default handler logs the error message and other
        context-dependent information.  In debug mode, a truncated
        stack trace is also appended showing where the given object
        (e.g. a handle or future or task) was created, if any.

        The context parameter has the same meaning as in
        `call_exception_handler()`.
        rUz!Unhandled exception in event looprfNF�source_traceback�handle_traceback>rUrfr4z+Object created at (most recent call last):
z+Handle created at (most recent call last):
r��
r\)�getrF�
__traceback__r�r
�sortedrg�	traceback�format_list�rstriprrArrF)	r�rrUrfr]�	log_linesr<�value�tbs	         r�default_exception_handlerz'BaseEventLoop.default_exception_handler�s����+�+�i�(�(���	:�9�G��K�K��,�,�	�� ��Y����I�4K�L�H�H��H��g�-�-��$�0��$�6�1��$�6�
�&�'��I�	��'�?�?�	0�	0�C��.�.�.���C�L�E��(�(�(��W�W�Y�2�5�9�9�:�:��F��������$����*�*�*��W�W�Y�2�5�9�9�:�:��F��������$����U��������.�.�u�.�.�/�/�/�/���T�Y�Y�y�)�)�H�=�=�=�=�=�=r c���|j�P	|�|��dS#ttf$r�t$rtjdd���YdSwxYw	|�||��dS#ttf$r�t$rc}	|�d||d���n7#ttf$r�t$rtjdd���Yn
wxYwYd}~dSYd}~dSd}~wwxYw)aDCall the current event loop's exception handler.

        The context argument is a dict containing the following keys:

        - 'message': Error message;
        - 'exception' (optional): Exception object;
        - 'future' (optional): Future instance;
        - 'task' (optional): Task instance;
        - 'handle' (optional): Handle instance;
        - 'protocol' (optional): Protocol instance;
        - 'transport' (optional): Transport instance;
        - 'socket' (optional): Socket instance;
        - 'asyncgen' (optional): Asynchronous generator that caused
                                 the exception.

        New keys maybe introduced in the future.

        Note: do not overload this method in an event loop subclass.
        For custom exception handling, use the
        `set_exception_handler()` method.
        Nz&Exception in default exception handlerTr\z$Unhandled error in exception handler)rUrfrzeException in default exception handler while handling an unexpected error in custom exception handler)r�r�rgrhr(rrF)r�rrls   rr\z$BaseEventLoop.call_exception_handler�s���,�"�*�	
,��.�.�w�7�7�7�7�7��� 1�2�
�
�
�� �
,�
,�
,���E�&*�,�,�,�,�,�,�,�	
,����
0��'�'��g�6�6�6�6�6��� 1�2�
�
�
�� �
0�
0�
0�0��2�2�#I�%(�#*�4�4������
#�$5�6�����$�0�0�0��L�"?�+/�0�0�0�0�0�0�0����������0�0�0�0�0�0�����
0���sE� �1A�A�A1�1C/�
B'�&C*�'1C�C*�C�C*�*C/c�L�|js|j�|��dSdS)zAdd a Handle to _ready.N)�
_cancelledr�rA�r�rs  r�
_add_callbackzBaseEventLoop._add_callback4s3��� �	'��K���v�&�&�&�&�&�	'�	'r c�X�|�|��|���dS)z6Like _add_callback() but called from a signal handler.N)r�r:r�s  r�_add_callback_signalsafez&BaseEventLoop._add_callback_signalsafe9s.�����6�"�"�"��������r c�8�|jr|xjdz
c_dSdS)z3Notification that a TimerHandle has been cancelled.rN)r�r�r�s  r�_timer_handle_cancelledz%BaseEventLoop._timer_handle_cancelled>s1����	-��'�'�1�,�'�'�'�'�	-�	-r c���t|j��}|tkrf|j|ztkrSg}|jD]&}|jrd|_�|�|���'tj|��||_d|_nb|jr[|jdjrI|xjdzc_tj	|j��}d|_|jr|jdj�Id}|j
s|jrd}nQ|jrJ|jdj}ttd||���z
��t ��}|j�|��}|�|��d}|���|jz}|jrZ|jd}|j|krnAtj	|j��}d|_|j
�|��|j�Zt|j
��}t+|��D]�}	|j
���}|jr�#|jr�	||_|���}
|���|���|
z
}||jkr#t7jdt;|��|��d|_��#d|_wxYw|�����d}dS)z�Run one full iteration of the event loop.

        This calls all currently ready callbacks, polls for I/O,
        schedules the resulting callbacks, and finally schedules
        'call_later' callbacks.
        FrrNzExecuting %s took %.3f seconds)rWr��_MIN_SCHEDULED_TIMER_HANDLESr��%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr�rAr��heapify�heappopr�r��_whenr��maxr��MAXIMUM_SELECT_TIMEOUT�	_selector�selectr=r��range�popleftrwr��_runr�rrer)r��sched_count�
new_scheduledr�timeoutr�r<�end_time�ntodo�ir�r�s            rr}zBaseEventLoop._run_onceCs���$�/�*�*���6�6�6��'�+�5�5�
6�
6��M��/�
1�
1���$�1�(-�F�%�%�!�(�(��0�0�0�0��M�-�(�(�(�+�D�O�*+�D�'�'��/�
*�d�o�a�&8�&C�
*��+�+�q�0�+�+���t��7�7��$)��!��/�
*�d�o�a�&8�&C�
*�
���;�	N�$�.�	N��G�G�
�_�	N��?�1�%�+�D��#�a���	�	���!3�4�4�6L�M�M�G��^�*�*�7�3�3�
����Z�(�(�(��
��9�9�;�;��!7�7���o�	'��_�Q�'�F��|�x�'�'���]�4�?�3�3�F� %�F���K���v�&�&�&�
�o�	'��D�K� � ���u���	�	�A��[�(�(�*�*�F�� �
���{�
�	0�+1�D�(������B��K�K�M�M�M������r�)�B��T�8�8�8���'G�'5�f�'=�'=�r�C�C�C�,0�D�(�(��4�D�(�/�/�/�/����
�
�
�
����s
�A4K�	K
c��t|��t|j��krdS|r7tj��|_tjtj��ntj|j��||_dSrO)rr�rx�#get_coroutine_origin_tracking_depthr��#set_coroutine_origin_tracking_depthr�DEBUG_STACK_DEPTH�r��enableds  rrvz,BaseEventLoop._set_coroutine_origin_tracking�s�����=�=�D��!H�I�I�I�I��F��	=��7�9�9�
�7��3��+�
-�
-�
-�
-�
�3��;�
=�
=�
=�3:��/�/�/r c��|jSrO)rwr�s rrzBaseEventLoop.get_debug�s
���{�r c�v�||_|���r|�|j|��dSdSrO)rwrrCrvr�s  rr�zBaseEventLoop.set_debug�sG������?�?���	T��%�%�d�&I�7�S�S�S�S�S�	T�	Tr rO)NNNr7)r)rN)FNN)Ur�r�r�r�r�r�rrrrr&r)r-r/r8r:r=rr@rGrOr`rjrerrrr�rjr�rrKrLr�rr�r�r�r�r�r�r�rCr�r�r�r�r�r�r�r�r�r�rrr rrr-rSr*r9rrVr>�
AI_PASSIVErprrrvryr|r"r#r�r�r�r�r�r\r�r�r�r}rvrr�rPr rrr�s�������/�/�/�<
�
�
�)�)�)�)-�d������*%�%�%�"�"�"�"�%)�$�"�"�"�"�"�9=�"� �$��t�"&�!%�!%�
"�"�"�"�"�CG�"�"�"�"�
@D�(,�"�"�"�"�
AE�)-�"�"�"�"�04�"�"�"�"�"�"�"�"�"�"�7�7�7�D�D�D�G�G�G�
"�"�"����2���D�D�D�K�K�K�4�4�4�0$�$�$�L���*�*�*�.���%�M�����-�-�-� � � �:>������06:������$26������&%�%�%����(�(�(�"=A�	�	�	�	�	�5�5�5� *�*�*�
���2"#��!�1�H�H�H�H�H�7�7�7�7�
A�(,�
A�
A�
A�
A�
A�.�.�.�/�/�/�4���**.�*.�*.�*.�Z59�G#����1�4��T�"&�!%�!%�$�G#�G#�G#�G#�G#�V*/�"&�!%�	#�#�#�#�8-<�#'�-<�-<�-<�-<�-<�^1�1�1�"�"�"�4%*�(,�.2�-1�	.+�.+�.+�.+�.+�bEI�D#�./�q��26�7;�$�	D#�D#�D#�D#�D#�N'(�f�.@�%&�a�
D�
D�
D�
D�
D����59�I��#��#������"&�!%��I�I�I�I�I�Z�"&�!%�	#�#�#�#�#�<#�#�#� #�#�#� %�%�%�&0�_�&0�o�&0�o�27�%)�1�(,�T��
"#�"#�"#�"#�"#�J%/�O�J�O�%/�_��$)�1�'+�D�t�	 #� #� #� #� #�D'�'�'�
*�*�*�"0>�0>�0>�d70�70�70�r'�'�'�
���
-�-�-�
N�N�N�`
:�
:�
:����T�T�T�T�Tr r)rr)r)7�__doc__rT�collections.abc�concurrent.futuresr�r�rr�rYrBr*r@r"rcr�r�rxrKr�rt�ImportErrorr4rrrrrr	r
rrr
r�logr�__all__r�r�r)r@r�rr&r1rLrcrmrqrv�Protocolrx�AbstractServerr�AbstractEventLooprrPr r�<module>r�sm��
�
�����������������������������	�	�	�	�
�
�
�
���������������������
�
�
�
�����������J�J�J�J������
�C�C�C�����������������������������������������������������������������������������$��
 #��),�%�
�G�F�J�'�'�	�#��������J�J�J�8�8�8�8�v����,"�"�"��7�6�=�!�!�
�G�G�G�G�
�
�
�>�>�>�
A)�A)�A)�A)�A)�	� 2�A)�A)�A)�Hn�n�n�n�n�V�
"�n�n�n�beT�eT�eT�eT�eT�F�,�eT�eT�eT�eT�eTs�A
�
A�A