uawdijnntqw1x1x1
IP : 216.73.216.110
Hostname : 6.87.74.97.host.secureserver.net
Kernel : Linux 6.87.74.97.host.secureserver.net 4.18.0-553.83.1.el8_10.x86_64 #1 SMP Mon Nov 10 04:22:44 EST 2025 x86_64
Disable Function : None :)
OS : Linux
PATH:
/
home
/
emeraadmin
/
www
/
Service
/
..
/
node_modules
/
path-root
/
..
/
jquery
/
..
/
..
/
src
/
..
/
4d695
/
asyncio.tar
/
/
__pycache__/__init__.cpython-312.pyc000064400000002663151706172560013237 0ustar00� T��h����dZddlZddl�ddl�ddl�ddl�ddl�ddl�ddl�ddl �ddl �ddl�ddl�ddl �ddl�ddl�ddl�ddl�ej$ej$zej$zej$zej$zej$zej$ze j$ze j$zej$zej$ze j$zej$zej$zej$zej$zZej&dk(rddl�eej$z Zyddl�eej$z Zy)z'The asyncio package, tracking PEP 3156.�N�)�*�win32)�__doc__�sys�base_events� coroutines�events� exceptions�futures�locks� protocols�runners�queues�streams� subprocess�tasks� taskgroups�timeouts�threads� transports�__all__�platform�windows_events�unix_events���)/usr/lib64/python3.12/asyncio/__init__.py�<module>rsZ��-��������������������������>�>�������?�?� � �=�=����� ��?�?���>�>���?�?� ���� ��=�=�������?�?� ����������"�<�<�7��!��~�%�%�%�G���{�"�"�"�Gr__pycache__/base_events.cpython-312.opt-2.pyc000064400000226663151706172560014746 0ustar00� T��h�2��4� ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlZddlZddl Z ddlZddlZddlZ ddlZddlmZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZddlmZddlmZdd lmZddlmZddl m!Z!dZ"dZ#dZ$e%ed�Z&dZ'd�Z(d�Z)d�Z*d%d�Z+d&d�Z,d�Z-e%ed�rd�Z.nd�Z.d�Z/Gd�d ej`�Z1Gd!�d"ejd�Z3Gd#�d$ejh�Z5y#e$rdZY��wxYw)'�N�)� constants)� coroutines)�events)� exceptions)�futures)� protocols)�sslproto)� staggered)�tasks)�timeouts)� 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 �,/usr/lib64/python3.12/asyncio/base_events.py�_format_handler Gs=�� � � �B��'�"�j�$�/����<��B�K�K� � ��6�{��c�h�|tjk(ry|tjk(ryt|�S)Nz<pipe>z<stdout>)� subprocess�PIPE�STDOUTr)�fds r�_format_piper'Ps+�� �Z�_�_��� �z� � � ���B�x�r!c���ttd�std�� |jtjtj d�y#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_reuseportr2Ys`���6�>�*��D�E�E� J��O�O�F�-�-�v�/B�/B�A�F��� J��I�J� J� J�s�/A � A"c �P�ttd�sy|dtjtjhvs|�y|tjk(rtj}n%|tj k(rtj}ny|�d}n<t |t�r|dk(rd}n$t |t�r|dk(rd}n t|�}|tjk(r7tjg}tr#|jtj �n|g}t |t�r|j#d�}d|vry|D]I} tj$||�tr |tj k(r |||d||||ffcS|||d||ffcSy#ttf$rYywxYw#t&$rY�mwxYw)N� inet_ptonrr!��idna�%)r*r+�IPPROTO_TCP�IPPROTO_UDP�SOCK_STREAM� SOCK_DGRAMr�bytesr�int� TypeErrorr,� AF_UNSPEC�AF_INET� _HAS_IPv6�appendr�decoder4r/) �host�port�family�type�proto�flowinfo�scopeid�afs�afs r�_ipaddr_inforMds����6�;�'���Q��*�*�F�,>�,>�?�?��L���v�!�!�!��"�"�� ��"�"� "��"�"����|��� �D�%� �T�S�[��� �D�#� �4�2�:��� ��t�9�D���!�!�!��~�~�����J�J�v���'��h���$����{�{�6�"�� �d�{���� ����R��&��R�6�?�?�2��4���T�4��7�,K�K�K��4���T�4�L�8�8����;�:�&� �� ��2� �� �s*�7F�;9F�7F�F�F� F%�$F%c�� tj�}|D]$}|d}||vrg||<||j|��&t|j ��}g}|dkDr%|j|dd|dz �|dd|dz �=|jd�tjjt j|��D��|S)Nrrc3�$K�|]}|�|��� y�w�N�)�.0�as r� <genexpr>z(_interleave_addrinfos.<locals>.<genexpr>�s!����� �a� �]� � �s�) �collections�OrderedDictrB�list�values�extend� itertools�chain� from_iterable�zip_longest)� addrinfos�first_address_family_count�addrinfos_by_family�addrrF�addrinfos_lists� reordereds r�_interleave_addrinfosrd�s���7�%�1�1�3�����a����,�,�*,���'��F�#�*�*�4�0� � �.�5�5�7�8�O��I�!�A�%������+�,K�-G�!�-K�L�M��A��>� :�Q� >�>�?� �����?�?�0�0��!�!�?�3� ����r!c��|j�s'|j�}t|ttf�rytj|�j�yrP)� cancelled� exceptionr� SystemExit�KeyboardInterruptr� _get_loop�stop)�fut�excs r�_run_until_complete_cbrn�sB���=�=�?��m�m�o���c�J�(9�:�;� ����c����!r!�TCP_NODELAYc�4�|jtjtjhvrl|jtj k(rN|jtjk(r0|jtjtjd�yyyy�Nr) rFr+r@rrGr:rHr8r-ror0s r�_set_nodelayrr�sj���K�K�F�N�N�F�O�O�<�<�� � �V�/�/�/�� � �f�0�0�0��O�O�F�.�.��0B�0B�A�F�1�0� =r!c��yrPrQr0s rrrrr�s��r!c�\�t�&t|tj�rtd��yy)Nz"Socket cannot be of type SSLSocket)�sslr� SSLSocketr>r0s r�_check_ssl_socketrw�s'�� ��:�d�C�M�M�:��<�=�=�;�r!c�B�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zy )�_SendfileFallbackProtocolc��t|tj�std��||_|j�|_|j�|_|j|_ |j�|j|�|jr*|jjj�|_yd|_y)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����&�*�">�">�?��L�M�M� ����)�)�+���&,�&7�&7�&9��#�&,�&=�&=��#��������D�!��&�&�$(�O�O�$9�$9�$G�$G�$I�D�!�$(�D�!r!c��K�|jj�rtd��|j}|�y|�d{���y7��w)NzConnection closed by peer)r|� is_closing�ConnectionErrorr�)r�rls r�drainz_SendfileFallbackProtocol.drain�s<�����?�?�%�%�'�!�"=�>�>��#�#���;��� � �s�:A�A�Ac��td��)Nz?Invalid state: connection should have been established already.��RuntimeError)r�� transports r�connection_madez)_SendfileFallbackProtocol.connection_made�s���N�O� Or!c���|j�B|�%|jjtd��n|jj|�|jj |�y)NzConnection is closed by peer)r�� set_exceptionr�r~�connection_lost)r�rms rr�z)_SendfileFallbackProtocol.connection_lost�s[��� � �,��{��%�%�3�3�#�$B�C�E��%�%�3�3�C�8����#�#�C�(r!c�p�|j�y|jjj�|_yrP)r�r|r�r��r�s r� pause_writingz'_SendfileFallbackProtocol.pause_writing�s,��� � �,�� $��� 5� 5� C� C� E��r!c�b�|j�y|jjd�d|_y)NF)r�� set_resultr�s r�resume_writingz(_SendfileFallbackProtocol.resume_writing�s-��� � �(�����(�(��/� $��r!c��td���Nz'Invalid state: reading should be pausedr�)r��datas r� data_receivedz'_SendfileFallbackProtocol.data_received����D�E�Er!c��td��r�r�r�s r�eof_receivedz&_SendfileFallbackProtocol.eof_receivedr�r!c��<K�|jj|j�|jr|jj �|j �|j j �|jr|jj�yy�wrP) r|r�r~r��resume_readingr��cancelr�r�r�s r�restorez!_SendfileFallbackProtocol.restoress�������$�$�T�[�[�1��&�&��O�O�*�*�,�� � �,� �!�!�(�(�*��&�&��K�K�&�&�(�'�s�BBN)�__name__� __module__�__qualname__r�r�r�r�r�r�r�r�r�rQr!rryry�s3��)��O� )�F� %�F�F� )r!ryc�h�eZdZ dd�Zd�Zd�Zd�Zd�Zd�Zd�Z d �Z ed ��Zd�Z d�Zd �Zd�Zy)rNc��||_||_d|_g|_||_||_||_||_||_d|_ d|_ y)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__sU���� ��� ������ �!1����� �'���&;��#�%9��"��� �$(��!r!c�P�d|jj�d|j�d�S)N�<z sockets=�>)� __class__r�r�r�s r�__repr__zServer.__repr__#s'���4�>�>�*�*�+�9�T�\�\�4D�A�F�Fr!c�.�|xjdz c_yrq)r�r�s r�_attachzServer._attach&s�����a��r!c��|xjdzc_|jdk(r|j�|j�yyy)Nrr)r�r��_wakeupr�s r�_detachzServer._detach*s;�����a�������"�t�}�}�'<��L�L�N�(=�"r!c�|�|j}d|_|D]$}|j�r�|jd��&yrP)r��doner�)r��waiters�waiters rr�zServer._wakeup0s3���-�-���� ��F��;�;�=��!�!�$�'�r!c �*�|jryd|_|jD]p}|j|j�|jj|j||j||j|j|j��ry�NT) r�r��listenr�r��_start_servingr�r�r�r�)r�r1s rr�zServer._start_serving7sp���=�=���� ��M�M�D��K�K�� � �&��J�J�%�%��&�&��d�.?�.?��d�m�m�T�%@�%@��*�*� ,�"r!c��|jSrP)r�r�s r�get_loopzServer.get_loopBs���z�z�r!c��|jSrP)r�r�s r� is_servingzServer.is_servingEs���}�}�r!c�T�|j�ytd�|jD��S)NrQc3�FK�|]}tj|����y�wrP)r�TransportSocket)rR�ss rrTz!Server.sockets.<locals>.<genexpr>Ls����F� �1�V�+�+�A�.� �s�!)r��tupler�s rr�zServer.socketsHs$���=�=� ���F�� � �F�F�Fr!c�P�|j}|�yd|_|D]}|jj|��d|_|j�;|jj�s!|jj �d|_|jdk(r|j�yy)NFr) r�r�� _stop_servingr�r�r�r�r�r�)r�r�r1s r�closezServer.closeNs����-�-���?���� ��D��J�J�$�$�T�*���� ��%�%�1��-�-�2�2�4��%�%�,�,�.�(,�D�%�����"��L�L�N�#r!c��jK�|j�tjd��d{���y7��w)Nr)r�r�sleepr�s r� start_servingzServer.start_servingas%���������k�k�!�n���s�)3�1�3c��K�|j�td|�d���|j�td|�d���|j�|jj�|_ |j�d{��� d|_y7� #tj$r1 |j�|j��d{���7�#�xYwwxYw#d|_wxYw�w)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���$��!M�N�P� P��=�=� ����� �;�<�<�����$(�J�J�$<�$<�$>��!� -��+�+�+�+�)-�D�%� ,���(�(� � �� � ���&�&�(�(�(����� ��)-�D�%�s`�A&C�)B�8B�9B�>C�B�C�#C�?C�C�C�C�C�C� C�Cc��K� |j�y|jj�}|jj|�|�d{���y7��wrP)r�r�r�rB)r�r�s rr�zServer.wait_closed|sE���� �(�=�=� �����)�)�+��� � ���V�$����s�A A�A�ArP)r�r�r�r�r�r�r�r�r�r�r��propertyr�r�r�r�r�rQr!rrrs[��>B�)�G� ��(� ,����G��G� �&�-�*r!rc��eZdZd�Zd�Zd�Zddd�d�Zd�Zd�Zd\ddd �d �Z d\dddddddd �d�Z d]d�Z d^d�Z d^d�Z d\d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd\d�Zd�Zd�Zd�Zd�Zd�Zd �Zd!�Zej>fd"�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`dd4�d5�Z/d6�Z0d7�Z1d8�Z2d\d9�Z3 d^dd0d0d0ddddddddd:�d;�Z4 dad<�Z5d`dd4�d=�Z6d>�Z7d?�Z8ddddd@�dA�Z9 d^d0d0d0ddddB�dC�Z:d0e;jxd0d0d1�dD�Z=dE�Z> d^e;j~e;j�ddFdddddddG� dH�ZAddddI�dJ�ZBdK�ZCdL�ZDdM�ZEeFj�eFj�eFj�ddd0ddddN� dO�ZHeFj�eFj�eFj�ddd0ddddN� dP�ZIdQ�ZJdR�ZKdS�ZLdT�ZMdU�ZNdV�ZOdW�ZPdX�ZQdY�ZRdZ�ZSd[�ZTy)brc���d|_d|_d|_tj�|_g|_d|_d|_d|_ tjd�j|_ d|_|jt!j"��d|_d|_d|_d|_d|_t/j0�|_d|_d|_y)NrF� monotonicg�������?)�_timer_cancelled_count�_closed� _stoppingrU�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�!4�[�!A�!L�!L���"&������z�0�0�2�3�'*��#�#���!���27��/�6:��3�"�/�/�+���*/��'�).��&r!c ��d|jj�d|j��d|j��d|j ��d� S)Nr�z running=z closed=z debug=r�)r�r�� is_running� is_closed� get_debugr�s rr�zBaseEventLoop.__repr__�sP������'�'�(� �$�/�/�2C�1D�E��n�n�&�'�w�t�~�~�/?�.@�� C� r!c�0� tj|��S)N�r�)r�Futurer�s rr�zBaseEventLoop.create_future�s��:��~�~�4�(�(r!N)�name�contextc�4� |j�|j�3tj||||��}|jrM|jd=n?|�|j||�}n|j|||��}tj ||� |~S#~wxYw)N)r�r r ����r )� _check_closedr�rr�_source_traceback�_set_task_name)r��coror r �tasks r�create_taskzBaseEventLoop.create_task�s��� � �������%��:�:�d��D�'�J�D��%�%��*�*�2�.����)�)�$��5���)�)�$��g�)�F��� � ��t�,� �����s�B�Bc�D� |�t|�std��||_y)Nz'task factory must be a callable or None)�callabler>r�)r��factorys r�set_task_factoryzBaseEventLoop.set_task_factory�s*�� ���x��'8��E�F�F�$��r!c�� |jSrP)r�r�s r�get_task_factoryzBaseEventLoop.get_task_factory�s��J��!�!�!r!)�extra�serverc�� t�rP��NotImplementedError)r�r1�protocolr�rrs r�_make_socket_transportz$BaseEventLoop._make_socket_transport�s��&�!�!r!FT)�server_side�server_hostnamerrr�r��call_connection_madec�� t�rPr)r��rawsockr� sslcontextr�r!r"rrr�r�r#s r�_make_ssl_transportz!BaseEventLoop._make_ssl_transport�s �� $�!�!r!c�� t�rPr)r�r1r�addressr�rs r�_make_datagram_transportz&BaseEventLoop._make_datagram_transport�s��(�!�!r!c�� t�rPr�r��piperr�rs r�_make_read_pipe_transportz'BaseEventLoop._make_read_pipe_transports��)�!�!r!c�� t�rPrr,s r�_make_write_pipe_transportz(BaseEventLoop._make_write_pipe_transports��*�!�!r!c ��K� t��wrPr) r�r�args�shell�stdin�stdout�stderr�bufsizer�kwargss r�_make_subprocess_transportz(BaseEventLoop._make_subprocess_transports���� +�!�!�s� c�� t�rPrr�s r�_write_to_selfzBaseEventLoop._write_to_selfs�� �"�!r!c�� t�rPr)r�� event_lists r�_process_eventszBaseEventLoop._process_eventss��&�!�!r!c�2�|jrtd��y)NzEvent loop is closed)r�r�r�s rrzBaseEventLoop._check_closeds���<�<��5�6�6�r!c�2�|jrtd��y)Nz!Executor shutdown has been called)rr�r�s r�_check_default_executorz%BaseEventLoop._check_default_executor#s���)�)��B�C�C�*r!c��|jj|�|j�s+|j|j|j��yyrP)r��discardr�call_soon_threadsafer�aclose�r��agens r�_asyncgen_finalizer_hookz&BaseEventLoop._asyncgen_finalizer_hook's?��������%��~�~���%�%�d�&6�&6���� �F� r!c��|jr tjd|�d�t|��|jj|�y)Nzasynchronous generator z3 was scheduled after loop.shutdown_asyncgens() call��source)r�warnings�warn�ResourceWarningr��addrFs r�_asyncgen_firstiter_hookz&BaseEventLoop._asyncgen_firstiter_hook,sA���*�*��M�M�)�$��21�2��� .� �����D�!r!c��K� d|_t|j�syt|j�}|jj �tj|D�cgc]}|j���c}ddi��d{���}t||�D].\}}t|t�s�|jd|��||d���0ycc}w7�G�w)NT�return_exceptionsz;an error occurred during closing of asynchronous generator )�messagerg�asyncgen)r�lenr�rW�clearr�gatherrE�zipr� Exception�call_exception_handler)r�� closing_agens�ag�results�resultrGs r�shutdown_asyncgensz BaseEventLoop.shutdown_asyncgens5s�����:�*.��'��4�?�?�#� ��T�_�_�-� ����������$1� 2�M�b�b�i�i�k�M� 2�$�"�$�$�� ���7�L�F�D��&�)�,��+�+�"9�9=�� B�!'� $� -��8��3�$�s$�A!C�#C�: C�C�&C�,!Cc��K� d|_|j�y|j�}tj|j |f��}|j � tj|�4�d{���|�d{���ddd��d{���|j�y7�/7�'7�#1�d{���7swY�)xYw#t$r?tjd|�d�td��|jjd��YywxYw�w) NT)�targetr2z:The executor did not finishing joining its threads within z seconds.�)� stacklevelF��wait)rr�r�� threading�Thread�_do_shutdown�startr �timeout�join�TimeoutErrorrLrM�RuntimeWarning�shutdown)r�rj�future�threads r�shutdown_default_executorz'BaseEventLoop.shutdown_default_executorNs����� �*.��&��!�!�)���#�#�%���!�!��):�):�&��K������ ��'�'��0�0����1�0� �K�K�M�1����1��0�0�0��� 8��M�M�0�07�y� �C�(�Q� 8� �"�"�+�+��+�7� 8�s��AD �B?�4B$�5B?�8B*�>B&�?B*�B?�B(�B?�D �$B?�&B*�(B?�*B<�0B3�1B<�8B?�?AD�D �D�D c�Z� |jjd��|j�s"|jtj |d�yy#t$rP}|j�s6|j�s!|j|j|�Yd}~yYd}~yYd}~yd}~wwxYw)NTrd) r�rnrrDr�_set_result_unless_cancelledrYrfr�)r�ro�exs rrhzBaseEventLoop._do_shutdownfs��� D��"�"�+�+��+�6��>�>�#��)�)�'�*N�*N�*0�$�8�$��� D��>�>�#�F�,<�,<�,>��)�)�&�*>�*>��C�C�-?�#�� D�s�A A� B*�<B%�%B*c�x�|j�rtd��tj��td��y)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_runningps>���?�?���C�D�D��#�#�%�1��I�K� K�2r!c�� |j�|j�|j|j�t j �} t j�|_t j|j|j��tj|� |j�|jrn� d|_d|_tjd�|jd�t j|�y#d|_d|_tjd�|jd�t j|�wxYw)N)� firstiter� finalizerF)rrw�_set_coroutine_origin_tracking�_debug�sys�get_asyncgen_hooksrf� get_identr��set_asyncgen_hooksrPrHr�_set_running_loop� _run_oncer�)r��old_agen_hookss r�run_foreverzBaseEventLoop.run_foreverws��)����������+�+�D�K�K�8��/�/�1�� 4�'�1�1�3�D�O��"�"�T�-J�-J�-1�-J�-J� L� �$�$�T�*����� ��>�>����"�D�N�"�D�O��$�$�T�*��/�/��6��"�"�N�3�� #�D�N�"�D�O��$�$�T�*��/�/��6��"�"�N�3�s�A8D�AEc�"� |j�|j�tj|�}t j ||��}|rd|_|jt� |j� |jt�|j�std��|j�S#|r0|j�r |j�s|j��xYw#|jt�wxYw)NrFz+Event loop stopped before Future completed.)rrwr�isfuturer� ensure_future�_log_destroy_pending�add_done_callbackrnr�r�rfrg�remove_done_callbackr�r^)r�ro�new_tasks r�run_until_completez BaseEventLoop.run_until_complete�s��� � ���������'�'��/�/���$�$�V�$�7���+0�F�'�� � �!7�8� @����� �'�'�(>�?��{�{�}��L�M�M��}�}���� ��F�K�K�M�&�2B�2B�2D�� � �"����'�'�(>�?�s�.B?�?5C4�4C7�7Dc�� d|_yr�)r�r�s rrkzBaseEventLoop.stop�s�� � ��r!c�n� |j�rtd��|jry|jrt j d|�d|_|jj�|jj�d|_ |j}|�d|_ |jd��yy)Nz!Cannot close a running event loopzClose %rTFrd)rr�r�r|r�debugr�rVr�rr�rn�r��executors rr�zBaseEventLoop.close�s��� ��?�?���B�C�C��<�<���;�;��L�L��T�*����������������)-��&��)�)����%)�D�"����5��)� r!c�� |jSrP)r�r�s rrzBaseEventLoop.is_closed�s��8��|�|�r!c��|j�s4|d|��t|��|j�s|j�yyy)Nzunclosed event loop rJ)rrNrr�)r��_warns r�__del__zBaseEventLoop.__del__�s=���~�~���(���1�?�4�P��?�?�$�� � ��%� r!c� � |jduSrP)r�r�s rrzBaseEventLoop.is_running�s��8����t�+�,r!c�,� tj�SrP)r�r�r�s rr�zBaseEventLoop.time�s�� ��~�~��r!r c�� |�td��|j|j�|z|g|��d|i�}|jr |jd=|S)Nzdelay must not be Noner r)r>�call_atr�r)r��delay�callbackr r2�timers r� call_laterzBaseEventLoop.call_later�sd�� ��=��4�5�5�����T�Y�Y�[�5�0�(�.�T�.�%,�.���"�"��'�'��+��r!c�P� |�td��|j�|jr"|j�|j |d�tj|||||�}|jr |jd=tj|j|�d|_ |S)Nzwhen cannot be Noner�rT)r>rr|� _check_thread�_check_callbackr�TimerHandler�heapq�heappushr�)r��whenr�r r2r�s rr�zBaseEventLoop.call_ats��� ��<��1�2�2������;�;���� �� � ��9�5��"�"�4��4��w�G���"�"��'�'��+� ���t����.�����r!c��� |j�|jr"|j�|j|d�|j |||�}|j r |j d=|S)N� call_soonr)rr|r�r�� _call_soonr�r�r�r r2rs rr�zBaseEventLoop.call_soonsf�� � �����;�;���� �� � ��;�7�����4��9���#�#��(�(��,�� r!c��tj|�stj|�rtd|�d���t |�std|�d|����y)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_callback(sg���"�"�8�,��.�.�x�8��1�&���<�>� >���!��4�V�H�=��l�$�%� %�"r!c��tj||||�}|jr |jd=|jj |�|S)Nr)r�Handlerr�rB)r�r�r2r rs rr�zBaseEventLoop._call_soon2sD�����x��t�W�=���#�#��(�(��,������6�"�� r!c�|� |j�ytj�}||jk7rtd��y)NzMNon-thread-safe operation invoked on an event loop other than the current one)r�rfrr�)r�� thread_ids rr�zBaseEventLoop._check_thread9sG�� ��?�?�"���'�'�)� �����'��'�(� (�(r!c��� |j�|jr|j|d�|j|||�}|jr |jd=|j�|S)NrDr)rr|r�r�rr;r�s rrDz"BaseEventLoop.call_soon_threadsafeJsc��0������;�;�� � ��+A�B�����4��9���#�#��(�(��,������ r!c�<�|j�|jr|j|d�|�E|j}|j �|�'t jjd��}||_t j|j|g|���|��S)N�run_in_executor�asyncio)�thread_name_prefixr) rr|r�r�rA� concurrentr�ThreadPoolExecutor�wrap_future�submit)r�r��funcr2s rr�zBaseEventLoop.run_in_executorUs��������;�;�� � ��'8�9����-�-�H��(�(�*���%�-�-�@�@�'0�A���*2��&��"�"��H�O�O�D�(�4�(�t�5� 5r!c�p�t|tjj�st d��||_y)Nz,executor must be ThreadPoolExecutor instance)rr�rr�r>r�r�s r�set_default_executorz"BaseEventLoop.set_default_executores,���(�J�$6�$6�$I�$I�J��J�K�K�!)��r!c�"�|�d|��g}|r|jd|���|r|jd|���|r|jd|���|r|jd|���dj|�}tjd|�|j �}tj||||||�} |j �|z } d|�d | d zd�d| ��}| |jk\rtj|�| Stj|�| S) N�:zfamily=ztype=zproto=zflags=�, zGet address info %szGetting address info z took g@�@z.3fzms: ) rBrkrr�r�r+�getaddrinfor��info)r�rDrErFrGrH�flags�msg�t0�addrinfo�dts r�_getaddrinfo_debugz BaseEventLoop._getaddrinfo_debugjs����q���!�"����J�J��� �+�,���J�J��t�h�'�(���J�J���y�)�*���J�J���y�)�*��i�i��n�����*�C�0� �Y�Y�[���%�%�d�D�&�$��u�M�� �Y�Y�[�2� ��%�c�U�&��c��#��d�8�,�O�� ��,�,�,��K�K����� �L�L����r!r�rFrGrHr�c ��K�|jr |j}ntj}|j d|||||||��d{���S7��wrP)r|r�r+r�r�)r�rDrErFrGrHr��getaddr_funcs rr�zBaseEventLoop.getaddrinfo�sU�����;�;��2�2�L�!�-�-�L��)�)��,��d�F�D�%��H�H� H�H�s�AA�A�Ac��bK�|jdtj||��d{���S7��wrP)r�r+�getnameinfo)r��sockaddrr�s rr�zBaseEventLoop.getnameinfo�s2�����)�)��&�$�$�h��7�7� 7�7�s�&/�-�/)�fallbackc��ZK�|jr|j�dk7rtd��t|�|j ||||� |j||||��d{���S7�#tj$r }|s�Yd}~nd}~wwxYw|j||||��d{���7S�w)Nrzthe socket must be non-blocking) r|� gettimeoutr,rw�_check_sendfile_params�_sock_sendfile_nativer�SendfileNotAvailableError�_sock_sendfile_fallback)r�r1�file�offset�countr�rms r� sock_sendfilezBaseEventLoop.sock_sendfile�s������;�;�4�?�?�,��1��>�?�?��$���#�#�D�$���>� ��3�3�D�$�4:�E�C�C� C�C���3�3� ����� ���1�1�$��28�%�A�A�A� A�sN�A B+� A+�$A)�%A+�(B+�)A+�+B�>B�B+�B�B+�%B(�&B+c��BK�tjd|�d|�d����w)Nz-syscall sendfile is not available for socket z and file z combination�rr��r�r1r�r�r�s rr�z#BaseEventLoop._sock_sendfile_native�s4�����2�2�;�D�8�D��x�|� -�.� .�s�c��8K�|r|j|�|rt|tj�ntj}t |�}d} |rt||z |�}|dkrnYt|�d|}|j d|j|��d{���} | sn#|j||d| ��d{���|| z }�p||dkDr"t|d�r|j||z�SSS7�S7�5#|dkDr"t|d�r|j||z�wwwxYw�w)Nr�seek) r��minr�!SENDFILE_FALLBACK_READBUFFER_SIZE� bytearray� memoryviewr��readinto�sock_sendallr*) r�r1r�r�r�� blocksize�buf� total_sent�view�reads rr�z%BaseEventLoop._sock_sendfile_fallback�s1������I�I�f��� ��y�B�B�C�#�E�E� �� �"��� � /��� #�E�J�$6� � B�I� �A�~��!�#��z� �2��!�1�1�$�� � �t�L�L�����'�'��d�5�D�k�:�:�:��d�"� ����A�~�'�$��"7�� � �&�:�-�.�#8�~�M��;���A�~�'�$��"7�� � �&�:�-�.�#8�~�sC�A D�AC.�C*�C.�6C,�7C.�(D�*C.�,C.�.)D�Dc��dt|dd�vrtd��|jtjk(std��|�It|t�stdj|���|dkrtdj|���t|t�stdj|���|dkrtdj|���y)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,rGr+r:rr=r>�formatr�s rr�z$BaseEventLoop._check_sendfile_params�s����g�d�F�C�0�0��C�D�D��y�y�F�.�.�.��J�K�K����e�S�)��A�H�H��O�Q�Q���z� �A�H�H��O�Q�Q��&�#�&��B�I�I���� ��A�:��B�I�I���� �r!c���K� g}|j|�|\}}}}} d} tj|||��} | jd�|�G|D]!\}}}}}||k7r� | j|�n"|r|j��t d|�d���|j| | ��d{���| dx}}S#t$rP} d|�dt| �j ���}t | j|�} |j| �Yd} ~ ��d} ~ wwxYw7�f#t$r)} |j| �| �| j��d} ~ w| �| j��xYw#dx}}wxYw�w)N�rFrGrHF�*error while attempting to bind on address �: z&no matching local address with family=z found)rBr+�setblocking�bindr/r�lower�errno�pop�sock_connectr�)r�r� addr_info�local_addr_infos� my_exceptionsrF�type_rH�_r)r1�lfamily�laddrrmr�s r� _connect_sockzBaseEventLoop._connect_sock�s�����2�� �� ���-�(�+4�(���u�a����# .��=�=��U�%�H�D����U�#��+�/?�+�G�Q��1�e��&�(� � 2�� � �%�(�� 0@�%�+�/�/�1�1�%�(O��y�PV�&W�X�X��#�#�D�'�2�2�2��*.�-�J���1#�2�'�',�i�r�#�c�(�.�.�2B�1C�E��&�c�i�i��5��%�,�,�S�1�1�� 2�� 3��� �� � ��%���� � ���� ���� � ����)-�-�J��sk� E$�<D� B5�19D�*D�+D�0E$�5 D�>AD �D� D�D� E�$E�E�E�E!�!E$)rurFrHr�r1� local_addrr"r�r��happy_eyeballs_delay� interleave� all_errorsc��D����K� | � |std��| �|r|std��|} |� |std��|� |std��|�t|�| �|�d}|�|���|�td���j||f|tj||����d{���}|std��| �:�j| |tj||����d{�����s td��d�|rt ||�}g�| �%|D]} �j�|���d{���}n0n.tj���fd �|D�| �� ��d{���d}|�ʉD��cgc]}|D]}|��� c}}� |rtd���t��dk(r�d�t�d��t�fd ��D��r�d�tdjdjd��D�����|�td��|j tjk7rtd|�����j#|||| ||���d{���\}}�j$r+|j'd�}t)j*d|||||�||fS7���7���7��f#t $rY���wxYw7��Jcc}}w#d�wxYw7�k�w)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�rFrGrHr�r��!getaddrinfo() returned empty listc3�0�K�|] }|f���fd� ���y�w)c�*���j�|��SrP)r�)r�r�laddr_infosr�s ���r�<lambda>z;BaseEventLoop.create_connection.<locals>.<genexpr>.<lambda>]s���$�2D�2D�&��+�3r!NrQ)rRr�rrr�s ���rrTz2BaseEventLoop.create_connection.<locals>.<genexpr>Zs'������).�H�)1���).�s�rrzcreate_connection failedc3�:�K�|]}t|��k(���y�wrP�r)rRrm�models �rrTz2BaseEventLoop.create_connection.<locals>.<genexpr>ps�����G�J�S�s�3�x�5�0�J�s�zMultiple exceptions: {}r�c3�2K�|]}t|����y�wrPr)rRrms rrTz2BaseEventLoop.create_connection.<locals>.<genexpr>us����%E�*�3�c�#�h�*�s�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,rw�_ensure_resolvedr+r:r/rdr�r�staggered_race�ExceptionGrouprUr�allr�rkrG�_create_connection_transportr|�get_extra_inforr�)r�r�rDrErurFrHr�r1r�r"r�r�rrr�infosr��subrmr�rrrrs` @@@r�create_connectionzBaseEventLoop.create_connectionsv����� ��&�s��J�K�K��"�s�� �"A�B�B�"�O� �,�S��C�E� E� �+�C��B�D� D����d�#��+� �0B��J���t�/��� �N�P�P��/�/��t��V��'�'�u�E��0�N�N�E���A�B�B��%�$(�$9�$9��v��+�+�5��d�%:�%,�,��#�!�"E�F�F�"���-�e�Z�@���J�#�+� %�H�!�%)�%7�%7�&��+�&?� ?��� !&�(�6�6��).� �)��������|�-7�G�Z�c�3�C�c�3�c�Z�G� �&�!�,�-G��T�T��:��!�+�(��m�+�!$�J�q�M� 2���G�J�G�G�",�Q�-�/�&�&?�&F�&F� �I�I�%E�*�%E�E�'G�H�H��|� �K�M�M��y�y�F�.�.�.�!�8���A�C�C�%)�$E�$E��"�C��"7�!5�%F�%7�7�� �8��;�;��+�+�H�5�D��L�L�:��t�T�9�h� @��(�"�"�mN��,��" ?��#�!� �!����H�� "&�J�� 7�s��BJ �I5�;J �I8�*J �?I>�I;�I>�*J �J�J �J�#J �(A8J� AJ �2J�3AJ �8J �;I>�> J�J � J�J �J �J�J c ��.K�|jd�|�}|j�} |r.t|t�rdn|} |j ||| | ||||��}n|j||| �} | �d{���||fS7�#|j ��xYw�w)NF�r!r"r�r�)r�r�r�boolr'r r�)r�r1r�rur"r!r�r�rr�r&r�s rrz*BaseEventLoop._create_connection_transport�s����� �����#�%���#�#�%���!+�C��!6��C�J��0�0��h� �F�'��&;�%9� 1�;�I��3�3�D�(�F�K�I� ��L�L� �(�"�"� �� ��O�O���s0�A,B�/A?�4A=�5A?�9B�=A?�?B�Bc��K� |j�rtd��t|dtjj �}|tjj urtd|����|tjjur |j||||��d{���S|std|����|j||||��d{���S7�0#tj$r }|s�Yd}~�Id}~wwxYw7�)�w)NzTransport is closing�_sendfile_compatiblez(sendfile is not supported for transport zHfallback 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�rms r�sendfilezBaseEventLoop.sendfile�s���� �,���!��5�6�6��y�"8� �.�.�:�:�<���9�*�*�6�6�6��:�9�-�H�J� J��9�*�*�5�5�5� �!�2�2�9�d�39�5�B�B�B���+�+4�-�9�:� :��,�,�Y��-3�U�<�<� <�B���7�7� ��� �� ��<�sN�BC:�C�"C�#C�&(C:�C8�C:�C�C5�(C0�+C:�0C5�5C:c��4K�tjd���w)Nz!sendfile syscall is not supportedr�)r�r�r�r�r�s rr#zBaseEventLoop._sendfile_native�s�����2�2�/�1� 1�s�c��K�|r|j|�|rt|d�nd}t|�}d}t|�} |rSt||z |�}|dkr?||dkDr t |d�r|j||z�|j��d{���St |�d|} |jd|j| ��d{���} | s?||dkDr t |d�r|j||z�|j��d{���S|j| d| �|j��d{���|| z }��7��7�y7�;7�#|dkDr t |d�r|j||z�|j��d{���7wxYw�w)Ni@rr�)r�r�r�ryr*r�r�r�r��writer�)r�r�r�r�r�r�r�r�rHr�r�s rr$z BaseEventLoop._sendfile_fallback�sx������I�I�f��).�C��u�%�E� �� �"��� �)�&�1�� "��� #�E�J�$6� � B�I� �A�~�)��A�~�'�$��"7�� � �&�:�-�.��-�-�/�!�!�"�#��z� �2��!�1�1�$�� � �t�L�L���%� �A�~�'�$��"7�� � �&�:�-�.��-�-�/�!�!� ���T�%�4�[�)��k�k�m�#�#��d�"� �� "��M�� "��$���A�~�'�$��"7�� � �&�:�-�.��-�-�/�!�!�s��<F�E�8F�D;�F�.E�D=�E�8F�D?�F� 'E�0E�1 E�;F�=E�?F�E�9F�<E?�=F�Frc��pK� t�td��t|tj�st d|����t|dd�st d|�d���|j �}tj||||||||d�� } |j�|j| �|j| j|�} |j|j�} |�d{���| j"S7�#t$r2|j�| j!�|j!��wxYw�w)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#)rur�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�sB���� � �;��C�D�D��*�c�n�n�5���!�n�&�'� '��y�"9�5�A���Y�M�)I�J�L� L��#�#�%���+�+��(�J����"7�!5�!&�(�� ���!����|�,��^�^�L�$@�$@�)�L� ��N�N�9�#;�#;�<� � ��L�L��*�*�*� ��� ��O�O����������� �s0�CD6� C8�%C6�&C8�*D6�6C8�8;D3�3D6)rFrHr�� reuse_port�allow_broadcastr1c ��FK� | ��| jtjk(rtd| ����|s|s |s|s|s|s|rGt |||||||��} djd�| j �D��}td|�d���| jd�d}�nb|s|s|dk(rtd ��||fd ff} �n�ttd�r�|tjk(r�||fD] }|��t|t�r�td��|rO|dd vrH tjtj|�j �rtj"|�||f||fff} n�i}d|fd|ffD]�\}}|�� t|t,�rt/|�dk(std��|j1||tj2|||���d{���}|st'd��|D]\}}}}}||f}||vrddg||<||||<�!��|j �D��cgc]\}}|r|d�|r|d�||f��} }}| std��g}| D]�\\}}\}}d} d} tj|tj2|��} |rt5| �|r/| j7tj8tj:d�| jd�|r| j=|�|r|s|j?| |��d{���|}n|d�|�}|jE�}|jG| |||�}|jHr4|rt)jJd||||�nt)jLd|||� |�d{���||fS#t$$rY��0t&$r"}t)j*d||�Yd}~��Ud}~wwxYw7���cc}}w7��#t&$r/}| �| jA�|jB|�Yd}~���d}~w| �| jA��xYw7��#|jA��xYw�w)Nz$A datagram socket was expected, got )r��remote_addrrFrHr�r3r4r�c3�6K�|]\}}|s� |�d|�����y�w)�=NrQ)rR�k�vs rrTz9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>=s!����$N�L�D�A�q�A��s�!�A�3�Z�L�s� �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: %rrrbz2-tuple is expectedrrzcan not get address informationr�z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))'rGr+r:r,�dictrk�itemsr�r*r=rrr>�stat�S_ISSOCK�os�st_mode�remove�FileNotFoundErrorr/r�errorr�rUrr;r2r-r.�SO_BROADCASTr�r�r�rBr�r*r|r�r�) r�r�r�r6rFrHr�r3r4r1�opts�problems�r_addr�addr_pairs_infora�err� addr_infos�idxr�famr��pror)�key� addr_pairr� local_address�remote_addressrmrr�r�s r�create_datagram_endpointz&BaseEventLoop.create_datagram_endpoint+s����� *����y�y�F�.�.�.� �:�4�(�C�E�E��k��e�u��/��z�{�#)��e�'1�,;�=�� �9�9�$N�D�J�J�L�$N�N�� �0�08�z��<�=�=� ���U�#��F��+��Q�;�$�%@�A�A�%+�U�O�\�#B�"D�����+��&�.�.�0H�'��5�D��'� �4��0E�'�(<�=�=�6��*�Q�-�{�"B� 6��=�=�����)<�)D�)D�E��I�I�j�1�&,�U�O�%/��$=�$?�#B�� � �#$�j�/�A�{�3C�!D�I�C���'� *�4�� 7�C��I��N�"+�,A�"B�B�&*�&;�&;� ��f�6G�6G�"'�u�4�'<�'A�!A�� %�")�*M�"N�N�7<�3�C��C��G�#&��*�C�"�*�4�37��,� �3��3:�J�s�O�C�0� 8=�"E�&<F�;K�;K�;M�#E�;M���i�'�I�a�L�,@�(�Y�q�\�-A��)�$�;M� �#E� '�$�%F�G�G��J�6E�2��&�%�0�-�������!�=�=�%�F�,=�,=�U�L�D�!�&�t�,�&����"�-�-�v�/B�/B�A�G��$�$�U�+�!�� � �-�0�"�.�"&�"3�"3�D�.�"I�I�I�!/���96E�<!��m�#�#�%���#�#�%���1�1��(�F�F�,� ��;�;�����0�&��Y��J����(�(�)�X�?� ��L�L� �(�"�"��}-���"�6����&5�%/��6�6��6�� !A��#E�8J���+��'�� � ��%�J�%�%�c�*�*����'�� � ����* �� ��O�O���s��C"P!�%P!�6P!�AM7�P!�0AP!�N0�A P!�N3�($P!� B!N;�.N9�/N;�5A3P!�)P�.P �/P�3P!�7 N-�P!�N-�N(�"P!�(N-�-P!�3P!�9N;�; P�$O.�(P!�.P�P!� P�P�P!c��K�|dd\}}t|||||g|dd���} | �| gS|j||||||���d{���S7��w)Nrbr�)rMr�) r�r)rFrGrHr�r�rDrEr�s rrzBaseEventLoop._ensure_resolved�st�����R�a�[� ��d��D�$���e�J�g�a�b�k�J�����6�M��)�)�$��V�$�05�U�*�D�D� D�D�s�;A�A�Ac��K�|j||f|tj||���d{���}|std|�d���|S7��w)N)rFrGr�r�zgetaddrinfo(z) returned empty list)rr+r:r/)r�rDrErFr�rs r�_create_server_getaddrinfoz(BaseEventLoop._create_server_getaddrinfo�s]�����+�+�T�4�L��17�1C�1C�27�d�,�D�D����L���0E�F�G�G���D�s�*A�A�Ar) rFr�r1r�ru� reuse_addressr3r�r�r�c ��K� t|t�rtd��|� |�td��|� |�td��|�t |�|�|��"|�td��| �(t jdk(xrtjdk7} g}|dk(rdg}n:t|t�s$t|tjj�s|g}n|}|D�cgc]}|j||||����}}tj|��d{���}t!t"j$j'|��}d } |D]�}|\}}}}} t)j(|||�}|j3|�| r/|j5t(j6t(j8d�| r-|t(j:t(j<fvrt?|�t@rR|t(j<k(r?tCt(d �r/|j5t(jDt(jFd� |jI|���|stKd|D�cgc]}|d�� c}����d}|sS|D]}|jU��n;|�td��|jVt(jXk7rtd|����|g}|D]}|j[d ��t]|||||||�}| r-|j_�tj`d��d{���|j,rt/jbd|�|Scc}w7��+#t(j*$r*|j,rt/j0d |||d��Y��8wxYw#tJ$r�}d|�dt|�jM���}|jNtNjPk(rG|jS�|jU�|j,rt/j0|�Yd}~���tK|jN|�d�d}~wwxYwcc}w#|s|D]}|jU��wwxYw7��@�w)Nz*ssl argument must be an SSLContext or Nonerrr�posix�cygwinr5)rFr�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 �z)Neither host/port nor sock were specifiedrrz %r is serving)2rrr>r,rwrCr r}�platformrrU�abc�IterablerYrrW�setrZr[r\r+rGr|r�warningrBr-r.�SO_REUSEADDRr@rr2rAr*r`�IPV6_V6ONLYr�r/r�r�� EADDRNOTAVAILr�r�rGr:r�rr�r�r�)r�r�rDrErFr�r1r�rurZr3r�r�r�r��hosts�fsr� completed�resrL�socktyperH� canonname�sarMr�r�rs r� create_serverzBaseEventLoop.create_server�s���� ��c�4� ��H�I�I� �,����C�E� E� �+����B�D� D����d�#���t�/��� �N�P�P��$� "���7� 2� O�s�|�|�x�7O� ��G��r�z�����T�3�'� ��{���'?�'?�@������$�%�#�d��1�1�$��V�8=�2�?�#� �%� �,�,��+�+�E�� ���5�5�e�<�=�E��I�4 %� �C�9<�6�B��%��B�!�%�}�}�R��5�A���N�N�4�(�$����"�-�-�v�/B�/B�D�J�"�b�V�^�^�V�_�_�,M�&M�&�t�,�"��&�/�/�1�#�F�N�;�����(;�(;�(.�(:�(:�(,�.� @�� � �"� �;!�V�!�:?�%@�%�$�d�1�g�%�%@�#C�D�D�!� � � '��� � ��!(��|� �!L�M�M��y�y�F�.�.�.� �#E�d�X�!N�O�O��f�G��D����U�#����g�'7��W�&;�,�.����!�!�#��+�+�a�.� � ��;�;��K�K���0�� ��c%�,��"�<�<�!��;�;�"�N�N�,G�+-�x���O�!� !��4#�@�#%�c�#�h�n�n�&6� 8���9�9��(;�(;�;�#�K�K�M� �J�J�L�#�{�{� &���s� 3�$�%�c�i�i��5�4�?��@��&A��!� '��� � ��!(�!��( !�s��C Q�L(�+Q�L-�.Q�2 P �L0�C P �!M0�2P �P �P �B(Q�?P?�.Q�09M-�)P �,M-�-P �0 P�9A=P�6P �<P�P�P � P<�<Q)rur�r�c ��rK�|jtjk7rtd|����|� |std��|� |std��|�t |�|j|||dd||���d{���\}}|jr)|jd�}tjd|||�||fS7�@�w) Nrrrr5T)r!r�r�r+z%r handled: (%r, %r)) rGr+r:r,rwrr|rrr�)r�r�r1rur�r�r�rs r�connect_accepted_socketz%BaseEventLoop.connect_accepted_socketRs����� �9�9��*�*�*��A�$��J�K�K� �,�S��C�E� E� �+�C��B�D� D����d�#�$(�$E�$E��"�C���"7�!5�%F�%7�7�� �8��;�;��+�+�H�5�D��L�L�/��y�(�K��(�"�"�7�s�A2B7�4B5�5AB7c��K�|�}|j�}|j|||�} |�d{���|jr&t j d|j �||�||fS7�:#|j��xYw�w)Nz Read pipe %r connected: (%r, %r))r�r.r�r|rr��fileno�r�r�r-rr�r�s r�connect_read_pipezBaseEventLoop.connect_read_pipeps�����#�%���#�#�%���2�2�4��6�J� � ��L�L� �;�;��L�L�;����� �8� =��(�"�"� �� ��O�O����+�+B�A0�A.�A0�6B�.A0�0B�Bc��K�|�}|j�}|j|||�} |�d{���|jr&t j d|j �||�||fS7�:#|j��xYw�w)Nz!Write pipe %r connected: (%r, %r))r�r0r�r|rr�rurvs r�connect_write_pipez BaseEventLoop.connect_write_pipe�s�����#�%���#�#�%���3�3�D�(�F�K� � ��L�L� �;�;��L�L�<����� �8� =��(�"�"� �� ��O�O���rxc�r�|g}|�|jdt|����|�1|tjk(r|jdt|����n>|�|jdt|����|�|jdt|����t j dj |��y)Nzstdin=zstdout=stderr=zstdout=zstderr=� )rBr'r#r%rr�rk)r�r�r4r5r6r�s r�_log_subprocesszBaseEventLoop._log_subprocess�s����u�����K�K�&��e�!4� 5�6�7���&�J�,=�,=�"=��K�K�.��f�)=�(>�?�@��!����g�l�6�&:�%;�<�=��!����g�l�6�&:�%;�<�=����S�X�X�d�^�$r!) r4r5r6�universal_newlinesr3r7�encoding�errors�textc ���K�t|ttf�std��|rtd��|std��|dk7rtd��|rtd��| �td��| �td��|�} d}|jrd |z}|j||||�|j| |d ||||fi|���d{���}|jr|�tjd||�|| fS7�-�w)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,r|r}r9rr�)r�r��cmdr4r5r6r~r3r7rr�r�r8r� debug_logr�s r�subprocess_shellzBaseEventLoop.subprocess_shell�s�����#��s�|�,��3�4�4���?�@�@���1�2�2��a�<��0�1�1���1�2�2����4�5�5����2�3�3�#�%��� ��;�;�/��4�I�� � ��E�6�6�B�9�$�9�9��c�4�����K�CI�K�K� ��;�;�9�0��K�K��)�Y�7��(�"�"� K�s�B=C/�?C-�.C/c ��K�|rtd��|rtd��|dk7rtd��|rtd��| �td��| �td��|f|z}|�}d}|jrd|��}|j||||�|j||d ||||fi| ���d{���}|jr|�t j d ||�||fS7�-�w)Nr�zshell must be Falserr�r�r�r�zexecute program Fr�)r,r|r}r9rr�)r�r��programr4r5r6r~r3r7rr�r�r2r8� popen_argsrr�r�s r�subprocess_execzBaseEventLoop.subprocess_exec�s������?�@�@���2�3�3��a�<��0�1�1���1�2�2����4�5�5����2�3�3��Z�$�&� �#�%��� ��;�;�+�7�+�6�I�� � ��E�6�6�B�9�$�9�9��j�%��������� ��;�;�9�0��K�K��)�Y�7��(�"�"��s�B"C�$C�%.Cc�� |jSrP)r�r�s r�get_exception_handlerz#BaseEventLoop.get_exception_handler�s�� ��&�&�&r!c�J� |�t|�std|����||_y)Nz+A callable object or None is expected, got )rr>r�)r��handlers r�set_exception_handlerz#BaseEventLoop.set_exception_handler�s:�� ���x��'8��#�#*�+�/�0� 0�")��r!c��� |jd�}|sd}|jd�}|�t|�||jf}nd}d|vr;|j�/|jjr|jj|d<|g}t|�D]�}|dvr�||}|dk(r:dj tj|��}d }||j�z }nJ|dk(r:dj tj|��}d }||j�z }nt|�}|j|�d|�����tjdj |�|� �y)NrSz!Unhandled exception in event looprgF�source_traceback�handle_traceback>rSrgr5z+Object created at (most recent call last): z+Handle created at (most recent call last): r�� r^)�getrG� __traceback__r�r�sortedrk� traceback�format_list�rstriprrBrrG) r�r rSrgr_� log_linesrR�value�tbs r�default_exception_handlerz'BaseEventLoop.default_exception_handler�s`�� ��+�+�i�(���9�G��K�K��,� �� ��Y���I�4K�4K�L�H��H��g�-��$�$�0��$�$�6�6��$�$�6�6� �&�'��I� ��'�?�C��.�.���C�L�E��(�(��W�W�Y�2�2�5�9�:��F�������$���*�*��W�W�Y�2�2�5�9�:��F�������$���U�������u�B�u�g�.�/�#� ���T�Y�Y�y�)�H�=r!c��� |j� |j|�y d}|jd�}|�|jd�}|�|jd�}|�t|d�r|j�}|�*t|d�r|j|j||�y|j||�y#ttf$r�t$rtjdd��YywxYw#ttf$r�t$r[} |jd ||d ��n:#ttf$r�t$rtjdd��YnwxYwYd}~yYd}~yd}~wwxYw)Nz&Exception in default exception handlerTr^rror�get_context�runz$Unhandled error in exception handler)rSrgr zeException in default exception handler while handling an unexpected error in custom exception handler)r�r�rhrir-rrGr�r*r�r�)r�r �ctx�thingrms rrZz$BaseEventLoop.call_exception_handler+sv�� �*�"�"�*� ,��.�.�w�7�$ 0������F�+���=�$�K�K��1�E��=�#�K�K��1�E��$��� �)F��+�+�-�C��?�w�s�E�':��G�G�D�3�3�T�7�C��+�+�D�'�:��3� 1�2� �� � ,����E�&*�,� ,��0� 1�2� �� � 0�0��2�2�#I�%(�#*�4��� #�$5�6���$�0��L�L�"?�+/�0�0��0��� 0�sM�B8�BC-�%C-�8/C*�)C*�-E �D�E�/E�E� E�E�E c�V� |js|jj|�yyrP)� _cancelledr�rB�r�rs r� _add_callbackzBaseEventLoop._add_callbackss%��%�� � ��K�K���v�&�!r!c�H� |j|�|j�yrP)r�r;r�s r�_add_callback_signalsafez&BaseEventLoop._add_callback_signalsafexs��D����6�"����r!c�J� |jr|xjdz c_yyrq)r�r�r�s r�_timer_handle_cancelledz%BaseEventLoop._timer_handle_cancelled}s$��A�����'�'�1�,�'�r!c�d� t|j�}|tkDrr|j|ztkDr\g}|jD]'}|j rd|_�|j |��)tj|�||_d|_n�|jrz|jdj ra|xjdzc_tj|j�}d|_|jr|jdj r�ad}|js|jrd}nP|jrD|jdj}ttd||j�z �t �}|j"j%|�}|j'|�d}|j�|j(z}|jrm|jd}|j|k\rnNtj|j�}d|_|jj |�|jr�mt|j�}t+|�D]�} |jj-�}|j r�*|j.rr ||_|j�} |j3�|j�| z }||j4k\r t7j8dt;|�|�d|_��|j3���d}y#d|_wxYw)NFrrzExecuting %s took %.3f seconds)rUr��_MIN_SCHEDULED_TIMER_HANDLESr��%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr�rBr��heapify�heappopr�r��_whenr��maxr��MAXIMUM_SELECT_TIMEOUT� _selector�selectr>r��range�popleftr|r��_runr�rrfr )r��sched_count� new_scheduledrrjr�r=�end_time�ntodo�ir�r�s rr�zBaseEventLoop._run_once�s��� ��$�/�/�*���6�6��'�'�+�5�5� 6��M��/�/���$�$�(-�F�%�!�(�(��0� *� �M�M�-�(�+�D�O�*+�D�'��/�/�d�o�o�a�&8�&C�&C��+�+�q�0�+����t���7��$)��!��/�/�d�o�o�a�&8�&C�&C� ���;�;�$�.�.��G� �_�_��?�?�1�%�+�+�D��#�a��� � ��!3�4�6L�M�G��^�^�*�*�7�3� ����Z�(�� ��9�9�;��!7�!7�7���o�o��_�_�Q�'�F��|�|�x�'���]�]�4�?�?�3�F� %�F���K�K���v�&� �o�o��D�K�K� ���u��A��[�[�(�(�*�F�� � ���{�{� 0�+1�D�(�����B��K�K�M�����r�)�B��T�8�8�8����'G�'5�f�'=�r�C�,0�D�(���� �!�"���,0�D�(�s � A)L&�& L/c� �t|�t|j�k(ry|rDtj�|_tj tj�||_ytj |j�||_yrP)rr�r}�#get_coroutine_origin_tracking_depthr��#set_coroutine_origin_tracking_depthr�DEBUG_STACK_DEPTH�r��enableds rr{z,BaseEventLoop._set_coroutine_origin_tracking�sw����=�D��!H�!H�I�I����7�7�9� �7��3�3��+�+� -�3:��/� �3�3��;�;� =�3:��/r!c��|jSrP)r|r�s rrzBaseEventLoop.get_debug�s���{�{�r!c�l�||_|j�r|j|j|�yyrP)r|rrDr{r�s rr�zBaseEventLoop.set_debug�s.������?�?���%�%�d�&I�&I�7�S�r!rP)NNNr<)r)rN)FNN)Ur�r�r�r�r�r�rrrr r'r*r.r0r9r;r>rrArHrPr_rqrhrwr�r�rkr�rrLrMr�rr�r�r�r�r�r�r�rDr�r�r�r�r�r�r�r�r�r�rrr%r#r$r2rVr+r:rrYr?� AI_PASSIVErqrsrwrzr}r#r$r�r�r�r�r�rZr�r�r�r�r{rr�rQr!rrr�s��/�< �)�)-�d��4%�"�"�%)�$�"�9=�"� �$��t�"&�!%�!%� "�CG�"� @D�(,�"� AE�)-�"�04�"�"�"�7�D�G� "��2�0D�K�4�0$�L�*�.�%�M�M��-� �:>��06:��$26��&%��(�"=A� �5� *� �2"#��!�1�H�7� A�(,� A�.�/�4�*).�X59�Q#����1�4��T�"&�!%�!%�$��Q#�j*/�"&�!%� #�8-<�#'�-<�^1�"�4%*�(,�.2�-1� .+�bEI�D#�./�q��26�7;�$� D#�N'(�f�.@�.@�%&�a� D��59�K��#�#��#�#������"&�!%��K�^�"&�!%� #�<#� #� %�&0�_�_�&0�o�o�&0�o�o�27�%)�1�(,�T�� "#�J%/�O�O�J�O�O�%/�_�_��$)�1�'+�D�t� #�D'� *�"0>�dF0�P'� � -� N�` :��Tr!r)rr)r)6rU�collections.abc�concurrent.futuresr�r�r�rZrCr+rAr#rfr�r�r}rLr�ru�ImportErrorr5rrrrrr r rrr rr�logr�__all__r�r�r*rAr�r r'r2rMrdrnrrrw�Protocolry�AbstractServerr�AbstractEventLooprrQr!r�<module>r�s-�� ������� � ������ ������������������$�� #��),�%� �F�J�'� �#����J�8�v�,"��6�=�!�G� �>� A)� � 2� 2�A)�HB�V� "� "�B�JPT�F�,�,�PT��k�� �C��s�D � D�D__pycache__/base_events.cpython-312.pyc000064400000251334151706172560013777 0ustar00� T��h�2��6�dZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlZddlZddl Z ddlZddlZddlZddlZ ddlZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZddlmZddlmZdd lmZddlmZddlm 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!ejb�Z2Gd"�d#ejf�Z4Gd$�d%ejj�Z6y#e$rdZY��wxYw)(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)�timeouts)� 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 �,/usr/lib64/python3.12/asyncio/base_events.py�_format_handler Gs=�� � � �B��'�"�j�$�/����<��B�K�K� � ��6�{��c�h�|tjk(ry|tjk(ryt|�S)Nz<pipe>z<stdout>)� subprocess�PIPE�STDOUTr)�fds r�_format_piper'Ps+�� �Z�_�_��� �z� � � ���B�x�r!c���ttd�std�� |jtjtj d�y#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_reuseportr2Ys`���6�>�*��D�E�E� J��O�O�F�-�-�v�/B�/B�A�F��� J��I�J� J� J�s�/A � A"c �P�ttd�sy|dtjtjhvs|�y|tjk(rtj}n%|tj k(rtj}ny|�d}n<t |t�r|dk(rd}n$t |t�r|dk(rd}n t|�}|tjk(r7tjg}tr#|jtj �n|g}t |t�r|j#d�}d|vry|D]I} tj$||�tr |tj k(r |||d||||ffcS|||d||ffcSy#ttf$rYywxYw#t&$rY�mwxYw)N� inet_ptonrr!��idna�%)r*r+�IPPROTO_TCP�IPPROTO_UDP�SOCK_STREAM� SOCK_DGRAMr�bytesr�int� TypeErrorr,� AF_UNSPEC�AF_INET� _HAS_IPv6�appendr�decoder4r/) �host�port�family�type�proto�flowinfo�scopeid�afs�afs r�_ipaddr_inforMds����6�;�'���Q��*�*�F�,>�,>�?�?��L���v�!�!�!��"�"�� ��"�"� "��"�"����|��� �D�%� �T�S�[��� �D�#� �4�2�:��� ��t�9�D���!�!�!��~�~�����J�J�v���'��h���$����{�{�6�"�� �d�{���� ����R��&��R�6�?�?�2��4���T�4��7�,K�K�K��4���T�4�L�8�8����;�:�&� �� ��2� �� �s*�7F�;9F�7F�F�F� F%�$F%c��tj�}|D]$}|d}||vrg||<||j|��&t|j ��}g}|dkDr%|j|dd|dz �|dd|dz �=|jd�tjjt j|��D��|S)z-Interleave list of addrinfo tuples by family.rrNc3�$K�|]}|�|��� y�w�N�)�.0�as r� <genexpr>z(_interleave_addrinfos.<locals>.<genexpr>�s!����� �a� �]� � �s�) �collections�OrderedDictrB�list�values�extend� itertools�chain� from_iterable�zip_longest)� addrinfos�first_address_family_count�addrinfos_by_family�addrrF�addrinfos_lists� reordereds r�_interleave_addrinfosrd�s���&�1�1�3�����a����,�,�*,���'��F�#�*�*�4�0� � �.�5�5�7�8�O��I�!�A�%������+�,K�-G�!�-K�L�M��A��>� :�Q� >�>�?� �����?�?�0�0��!�!�?�3� ����r!c��|j�s'|j�}t|ttf�rytj|�j�yrP)� cancelled� exceptionr� SystemExit�KeyboardInterruptr� _get_loop�stop)�fut�excs r�_run_until_complete_cbrn�sB���=�=�?��m�m�o���c�J�(9�:�;� ����c����!r!�TCP_NODELAYc�4�|jtjtjhvrl|jtj k(rN|jtjk(r0|jtjtjd�yyyy�Nr) rFr+r@rrGr:rHr8r-ror0s r�_set_nodelayrr�sj���K�K�F�N�N�F�O�O�<�<�� � �V�/�/�/�� � �f�0�0�0��O�O�F�.�.��0B�0B�A�F�1�0� =r!c��yrPrQr0s rrrrr�s��r!c�\�t�&t|tj�rtd��yy)Nz"Socket cannot be of type SSLSocket)�sslr� SSLSocketr>r0s r�_check_ssl_socketrw�s'�� ��:�d�C�M�M�:��<�=�=�;�r!c�B�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zy )�_SendfileFallbackProtocolc��t|tj�std��||_|j�|_|j�|_|j|_ |j�|j|�|jr*|jjj�|_yd|_y)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����&�*�">�">�?��L�M�M� ����)�)�+���&,�&7�&7�&9��#�&,�&=�&=��#��������D�!��&�&�$(�O�O�$9�$9�$G�$G�$I�D�!�$(�D�!r!c��K�|jj�rtd��|j}|�y|�d{���y7��w)NzConnection closed by peer)r|� is_closing�ConnectionErrorr�)r�rls r�drainz_SendfileFallbackProtocol.drain�s<�����?�?�%�%�'�!�"=�>�>��#�#���;��� � �s�:A�A�Ac��td��)Nz?Invalid state: connection should have been established already.��RuntimeError)r�� transports r�connection_madez)_SendfileFallbackProtocol.connection_made�s���N�O� Or!c���|j�B|�%|jjtd��n|jj|�|jj |�y)NzConnection is closed by peer)r�� set_exceptionr�r~�connection_lost)r�rms rr�z)_SendfileFallbackProtocol.connection_lost�s[��� � �,��{��%�%�3�3�#�$B�C�E��%�%�3�3�C�8����#�#�C�(r!c�p�|j�y|jjj�|_yrP)r�r|r�r��r�s r� pause_writingz'_SendfileFallbackProtocol.pause_writing�s,��� � �,�� $��� 5� 5� C� C� E��r!c�b�|j�y|jjd�d|_y)NF)r�� set_resultr�s r�resume_writingz(_SendfileFallbackProtocol.resume_writing�s-��� � �(�����(�(��/� $��r!c��td���Nz'Invalid state: reading should be pausedr�)r��datas r� data_receivedz'_SendfileFallbackProtocol.data_received����D�E�Er!c��td��r�r�r�s r�eof_receivedz&_SendfileFallbackProtocol.eof_receivedr�r!c��<K�|jj|j�|jr|jj �|j �|j j �|jr|jj�yy�wrP) r|r�r~r��resume_readingr��cancelr�r�r�s r�restorez!_SendfileFallbackProtocol.restoress�������$�$�T�[�[�1��&�&��O�O�*�*�,�� � �,� �!�!�(�(�*��&�&��K�K�&�&�(�'�s�BBN)�__name__� __module__�__qualname__r�r�r�r�r�r�r�r�r�rQr!rryry�s3��)��O� )�F� %�F�F� )r!ryc�h�eZdZ dd�Zd�Zd�Zd�Zd�Zd�Zd�Z d �Z ed ��Zd�Z d�Zd �Zd�Zy)rNc��||_||_d|_g|_||_||_||_||_||_d|_ d|_ y)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__sU���� ��� ������ �!1����� �'���&;��#�%9��"��� �$(��!r!c�P�d|jj�d|j�d�S)N�<z sockets=�>)� __class__r�r�r�s r�__repr__zServer.__repr__#s'���4�>�>�*�*�+�9�T�\�\�4D�A�F�Fr!c�J�|j�J�|xjdz c_yrq)r�r�r�s r�_attachzServer._attach&s#���}�}�(�(�(����a��r!c��|jdkDsJ�|xjdzc_|jdk(r|j�|j�yyy)Nrr)r�r��_wakeupr�s r�_detachzServer._detach*sO���!�!�A�%�%�%����a�������"�t�}�}�'<��L�L�N�(=�"r!c�|�|j}d|_|D]$}|j�r�|jd��&yrP)r��doner�)r��waiters�waiters rr�zServer._wakeup0s3���-�-���� ��F��;�;�=��!�!�$�'�r!c �*�|jryd|_|jD]p}|j|j�|jj|j||j||j|j|j��ry)NT) r�r��listenr�r��_start_servingr�r�r�r�)r�r1s rr�zServer._start_serving7sp���=�=���� ��M�M�D��K�K�� � �&��J�J�%�%��&�&��d�.?�.?��d�m�m�T�%@�%@��*�*� ,�"r!c��|jSrP)r�r�s r�get_loopzServer.get_loopBs���z�z�r!c��|jSrP)r�r�s r� is_servingzServer.is_servingEs���}�}�r!c�T�|j�ytd�|jD��S)NrQc3�FK�|]}tj|����y�wrP)r�TransportSocket)rR�ss rrTz!Server.sockets.<locals>.<genexpr>Ls����F� �1�V�+�+�A�.� �s�!)r��tupler�s rr�zServer.socketsHs$���=�=� ���F�� � �F�F�Fr!c�P�|j}|�yd|_|D]}|jj|��d|_|j�;|jj�s!|jj �d|_|jdk(r|j�yy)NFr) r�r�� _stop_servingr�r�r�r�r�r�)r�r�r1s r�closezServer.closeNs����-�-���?���� ��D��J�J�$�$�T�*���� ��%�%�1��-�-�2�2�4��%�%�,�,�.�(,�D�%�����"��L�L�N�#r!c��jK�|j�tjd��d{���y7��w)Nr)r�r�sleepr�s r� start_servingzServer.start_servingas%���������k�k�!�n���s�)3�1�3c��K�|j�td|�d���|j�td|�d���|j�|jj�|_ |j�d{��� d|_y7� #tj$r1 |j�|j��d{���7�#�xYwwxYw#d|_wxYw�w)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���$��!M�N�P� P��=�=� ����� �;�<�<�����$(�J�J�$<�$<�$>��!� -��+�+�+�+�)-�D�%� ,���(�(� � �� � ���&�&�(�(�(����� ��)-�D�%�s`�A&C�)B�8B�9B�>C�B�C�#C�?C�C�C�C�C�C� C�Cc��K�|j�y|jj�}|jj|�|�d{���y7��w)a�Wait until server is closed and all connections are dropped. - If the server is not closed, wait. - If it is closed, but there are still active connections, wait. Anyone waiting here will be unblocked once both conditions (server is closed and all connections have been dropped) have become true, in either order. Historical note: In 3.11 and before, this was broken, returning immediately if the server was already closed, even if there were still active connections. An attempted fix in 3.12.0 was still broken, returning immediately if the server was still open and there were no active connections. Hopefully in 3.12.1 we have it right. N)r�r�r�rB)r�r�s rr�zServer.wait_closed|s@����*�=�=� �����)�)�+��� � ���V�$����s�AA� A�ArP)r�r�r�r�r�r�r�r�r�r�r��propertyr�r�r�r�r�rQr!rrrs[��>B�)�G� ��(� ,����G��G� �&�-�*r!rc��eZdZd�Zd�Zd�Zddd�d�Zd�Zd�Zd\ddd �d �Z d\dddddddd �d�Z d]d�Z d^d�Z d^d�Z d\d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd\d�Zd�Zd�Zd�Zd�Zd�Zd �Zd!�Zej>fd"�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`dd4�d5�Z/d6�Z0d7�Z1d8�Z2d\d9�Z3 d^dd0d0d0ddddddddd:�d;�Z4 dad<�Z5d`dd4�d=�Z6d>�Z7d?�Z8ddddd@�dA�Z9 d^d0d0d0ddddB�dC�Z:d0e;jxd0d0d1�dD�Z=dE�Z> d^e;j~e;j�ddFdddddddG� dH�ZAddddI�dJ�ZBdK�ZCdL�ZDdM�ZEeFj�eFj�eFj�ddd0ddddN� dO�ZHeFj�eFj�eFj�ddd0ddddN� dP�ZIdQ�ZJdR�ZKdS�ZLdT�ZMdU�ZNdV�ZOdW�ZPdX�ZQdY�ZRdZ�ZSd[�ZTy)brc���d|_d|_d|_tj�|_g|_d|_d|_d|_ tjd�j|_ d|_|jt!j"��d|_d|_d|_d|_d|_t/j0�|_d|_d|_y)NrF� monotonicg�������?)�_timer_cancelled_count�_closed� _stoppingrU�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�!4�[�!A�!L�!L���"&������z�0�0�2�3�'*��#�#���!���27��/�6:��3�"�/�/�+���*/��'�).��&r!c ��d|jj�d|j��d|j��d|j ��d� S)Nr�z running=z closed=z debug=r�)r�r�� is_running� is_closed� get_debugr�s rr�zBaseEventLoop.__repr__�sP������'�'�(� �$�/�/�2C�1D�E��n�n�&�'�w�t�~�~�/?�.@�� 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�2�|j�|j�3tj||||��}|jrM|jd=n?|�|j||�}n|j|||��}tj ||� |~S#~wxYw)zDSchedule a coroutine object. Return a task object. )r�rr ����r )� _check_closedr�rr�_source_traceback�_set_task_name)r��cororr �tasks r�create_taskzBaseEventLoop.create_task�s��� �������%��:�:�d��D�'�J�D��%�%��*�*�2�.����)�)�$��5���)�)�$��g�)�F��� � ��t�,� �����s�B�Bc�B�|�t|�std��||_y)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�s%����x��'8��E�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�r1�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�r1r�addressr�rs r�_make_datagram_transportz&BaseEventLoop._make_datagram_transport�r r!c��t�)zCreate read pipe transport.r�r��piperr�rs r�_make_read_pipe_transportz'BaseEventLoop._make_read_pipe_transportr r!c��t�)zCreate write pipe transport.rr,s r�_make_write_pipe_transportz(BaseEventLoop._make_write_pipe_transportr r!c ��K�t��w)zCreate subprocess transport.r) r�r�args�shell�stdin�stdout�stderr�bufsizer�kwargss r�_make_subprocess_transportz(BaseEventLoop._make_subprocess_transports����"�!�s� 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_selfs ��"�!r!c��t�)zProcess selector events.r)r�� event_lists r�_process_eventszBaseEventLoop._process_eventss��!�!r!c�2�|jrtd��y)NzEvent loop is closed)r�r�r�s rr zBaseEventLoop._check_closeds���<�<��5�6�6�r!c�2�|jrtd��y)Nz!Executor shutdown has been called)rr�r�s r�_check_default_executorz%BaseEventLoop._check_default_executor#s���)�)��B�C�C�*r!c��|jj|�|j�s+|j|j|j��yyrP)r��discardr�call_soon_threadsafer�aclose�r��agens r�_asyncgen_finalizer_hookz&BaseEventLoop._asyncgen_finalizer_hook's?��������%��~�~���%�%�d�&6�&6���� �F� r!c��|jr tjd|�d�t|��|jj|�y)Nzasynchronous generator z3 was scheduled after loop.shutdown_asyncgens() call��source)r��warnings�warn�ResourceWarningr��addrFs r�_asyncgen_firstiter_hookz&BaseEventLoop._asyncgen_firstiter_hook,sA���*�*��M�M�)�$��21�2��� .� �����D�!r!c��K�d|_t|j�syt|j�}|jj �tj|D�cgc]}|j���c}ddi��d{���}t||�D].\}}t|t�s�|jd|��||d���0ycc}w7�G�w)z,Shutdown all active asynchronous generators.TN�return_exceptionsz;an error occurred during closing of asynchronous generator )�messagerg�asyncgen)r��lenr�rW�clearr�gatherrE�zipr� Exception�call_exception_handler)r�� closing_agens�ag�results�resultrGs r�shutdown_asyncgensz BaseEventLoop.shutdown_asyncgens5s�����*.��'��4�?�?�#� ��T�_�_�-� ����������$1� 2�M�b�b�i�i�k�M� 2�$�"�$�$�� ���7�L�F�D��&�)�,��+�+�"9�9=�� B�!'� $� -��8��3�$�s$�A C �"C�9 C �C�&C �+!C c��K�d|_|j�y|j�}tj|j |f��}|j � tj|�4�d{���|�d{���ddd��d{���|j�y7�/7�'7�#1�d{���7swY�)xYw#t$r?tjd|�d�td��|jjd� �YywxYw�w) aSchedule the shutdown of the default executor. The timeout parameter specifies the amount of time the executor will be given to finish joining. The default value is None, which means that the executor will be given an unlimited amount of time. TN)�targetr2z:The executor did not finishing joining its threads within z seconds.�)� stacklevelF��wait)rr�r�� threading�Thread�_do_shutdown�startr �timeout�join�TimeoutErrorrLrM�RuntimeWarning�shutdown)r�rj�future�threads r�shutdown_default_executorz'BaseEventLoop.shutdown_default_executorNs�����*.��&��!�!�)���#�#�%���!�!��):�):�&��K������ ��'�'��0�0����1�0� �K�K�M�1����1��0�0�0��� 8��M�M�0�07�y� �C�(�Q� 8� �"�"�+�+��+�7� 8�s��AD �B>�3B#�4B>�7B)�=B%�>B)�B>� B'�B>�D �#B>�%B)�'B>�)B;�/B2�0B;�7B>�>AD�D �D�D c�Z� |jjd��|j�s"|jtj |d�yy#t$rP}|j�s6|j�s!|j|j|�Yd}~yYd}~yYd}~yd}~wwxYw)NTrd) r�rnrrDr�_set_result_unless_cancelledrYrfr�)r�ro�exs rrhzBaseEventLoop._do_shutdownfs��� D��"�"�+�+��+�6��>�>�#��)�)�'�*N�*N�*0�$�8�$��� D��>�>�#�F�,<�,<�,>��)�)�&�*>�*>��C�C�-?�#�� D�s�A A� B*�<B%�%B*c�x�|j�rtd��tj��td��y)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_runningps>���?�?���C�D�D��#�#�%�1��I�K� K�2r!c��|j�|j�|j|j�t j �} t j�|_t j|j|j��tj|� |j�|jrn� d|_d|_tjd�|jd�t j|�y#d|_d|_tjd�|jd�t j|�wxYw)zRun until stop() is called.)� firstiter� finalizerFN)r rw�_set_coroutine_origin_tracking�_debug�sys�get_asyncgen_hooksrf� get_identr��set_asyncgen_hooksrPrHr�_set_running_loop� _run_oncer�)r��old_agen_hookss r�run_foreverzBaseEventLoop.run_foreverws�����������+�+�D�K�K�8��/�/�1�� 4�'�1�1�3�D�O��"�"�T�-J�-J�-1�-J�-J� L� �$�$�T�*����� ��>�>����"�D�N�"�D�O��$�$�T�*��/�/��6��"�"�N�3�� #�D�N�"�D�O��$�$�T�*��/�/��6��"�"�N�3�s�A8D�AEc� �|j�|j�tj|�}t j ||��}|rd|_|jt� |j� |jt�|j�std��|j�S#|r0|j�r |j�s|j��xYw#|jt�wxYw)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 rwr�isfuturer� ensure_future�_log_destroy_pending�add_done_callbackrnr�r�rfrg�remove_done_callbackr�r^)r�ro�new_tasks r�run_until_completez BaseEventLoop.run_until_complete�s��� ���������'�'��/�/���$�$�V�$�7���+0�F�'�� � �!7�8� @����� �'�'�(>�?��{�{�}��L�M�M��}�}���� ��F�K�K�M�&�2B�2B�2D�� � �"����'�'�(>�?�s�-B>�>5C3�3C6�6D c��d|_y)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 rrkzBaseEventLoop.stop�s����r!c�l�|j�rtd��|jry|jrt j d|�d|_|jj�|jj�d|_ |j}|�d|_ |jd��yy)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 %rTFrd)rr�r�r|r�debugr�rVr�rr�rn�r��executors rr�zBaseEventLoop.close�s����?�?���B�C�C��<�<���;�;��L�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��|j�s4|d|��t|��|j�s|j�yyy)Nzunclosed event loop rJ)rrNrr�)r��_warns r�__del__zBaseEventLoop.__del__�s=���~�~���(���1�?�4�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|j�|z|g|��d|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. zdelay must not be Noner r)r>�call_atr�r)r��delay�callbackr r2�timers r� call_laterzBaseEventLoop.call_later�s_�� �=��4�5�5�����T�Y�Y�[�5�0�(�.�T�.�%,�.���"�"��'�'��+��r!c�N�|�td��|j�|jr"|j�|j |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. zwhen cannot be Noner�rT)r>r r|� _check_thread�_check_callbackr�TimerHandler�heapq�heappushr�)r��whenr�r r2r�s rr�zBaseEventLoop.call_ats��� �<��1�2�2������;�;���� �� � ��9�5��"�"�4��4��w�G���"�"��'�'��+� ���t����.�����r!c���|j�|jr"|j�|j|d�|j |||�}|j r |j d=|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 r|r�r�� _call_soonr�r�r�r r2rs rr�zBaseEventLoop.call_soonsa�� �����;�;���� �� � ��;�7�����4��9���#�#��(�(��,�� r!c��tj|�stj|�rtd|�d���t |�std|�d|����y)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_callback(sg���"�"�8�,��.�.�x�8��1�&���<�>� >���!��4�V�H�=��l�$�%� %�"r!c��tj||||�}|jr |jd=|jj |�|S)Nr)r�Handlerr�rB)r�r�r2r rs rr�zBaseEventLoop._call_soon2sD�����x��t�W�=���#�#��(�(��,������6�"�� r!c�z�|j�ytj�}||jk7rtd��y)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�rfrr�)r�� thread_ids rr�zBaseEventLoop._check_thread9sB���?�?�"���'�'�)� �����'��'�(� (�(r!c���|j�|jr|j|d�|j|||�}|jr |jd=|j�|S)z"Like call_soon(), but thread-safe.rDr)r r|r�r�rr;r�s rrDz"BaseEventLoop.call_soon_threadsafeJs`�������;�;�� � ��+A�B�����4��9���#�#��(�(��,������ r!c�<�|j�|jr|j|d�|�E|j}|j �|�'t jjd��}||_t j|j|g|���|��S)N�run_in_executor�asyncio)�thread_name_prefixr) r r|r�r�rA� concurrentr�ThreadPoolExecutor�wrap_future�submit)r�r��funcr2s rr�zBaseEventLoop.run_in_executorUs��������;�;�� � ��'8�9����-�-�H��(�(�*���%�-�-�@�@�'0�A���*2��&��"�"��H�O�O�D�(�4�(�t�5� 5r!c�p�t|tjj�st d��||_y)Nz,executor must be ThreadPoolExecutor instance)rr�rr�r>r�r�s r�set_default_executorz"BaseEventLoop.set_default_executores,���(�J�$6�$6�$I�$I�J��J�K�K�!)��r!c�"�|�d|��g}|r|jd|���|r|jd|���|r|jd|���|r|jd|���dj|�}tjd|�|j �}tj||||||�} |j �|z } d|�d | d zd�d| ��}| |jk\rtj|�| Stj|�| S) N�:zfamily=ztype=zproto=zflags=�, zGet address info %szGetting address info z took g@�@z.3fzms: ) rBrkrr�r�r+�getaddrinfor��info)r�rDrErFrGrH�flags�msg�t0�addrinfo�dts r�_getaddrinfo_debugz BaseEventLoop._getaddrinfo_debugjs����q���!�"����J�J��� �+�,���J�J��t�h�'�(���J�J���y�)�*���J�J���y�)�*��i�i��n�����*�C�0� �Y�Y�[���%�%�d�D�&�$��u�M�� �Y�Y�[�2� ��%�c�U�&��c��#��d�8�,�O�� ��,�,�,��K�K����� �L�L����r!r�rFrGrHr�c ��K�|jr |j}ntj}|j d|||||||��d{���S7��wrP)r|r�r+r�r�)r�rDrErFrGrHr��getaddr_funcs rr�zBaseEventLoop.getaddrinfo�sU�����;�;��2�2�L�!�-�-�L��)�)��,��d�F�D�%��H�H� H�H�s�AA�A�Ac��bK�|jdtj||��d{���S7��wrP)r�r+�getnameinfo)r��sockaddrr�s rr�zBaseEventLoop.getnameinfo�s2�����)�)��&�$�$�h��7�7� 7�7�s�&/�-�/)�fallbackc��ZK�|jr|j�dk7rtd��t|�|j ||||� |j||||��d{���S7�#tj$r }|s�Yd}~nd}~wwxYw|j||||��d{���7S�w)Nrzthe socket must be non-blocking) r|� gettimeoutr,rw�_check_sendfile_params�_sock_sendfile_nativer�SendfileNotAvailableError�_sock_sendfile_fallback)r�r1�file�offset�countr�rms r� sock_sendfilezBaseEventLoop.sock_sendfile�s������;�;�4�?�?�,��1��>�?�?��$���#�#�D�$���>� ��3�3�D�$�4:�E�C�C� C�C���3�3� ����� ���1�1�$��28�%�A�A�A� A�sN�A B+� A+�$A)�%A+�(B+�)A+�+B�>B�B+�B�B+�%B(�&B+c��BK�tjd|�d|�d����w)Nz-syscall sendfile is not available for socket z and file z combination�rr��r�r1r�r�r�s rr�z#BaseEventLoop._sock_sendfile_native�s4�����2�2�;�D�8�D��x�|� -�.� .�s�c��8K�|r|j|�|rt|tj�ntj}t |�}d} |rt||z |�}|dkrnYt|�d|}|j d|j|��d{���} | sn#|j||d| ��d{���|| z }�p||dkDr"t|d�r|j||z�SSS7�S7�5#|dkDr"t|d�r|j||z�wwwxYw�w)Nr�seek) r��minr�!SENDFILE_FALLBACK_READBUFFER_SIZE� bytearray� memoryviewr��readinto�sock_sendallr*) r�r1r�r�r�� blocksize�buf� total_sent�view�reads rr�z%BaseEventLoop._sock_sendfile_fallback�s1������I�I�f��� ��y�B�B�C�#�E�E� �� �"��� � /��� #�E�J�$6� � B�I� �A�~��!�#��z� �2��!�1�1�$�� � �t�L�L�����'�'��d�5�D�k�:�:�:��d�"� ����A�~�'�$��"7�� � �&�:�-�.�#8�~�M��;���A�~�'�$��"7�� � �&�:�-�.�#8�~�sC�A D�AC.�C*�C.�6C,�7C.�(D�*C.�,C.�.)D�Dc��dt|dd�vrtd��|jtjk(std��|�It|t�stdj|���|dkrtdj|���t|t�stdj|���|dkrtdj|���y)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,rGr+r:rr=r>�formatr�s rr�z$BaseEventLoop._check_sendfile_params�s����g�d�F�C�0�0��C�D�D��y�y�F�.�.�.��J�K�K����e�S�)��A�H�H��O�Q�Q���z� �A�H�H��O�Q�Q��&�#�&��B�I�I���� ��A�:��B�I�I���� �r!c���K�g}|j|�|\}}}}} d} tj|||��} | jd�|�G|D]!\}}}}}||k7r� | j|�n"|r|j��t d|�d���|j| | ��d{���| dx}}S#t$rP} d|�dt| �j ���}t | j|�} |j| �Yd} ~ ��d} ~ wwxYw7�f#t$r)} |j| �| �| j��d} ~ w| �| j��xYw#dx}}wxYw�w)z$Create, bind and connect one socket.N�rFrGrHF�*error while attempting to bind on address �: z&no matching local address with family=z found)rBr+�setblocking�bindr/r�lower�errno�pop�sock_connectr�)r�r� addr_info�local_addr_infos� my_exceptionsrF�type_rH�_r)r1�lfamily�laddrrmr�s r� _connect_sockzBaseEventLoop._connect_sock�s������ �� ���-�(�+4�(���u�a����# .��=�=��U�%�H�D����U�#��+�/?�+�G�Q��1�e��&�(� � 2�� � �%�(�� 0@�%�+�/�/�1�1�%�(O��y�PV�&W�X�X��#�#�D�'�2�2�2��*.�-�J���1#�2�'�',�i�r�#�c�(�.�.�2B�1C�E��&�c�i�i��5��%�,�,�S�1�1�� 2�� 3��� �� � ��%���� � ���� ���� � ����)-�-�J��sk�E#�<D�B4�09D�)D�*D�/E#�4 D �=AD�D�D � D� E�$D?�?E�E�E � E#)rurFrHr�r1� local_addrr"r�r��happy_eyeballs_delay� interleave� all_errorsc��B����K�| � |std��| �|r|std��|} |� |std��|� |std��|�t|�| �|�d}|�|���|�td���j||f|tj||����d{���}|std ��| �:�j| |tj||����d{�����s td ��d�|rt ||�}g�| �%|D]} �j�|���d{���}n0n.tj���fd �|D�| ����d{���d}|�ʉD��cgc]}|D]}|��� c}}� |rtd ���t��dk(r�d�t�d��t�fd��D��r�d�tdjdjd��D�����|�td��|j tjk7rtd|�����j#|||| ||���d{���\}}�j$r+|j'd�}t)j*d|||||�||fS7���7���7��f#t $rY���wxYw7��Jcc}}w#d�wxYw7�k�w)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�rFrGrHr�r��!getaddrinfo() returned empty listc3�0�K�|] }|f���fd� ���y�w)c�*���j�|��SrP)r�)r�r�laddr_infosr�s ���r�<lambda>z;BaseEventLoop.create_connection.<locals>.<genexpr>.<lambda>]s���$�2D�2D�&��+�3r!NrQ)rRr�rrr�s ���rrTz2BaseEventLoop.create_connection.<locals>.<genexpr>Zs'������).�H�)1���).�s�rrzcreate_connection failedc3�:�K�|]}t|��k(���y�wrP�r)rRrm�models �rrTz2BaseEventLoop.create_connection.<locals>.<genexpr>ps�����G�J�S�s�3�x�5�0�J�s�zMultiple exceptions: {}r�c3�2K�|]}t|����y�wrPr)rRrms rrTz2BaseEventLoop.create_connection.<locals>.<genexpr>us����%E�*�3�c�#�h�*�s�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,rw�_ensure_resolvedr+r:r/rdr�r�staggered_race�ExceptionGrouprUr�allr�rkrG�_create_connection_transportr|�get_extra_inforr�)r�r�rDrErurFrHr�r1r�r"r�r�rrr�infosr��subrmr�rrrrs` @@@r�create_connectionzBaseEventLoop.create_connectionsq�����(�&�s��J�K�K��"�s�� �"A�B�B�"�O� �,�S��C�E� E� �+�C��B�D� D����d�#��+� �0B��J���t�/��� �N�P�P��/�/��t��V��'�'�u�E��0�N�N�E���A�B�B��%�$(�$9�$9��v��+�+�5��d�%:�%,�,��#�!�"E�F�F�"���-�e�Z�@���J�#�+� %�H�!�%)�%7�%7�&��+�&?� ?��� !&�(�6�6��).� �)��������|�-7�G�Z�c�3�C�c�3�c�Z�G� �&�!�,�-G��T�T��:��!�+�(��m�+�!$�J�q�M� 2���G�J�G�G�",�Q�-�/�&�&?�&F�&F� �I�I�%E�*�%E�E�'G�H�H��|� �K�M�M��y�y�F�.�.�.�!�8���A�C�C�%)�$E�$E��"�C��"7�!5�%F�%7�7�� �8��;�;��+�+�H�5�D��L�L�:��t�T�9�h� @��(�"�"�mN��,��" ?��#�!� �!����H�� "&�J�� 7�s��BJ�I4�;J�I7�*J�>I=�I:�I=�*J�J �J�J�"J�'A8J�AJ�1J�2AJ�7J�:I=�= J �J� J � J�J�J�Jc ��.K�|jd�|�}|j�} |r.t|t�rdn|} |j ||| | ||||��}n|j||| �} | �d{���||fS7�#|j ��xYw�w)NF�r!r"r�r�)r�r�r�boolr'rr�)r�r1r�rur"r!r�r�rr�r&r�s rrz*BaseEventLoop._create_connection_transport�s����� �����#�%���#�#�%���!+�C��!6��C�J��0�0��h� �F�'��&;�%9� 1�;�I��3�3�D�(�F�K�I� ��L�L� �(�"�"� �� ��O�O���s0�A,B�/A?�4A=�5A?�9B�=A?�?B�Bc��K�|j�rtd��t|dtjj �}|tjj urtd|����|tjjur |j||||��d{���S|std|����|j||||��d{���S7�0#tj$r }|s�Yd}~�Id}~wwxYw7�)�w)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�rms r�sendfilezBaseEventLoop.sendfile�s����0���!��5�6�6��y�"8� �.�.�:�:�<���9�*�*�6�6�6��:�9�-�H�J� J��9�*�*�5�5�5� �!�2�2�9�d�39�5�B�B�B���+�+4�-�9�:� :��,�,�Y��-3�U�<�<� <�B���7�7� ��� �� ��<�sN�BC9� C�!C�"C�%(C9� C7�C9�C�C4�'C/�*C9�/C4�4C9c��4K�tjd���w)Nz!sendfile syscall is not supportedr�)r�r�r�r�r�s rr#zBaseEventLoop._sendfile_native�s�����2�2�/�1� 1�s�c��K�|r|j|�|rt|d�nd}t|�}d}t|�} |rSt||z |�}|dkr?||dkDr t |d�r|j||z�|j��d{���St |�d|} |jd|j| ��d{���} | s?||dkDr t |d�r|j||z�|j��d{���S|j| d| �|j��d{���|| z }��7��7�y7�;7�#|dkDr t |d�r|j||z�|j��d{���7wxYw�w)Ni@rr�)r�r�r�ryr*r�r�r�r��writer�)r�r�r�r�r�r�r�r�rHr�r�s rr$z BaseEventLoop._sendfile_fallback�sx������I�I�f��).�C��u�%�E� �� �"��� �)�&�1�� "��� #�E�J�$6� � B�I� �A�~�)��A�~�'�$��"7�� � �&�:�-�.��-�-�/�!�!�"�#��z� �2��!�1�1�$�� � �t�L�L���%� �A�~�'�$��"7�� � �&�:�-�.��-�-�/�!�!� ���T�%�4�[�)��k�k�m�#�#��d�"� �� "��M�� "��$���A�~�'�$��"7�� � �&�:�-�.��-�-�/�!�!�s��<F�E�8F�D;�F�.E�D=�E�8F�D?�F� 'E�0E�1 E�;F�=E�?F�E�9F�<E?�=F�Frc��nK�t�td��t|tj�st d|����t|dd�st d|�d���|j �}tj||||||||d�� } |j�|j| �|j| j|�} |j|j�} |�d{���| j"S7�#t$r2|j�| j!�|j!��wxYw�w) 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#)rur�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��*�c�n�n�5���!�n�&�'� '��y�"9�5�A���Y�M�)I�J�L� L��#�#�%���+�+��(�J����"7�!5�!&�(�� ���!����|�,��^�^�L�$@�$@�)�L� ��N�N�9�#;�#;�<� � ��L�L��*�*�*� ��� ��O�O����������� �s0�CD5�C7�$C5�%C7�)D5�5C7�7;D2�2D5)rFrHr�� reuse_port�allow_broadcastr1c ��DK�| ��| jtjk(rtd| ����|s|s |s|s|s|s|rGt |||||||��} djd�| j �D��}td|�d���| jd�d}�nb|s|s|d k(rtd ��||fdff} �n�ttd�r�|tjk(r�||fD] }|��t|t�r�td ��|rO|d dvrH tjtj|�j �rtj"|�||f||fff} n�i}d |fd|ffD]�\}}|�� t|t,�rt/|�dk(std��|j1||tj2|||���d{���}|st'd��|D]\}}}}}||f}||vrddg||<||||<�!��|j �D��cgc]\}}|r|d �|r|d�||f��} }}| std��g}| D]�\\}}\}}d} d} tj|tj2|��} |rt5| �|r/| j7tj8tj:d�| jd�|r| j=|�|r|s|j?| |��d{���|}n|d �|�}|jE�}|jG| |||�}|jHr4|rt)jJd||||�nt)jLd|||� |�d{���||fS#t$$rY��0t&$r"}t)j*d||�Yd}~��Ud}~wwxYw7���cc}}w7��#t&$r/}| �| jA�|jB|�Yd}~���d}~w| �| jA��xYw7��#|jA��xYw�w)zCreate datagram connection.Nz$A datagram socket was expected, got )r��remote_addrrFrHr�r3r4r�c3�6K�|]\}}|s� |�d|�����y�w)�=NrQ)rR�k�vs rrTz9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>=s!����$N�L�D�A�q�A��s�!�A�3�Z�L�s� �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: %rrrbz2-tuple is expectedrrzcan not get address informationr�z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))'rGr+r:r,�dictrk�itemsr�r*r=rrr>�stat�S_ISSOCK�os�st_mode�remove�FileNotFoundErrorr/r�errorr�rUrr;r2r-r.�SO_BROADCASTr�r�r�rBr�r*r|r�r�) r�r�r�r6rFrHr�r3r4r1�opts�problems�r_addr�addr_pairs_infora�err� addr_infos�idxr�famr��pror)�key� addr_pairr� local_address�remote_addressrmrr�r�s r�create_datagram_endpointz&BaseEventLoop.create_datagram_endpoint+s��������y�y�F�.�.�.� �:�4�(�C�E�E��k��e�u��/��z�{�#)��e�'1�,;�=�� �9�9�$N�D�J�J�L�$N�N�� �0�08�z��<�=�=� ���U�#��F��+��Q�;�$�%@�A�A�%+�U�O�\�#B�"D�����+��&�.�.�0H�'��5�D��'� �4��0E�'�(<�=�=�6��*�Q�-�{�"B� 6��=�=�����)<�)D�)D�E��I�I�j�1�&,�U�O�%/��$=�$?�#B�� � �#$�j�/�A�{�3C�!D�I�C���'� *�4�� 7�C��I��N�"+�,A�"B�B�&*�&;�&;� ��f�6G�6G�"'�u�4�'<�'A�!A�� %�")�*M�"N�N�7<�3�C��C��G�#&��*�C�"�*�4�37��,� �3��3:�J�s�O�C�0� 8=�"E�&<F�;K�;K�;M�#E�;M���i�'�I�a�L�,@�(�Y�q�\�-A��)�$�;M� �#E� '�$�%F�G�G��J�6E�2��&�%�0�-�������!�=�=�%�F�,=�,=�U�L�D�!�&�t�,�&����"�-�-�v�/B�/B�A�G��$�$�U�+�!�� � �-�0�"�.�"&�"3�"3�D�.�"I�I�I�!/���96E�<!��m�#�#�%���#�#�%���1�1��(�F�F�,� ��;�;�����0�&��Y��J����(�(�)�X�?� ��L�L� �(�"�"��}-���"�6����&5�%/��6�6��6�� !A��#E�8J���+��'�� � ��%�J�%�%�c�*�*����'�� � ����* �� ��O�O���s��C!P �$P �5P �AM6�P �/AP �N/�A P �N2�'$P �B!N:�-N8�.N:�4A3P �(P �-P�.P �2P �6 N,�?P �N,� N'�!P �'N,�,P �2P �8N:�: P�$O-�'P �-P�P �P � P�P c��K�|dd\}}t|||||g|dd���} | �| gS|j||||||���d{���S7��w)Nrbr�)rMr�) r�r)rFrGrHr�r�rDrEr�s rrzBaseEventLoop._ensure_resolved�st�����R�a�[� ��d��D�$���e�J�g�a�b�k�J�����6�M��)�)�$��V�$�05�U�*�D�D� D�D�s�;A�A�Ac��K�|j||f|tj||���d{���}|std|�d���|S7��w)N)rFrGr�r�zgetaddrinfo(z) returned empty list)rr+r:r/)r�rDrErFr�rs r�_create_server_getaddrinfoz(BaseEventLoop._create_server_getaddrinfo�s]�����+�+�T�4�L��17�1C�1C�27�d�,�D�D����L���0E�F�G�G���D�s�*A�A�Ar) rFr�r1r�ru� reuse_addressr3r�r�r�c ��K�t|t�rtd��|� |�td��|� |�td��|�t |�|�|��"|�td��| �(t jdk(xrtjdk7} g}|dk(rdg}n:t|t�s$t|tjj�s|g}n|}|D�cgc]}|j||||� ���}}tj|��d{���}t!t"j$j'|��}d } |D]�}|\}}}}} t)j(|||�}|j3|�| r/|j5t(j6t(j8d�| r-|t(j:t(j<fvrt?|�t@rR|t(j<k(r?tCt(d�r/|j5t(jDt(jFd� |jI|���|stKd|D�cgc]}|d�� c}����d}|sS|D]}|jU��n;|�td��|jVt(jXk7rtd|����|g}|D]}|j[d ��t]|||||||�}| r-|j_�tj`d��d{���|j,rt/jbd|�|Scc}w7��+#t(j*$r*|j,rt/j0d|||d� �Y��8wxYw#tJ$r�}d|�dt|�jM���}|jNtNjPk(rG|jS�|jU�|j,rt/j0|�Yd}~���tK|jN|�d�d}~wwxYwcc}w#|s|D]}|jU��wwxYw7��@�w)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 NoneNrrr�posix�cygwinr5)rFr�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 �z)Neither host/port nor sock were specifiedrrz %r is serving)2rrr>r,rwrCrr}�platformrrU�abc�IterablerYrrW�setrZr[r\r+rGr|r�warningrBr-r.�SO_REUSEADDRr@rr2rAr*r`�IPV6_V6ONLYr�r/r�r�� EADDRNOTAVAILr�r�rGr:r�rr�r�r�)r�r�rDrErFr�r1r�rurZr3r�r�r�r��hosts�fsr� completed�resrL�socktyperH� canonname�sarMr�r�rs r� create_serverzBaseEventLoop.create_server�s����8�c�4� ��H�I�I� �,����C�E� E� �+����B�D� D����d�#���t�/��� �N�P�P��$� "���7� 2� O�s�|�|�x�7O� ��G��r�z�����T�3�'� ��{���'?�'?�@������$�%�#�d��1�1�$��V�8=�2�?�#� �%� �,�,��+�+�E�� ���5�5�e�<�=�E��I�4 %� �C�9<�6�B��%��B�!�%�}�}�R��5�A���N�N�4�(�$����"�-�-�v�/B�/B�D�J�"�b�V�^�^�V�_�_�,M�&M�&�t�,�"��&�/�/�1�#�F�N�;�����(;�(;�(.�(:�(:�(,�.� @�� � �"� �;!�V�!�:?�%@�%�$�d�1�g�%�%@�#C�D�D�!� � � '��� � ��!(��|� �!L�M�M��y�y�F�.�.�.� �#E�d�X�!N�O�O��f�G��D����U�#����g�'7��W�&;�,�.����!�!�#��+�+�a�.� � ��;�;��K�K���0�� ��c%�,��"�<�<�!��;�;�"�N�N�,G�+-�x���O�!� !��4#�@�#%�c�#�h�n�n�&6� 8���9�9��(;�(;�;�#�K�K�M� �J�J�L�#�{�{� &���s� 3�$�%�c�i�i��5�4�?��@��&A��!� '��� � ��!(�!��( !�s��CQ�L'�*Q�L,�.Q�1 P�?L/�C P� M/�1P�?P �P�B(Q�>P>�?.Q�/9M,�(P�+M,�,P�/ P�8A=P�5P�;P�P�P�P;�;Q)rur�r�c ��rK�|jtjk7rtd|����|� |std��|� |std��|�t |�|j|||dd||���d{���\}}|jr)|jd�}tjd|||�||fS7�@�w) Nrrrr5T)r!r�r�r+z%r handled: (%r, %r)) rGr+r:r,rwrr|rrr�)r�r�r1rur�r�r�rs r�connect_accepted_socketz%BaseEventLoop.connect_accepted_socketRs����� �9�9��*�*�*��A�$��J�K�K� �,�S��C�E� E� �+�C��B�D� D����d�#�$(�$E�$E��"�C���"7�!5�%F�%7�7�� �8��;�;��+�+�H�5�D��L�L�/��y�(�K��(�"�"�7�s�A2B7�4B5�5AB7c��K�|�}|j�}|j|||�} |�d{���|jr&t j d|j �||�||fS7�:#|j��xYw�w)Nz Read pipe %r connected: (%r, %r))r�r.r�r|rr��fileno�r�r�r-rr�r�s r�connect_read_pipezBaseEventLoop.connect_read_pipeps�����#�%���#�#�%���2�2�4��6�J� � ��L�L� �;�;��L�L�;����� �8� =��(�"�"� �� ��O�O����+�+B�A0�A.�A0�6B�.A0�0B�Bc��K�|�}|j�}|j|||�} |�d{���|jr&t j d|j �||�||fS7�:#|j��xYw�w)Nz!Write pipe %r connected: (%r, %r))r�r0r�r|rr�rurvs r�connect_write_pipez BaseEventLoop.connect_write_pipe�s�����#�%���#�#�%���3�3�D�(�F�K� � ��L�L� �;�;��L�L�<����� �8� =��(�"�"� �� ��O�O���rxc�r�|g}|�|jdt|����|�1|tjk(r|jdt|����n>|�|jdt|����|�|jdt|����t j dj |��y)Nzstdin=zstdout=stderr=zstdout=zstderr=� )rBr'r#r%rr�rk)r�r�r4r5r6r�s r�_log_subprocesszBaseEventLoop._log_subprocess�s����u�����K�K�&��e�!4� 5�6�7���&�J�,=�,=�"=��K�K�.��f�)=�(>�?�@��!����g�l�6�&:�%;�<�=��!����g�l�6�&:�%;�<�=����S�X�X�d�^�$r!) r4r5r6�universal_newlinesr3r7�encoding�errors�textc ���K�t|ttf�std��|rtd��|std��|dk7rtd��|rtd��| �td��| �td��|�} d}|jrd |z}|j||||�|j| |d ||||fi|���d{���}|jr|�tjd||�|| fS7�-�w)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,r|r}r9rr�)r�r��cmdr4r5r6r~r3r7rr�r�r8r� debug_logr�s r�subprocess_shellzBaseEventLoop.subprocess_shell�s�����#��s�|�,��3�4�4���?�@�@���1�2�2��a�<��0�1�1���1�2�2����4�5�5����2�3�3�#�%��� ��;�;�/��4�I�� � ��E�6�6�B�9�$�9�9��c�4�����K�CI�K�K� ��;�;�9�0��K�K��)�Y�7��(�"�"� K�s�B=C/�?C-�.C/c ��K�|rtd��|rtd��|dk7rtd��|rtd��| �td��| �td��|f|z}|�}d}|jrd|��}|j||||�|j||d ||||fi| ���d{���}|jr|�t j d ||�||fS7�-�w)Nr�zshell must be Falserr�r�r�r�zexecute program Fr�)r,r|r}r9rr�)r�r��programr4r5r6r~r3r7rr�r�r2r8� popen_argsrr�r�s r�subprocess_execzBaseEventLoop.subprocess_exec�s������?�@�@���2�3�3��a�<��0�1�1���1�2�2����4�5�5����2�3�3��Z�$�&� �#�%��� ��;�;�+�7�+�6�I�� � ��E�6�6�B�9�$�9�9��j�%��������� ��;�;�9�0��K�K��)�Y�7��(�"�"��s�B"C�$C�%.Cc��|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�H�|�t|�std|����||_y)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�s5����x��'8��#�#*�+�/�0� 0�")��r!c���|jd�}|sd}|jd�}|�t|�||jf}nd}d|vr;|j�/|jjr|jj|d<|g}t|�D]�}|dvr�||}|dk(r:d j tj|��}d }||j�z }nJ|dk(r:d j tj|��}d}||j�z }nt|�}|j|�d|�����tjd j |�|��y)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()`. rSz!Unhandled exception in event looprgNF�source_traceback�handle_traceback>rSrgr5z+Object created at (most recent call last): z+Handle created at (most recent call last): r�� r^)�getrG� __traceback__r�r�sortedrk� traceback�format_list�rstriprrBrrG) r�r rSrgr_� log_linesrR�value�tbs r�default_exception_handlerz'BaseEventLoop.default_exception_handler�s[���+�+�i�(���9�G��K�K��,� �� ��Y���I�4K�4K�L�H��H��g�-��$�$�0��$�$�6�6��$�$�6�6� �&�'��I� ��'�?�C��.�.���C�L�E��(�(��W�W�Y�2�2�5�9�:��F�������$���*�*��W�W�Y�2�2�5�9�:��F�������$���U�������u�B�u�g�.�/�#� ���T�Y�Y�y�)�H�=r!c���|j� |j|�y d}|jd�}|�|jd�}|�|jd�}|�t|d�r|j�}|�*t|d �r|j|j||�y|j||�y#ttf$r�t$rtjdd��YywxYw#ttf$r�t$r[} |jd ||d��n:#ttf$r�t$rtjdd��YnwxYwYd}~yYd}~yd}~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^rror�get_context�runz$Unhandled error in exception handler)rSrgr zeException in default exception handler while handling an unexpected error in custom exception handler)r�r�rhrir-rrGr�r*r�r�)r�r �ctx�thingrms rrZz$BaseEventLoop.call_exception_handler+sq��,�"�"�*� ,��.�.�w�7�$ 0������F�+���=�$�K�K��1�E��=�#�K�K��1�E��$��� �)F��+�+�-�C��?�w�s�E�':��G�G�D�3�3�T�7�C��+�+�D�'�:��3� 1�2� �� � ,����E�&*�,� ,��0� 1�2� �� � 0�0��2�2�#I�%(�#*�4��� #�$5�6���$�0��L�L�"?�+/�0�0��0��� 0�sM�B7�BC,�$C,�7/C)�(C)�,E�D�E�/E � E�E � E�Ec�T�|js|jj|�yy)zAdd a Handle to _ready.N)� _cancelledr�rB�r�rs r� _add_callbackzBaseEventLoop._add_callbackss"��� � ��K�K���v�&�!r!c�F�|j|�|j�y)z6Like _add_callback() but called from a signal handler.N)r�r;r�s r�_add_callback_signalsafez&BaseEventLoop._add_callback_signalsafexs�����6�"����r!c�H�|jr|xjdz c_yy)z3Notification that a TimerHandle has been cancelled.rN)r�r�r�s r�_timer_handle_cancelledz%BaseEventLoop._timer_handle_cancelled}s!������'�'�1�,�'�r!c�b�t|j�}|tkDrr|j|ztkDr\g}|jD]'}|j rd|_�|j |��)tj|�||_d|_n�|jrz|jdj ra|xjdzc_tj|j�}d|_|jr|jdj r�ad}|js|jrd}nP|jrD|jdj}ttd||j�z �t �}|j"j%|�}|j'|�d}|j�|j(z}|jrm|jd}|j|k\rnNtj|j�}d|_|jj |�|jr�mt|j�}t+|�D]�} |jj-�}|j r�*|j.rr ||_|j�} |j3�|j�| z }||j4k\r t7j8dt;|�|�d|_��|j3���d}y#d|_wxYw)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)rUr��_MIN_SCHEDULED_TIMER_HANDLESr��%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr�rBr��heapify�heappopr�r��_whenr��maxr��MAXIMUM_SELECT_TIMEOUT� _selector�selectr>r��range�popleftr|r��_runr�rrfr )r��sched_count� new_scheduledrrjr�r=�end_time�ntodo�ir�r�s rr�zBaseEventLoop._run_once�s����$�/�/�*���6�6��'�'�+�5�5� 6��M��/�/���$�$�(-�F�%�!�(�(��0� *� �M�M�-�(�+�D�O�*+�D�'��/�/�d�o�o�a�&8�&C�&C��+�+�q�0�+����t���7��$)��!��/�/�d�o�o�a�&8�&C�&C� ���;�;�$�.�.��G� �_�_��?�?�1�%�+�+�D��#�a��� � ��!3�4�6L�M�G��^�^�*�*�7�3� ����Z�(�� ��9�9�;��!7�!7�7���o�o��_�_�Q�'�F��|�|�x�'���]�]�4�?�?�3�F� %�F���K�K���v�&� �o�o��D�K�K� ���u��A��[�[�(�(�*�F�� � ���{�{� 0�+1�D�(�����B��K�K�M�����r�)�B��T�8�8�8����'G�'5�f�'=�r�C�,0�D�(���� �!�"���,0�D�(�s �A)L%�% L.c� �t|�t|j�k(ry|rDtj�|_tj tj�||_ytj |j�||_yrP)rr�r}�#get_coroutine_origin_tracking_depthr��#set_coroutine_origin_tracking_depthr�DEBUG_STACK_DEPTH�r��enableds rr{z,BaseEventLoop._set_coroutine_origin_tracking�sw����=�D��!H�!H�I�I����7�7�9� �7��3�3��+�+� -�3:��/� �3�3��;�;� =�3:��/r!c��|jSrP)r|r�s rrzBaseEventLoop.get_debug�s���{�{�r!c�l�||_|j�r|j|j|�yyrP)r|rrDr{r�s rr�zBaseEventLoop.set_debug�s.������?�?���%�%�d�&I�&I�7�S�r!rP)NNNr<)r)rN)FNN)Ur�r�r�r�r�r�rrrrr'r*r.r0r9r;r>r rArHrPr_rqrhrwr�r�rkr�rrLrMr�rr�r�r�r�r�r�r�rDr�r�r�r�r�r�r�r�r�r�rrr%r#r$r2rVr+r:rrYr?� AI_PASSIVErqrsrwrzr}r#r$r�r�r�r�r�rZr�r�r�r�r{rr�rQr!rrr�s��/�< �)�)-�d��4%�"�"�%)�$�"�9=�"� �$��t�"&�!%�!%� "�CG�"� @D�(,�"� AE�)-�"�04�"�"�"�7�D�G� "��2�0D�K�4�0$�L�*�.�%�M�M��-� �:>��06:��$26��&%��(�"=A� �5� *� �2"#��!�1�H�7� A�(,� A�.�/�4�*).�X59�Q#����1�4��T�"&�!%�!%�$��Q#�j*/�"&�!%� #�8-<�#'�-<�^1�"�4%*�(,�.2�-1� .+�bEI�D#�./�q��26�7;�$� D#�N'(�f�.@�.@�%&�a� D��59�K��#�#��#�#������"&�!%��K�^�"&�!%� #�<#� #� %�&0�_�_�&0�o�o�&0�o�o�27�%)�1�(,�T�� "#�J%/�O�O�J�O�O�%/�_�_��$)�1�'+�D�t� #�D'� *�"0>�dF0�P'� � -� N�` :��Tr!r)rr)r)7�__doc__rU�collections.abc�concurrent.futuresr�r�r�rZrCr+rAr#rfr�r�r}rLr�ru�ImportErrorr5rrrrrr r rrr rr�logr�__all__r�r�r*rAr�r r'r2rMrdrnrrrw�Protocolry�AbstractServerr�AbstractEventLooprrQr!r�<module>r�s-�� ������� � ������ ������������������$�� #��),�%� �F�J�'� �#����J�8�v�,"��6�=�!�G� �>� A)� � 2� 2�A)�HB�V� "� "�B�JPT�F�,�,�PT��k�� �C��s�D�D�D__pycache__/base_futures.cpython-312.opt-1.pyc000064400000006020151706172560015115 0ustar00� T��h���h�dZddlZddlmZdZdZdZd�Zd �Zd �Z ej�d��Zy)��N�)�format_helpers�PENDING� CANCELLED�FINISHEDc�N�t|jd�xr|jduS)z�Check for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. �_asyncio_future_blockingN)�hasattr� __class__r )�objs �-/usr/lib64/python3.12/asyncio/base_futures.py�isfuturer s+�� �C�M�M�#=�>� 5��(�(��4�6�c� �t|�}|sd}d�}|dk(r||dd�}nc|dk(r+dj||dd�||dd��}n3|dkDr.dj||dd�|dz ||dd��}d |�d �S)�#helper function for Future.__repr__�c�.�tj|d�S)Nr)r�_format_callback_source)�callbacks r� format_cbz$_format_callbacks.<locals>.format_cbs���5�5�h��C�Crrr�z{}, {}z{}, <{} more>, {}���zcb=[�])�len�format)�cb�sizers r�_format_callbacksrs����r�7�D�� ��D��q�y� �r�!�u�Q�x� �� ��� �_�_�Y�r�!�u�Q�x�0�)�B�q�E�!�H�2E� F�� ��� � '� '� �"�Q�%��(�(;�(,�q��(1�"�R�&��)�(<�>���"��Q�<�rc���|jj�g}|jtk(r^|j�|j d|j���n3tj|j�}|j d|���|jr$|j t|j��|jr,|jd}|j d|d�d|d���|S)rz exception=zresult=rzcreated at r�:r)�_state�lower� _FINISHED� _exception�append�reprlib�repr�_result� _callbacksr�_source_traceback)�future�info�result�frames r�_future_repr_infor0,s��� �M�M���!�"�D� �}�}� �!����(��K�K�*�V�%6�%6�$9�:�;��\�\�&�.�.�1�F��K�K�'�&��*�+� ������%�f�&7�&7�8�9� ����(�(��,�����k�%��(��1�U�1�X�J�7�8��Krc�p�djt|��}d|jj�d|�d�S)N� �<�>)�joinr0r�__name__)r,r-s r�_future_reprr7@s8���8�8�%�f�-�.�D� �v���(�(�)��4�&��2�2r)�__all__r'rr�_PENDING� _CANCELLEDr$rrr0�recursive_reprr7rrr�<module>r<sO�� ������ � �� �6��(�(�����3��3r__pycache__/base_futures.cpython-312.pyc000064400000006020151706172560014156 0ustar00� T��h���h�dZddlZddlmZdZdZdZd�Zd �Zd �Z ej�d��Zy)��N�)�format_helpers�PENDING� CANCELLED�FINISHEDc�N�t|jd�xr|jduS)z�Check for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. �_asyncio_future_blockingN)�hasattr� __class__r )�objs �-/usr/lib64/python3.12/asyncio/base_futures.py�isfuturer s+�� �C�M�M�#=�>� 5��(�(��4�6�c� �t|�}|sd}d�}|dk(r||dd�}nc|dk(r+dj||dd�||dd��}n3|dkDr.dj||dd�|dz ||dd��}d |�d �S)�#helper function for Future.__repr__�c�.�tj|d�S)Nr)r�_format_callback_source)�callbacks r� format_cbz$_format_callbacks.<locals>.format_cbs���5�5�h��C�Crrr�z{}, {}z{}, <{} more>, {}���zcb=[�])�len�format)�cb�sizers r�_format_callbacksrs����r�7�D�� ��D��q�y� �r�!�u�Q�x� �� ��� �_�_�Y�r�!�u�Q�x�0�)�B�q�E�!�H�2E� F�� ��� � '� '� �"�Q�%��(�(;�(,�q��(1�"�R�&��)�(<�>���"��Q�<�rc���|jj�g}|jtk(r^|j�|j d|j���n3tj|j�}|j d|���|jr$|j t|j��|jr,|jd}|j d|d�d|d���|S)rz exception=zresult=rzcreated at r�:r)�_state�lower� _FINISHED� _exception�append�reprlib�repr�_result� _callbacksr�_source_traceback)�future�info�result�frames r�_future_repr_infor0,s��� �M�M���!�"�D� �}�}� �!����(��K�K�*�V�%6�%6�$9�:�;��\�\�&�.�.�1�F��K�K�'�&��*�+� ������%�f�&7�&7�8�9� ����(�(��,�����k�%��(��1�U�1�X�J�7�8��Krc�p�djt|��}d|jj�d|�d�S)N� �<�>)�joinr0r�__name__)r,r-s r�_future_reprr7@s8���8�8�%�f�-�.�D� �v���(�(�)��4�&��2�2r)�__all__r'rr�_PENDING� _CANCELLEDr$rrr0�recursive_reprr7rrr�<module>r<sO�� ������ � �� �6��(�(�����3��3r__pycache__/base_subprocess.cpython-312.opt-2.pyc000064400000036646151706172560015632 0ustar00� T��h�"���ddlZddlZddlZddlmZddlmZddlmZGd�dej�Z Gd�d ej�ZGd �deej�Z y)�N�)� protocols)� transports)�loggerc���eZdZ d�fd� Zd�Zd�Zd�Zd�Zd�Zd�Z e jfd�Zd �Z d �Zd�Zd�Zd �Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z�xZS)�BaseSubprocessTransportc �n��t� |�| �d|_||_||_d|_d|_d|_g|_tj�|_i|_d|_ |tjk(rd|jd<|tjk(rd|jd<|tjk(rd|jd< |j d||||||d�|��|j j$|_|j |j&d<|jj)�r?t+|t,t.f�r|}n|d}t1j2d||j�|jj5|j7| ��y#|j#��xYw) NFrr�)�args�shell�stdin�stdout�stderr�bufsize� subprocesszprocess %r created: pid %s�)�super�__init__�_closed� _protocol�_loop�_proc�_pid�_returncode� _exit_waiters�collections�deque�_pending_calls�_pipes� _finishedr�PIPE�_start�close�pid�_extra� get_debug� isinstance�bytes�strr�debug�create_task�_connect_pipes)�self�loop�protocolrrr rrr�waiter�extra�kwargs�program� __class__s ��0/usr/lib64/python3.12/asyncio/base_subprocess.pyrz BaseSubprocessTransport.__init__sx��� ��������!����� ��� ��� �������)�/�/�1����������J�O�O�#�!�D�K�K��N��Z�_�_�$�!�D�K�K��N��Z�_�_�$�!�D�K�K��N� ��D�K�K� B�T��e�F�%�w� B�:@� B��J�J�N�N�� �$(�J�J����L�!��:�:���!��$����-����q�'���L�L�5� �$�)�)� -� � � ���t�2�2�6�:�;�� ��J�J�L��s�F!�!F4c�^�|jjg}|jr|jd�|j�|jd|j���|j �|jd|j ���n/|j�|jd�n|jd�|jjd�}|�|jd|j���|jjd�}|jjd �}|�#||ur|jd |j���n@|�|jd|j���|�|jd|j���d jdj|��S)N�closedzpid=zreturncode=�runningznot startedrzstdin=rr zstdout=stderr=zstdout=zstderr=z<{}>� )r4�__name__r�appendrrr�get�pipe�format�join)r-�infor rrs r5�__repr__z BaseSubprocessTransport.__repr__7sX�����'�'�(���<�<��K�K��!��9�9� ��K�K�$�t�y�y�k�*�+����'��K�K�+�d�&6�&6�%7�8�9� �Y�Y� "��K�K� �"��K�K� �&�������"�����K�K�&�����-�.�������#��������#����&�F�"2��K�K�.���� �6�7��!����g�f�k�k�]�3�4��!����g�f�k�k�]�3�4��}�}�S�X�X�d�^�,�,�c��t��N)�NotImplementedError)r-rrr rrrr2s r5r"zBaseSubprocessTransport._startTs��!�!rBc��||_yrD�r)r-r/s r5�set_protocolz$BaseSubprocessTransport.set_protocolWs ��!��rBc��|jSrDrG�r-s r5�get_protocolz$BaseSubprocessTransport.get_protocolZs���~�~�rBc��|jSrD)rrJs r5� is_closingz"BaseSubprocessTransport.is_closing]s���|�|�rBc���|jryd|_|jj�D]}|��|jj ��!|j �t|j�g|j j��L|jj�rtjd|� |j j�yyyy#t$rYywxYw)NTz$Close running child process: kill %r)rr�valuesr=r#rr�pollrr&r�warning�kill�ProcessLookupError)r-�protos r5r#zBaseSubprocessTransport.close`s����<�<������[�[�'�'�)�E��}���J�J����*� �J�J�"�� � �(�� � ���!�)��z�z�#�#�%����E�t�L� �� � ���!� *�)� #��&� �� �s�4C� C�Cc�b�|js#|d|��t|��|j�yy)Nzunclosed transport )�source)r�ResourceWarningr#)r-�_warns r5�__del__zBaseSubprocessTransport.__del__{s+���|�|��'��x�0�/�$�O��J�J�L�rBc��|jSrD)rrJs r5�get_pidzBaseSubprocessTransport.get_pid�s���y�y�rBc��|jSrD)rrJs r5�get_returncodez&BaseSubprocessTransport.get_returncode�s�����rBc�R�||jvr|j|jSyrD)rr=)r-�fds r5�get_pipe_transportz*BaseSubprocessTransport.get_pipe_transport�s%�� ������;�;�r�?�'�'�'�rBc�0�|j� t��yrD)rrSrJs r5�_check_procz#BaseSubprocessTransport._check_proc�s���:�:��$�&�&�rBc�Z�|j�|jj|�yrD)rbr�send_signal)r-�signals r5rdz#BaseSubprocessTransport.send_signal�s ������� � ���v�&rBc�X�|j�|jj�yrD)rbr� terminaterJs r5rgz!BaseSubprocessTransport.terminate�s������� � ���rBc�X�|j�|jj�yrD)rbrrRrJs r5rRzBaseSubprocessTransport.kill�s������� � ���rBc���K� �j}�j}|j�9|j�fd�|j��d{���\}}|�jd<|j �9|j �fd�|j ��d{���\}}|�jd<|j�9|j �fd�|j��d{���\}}|�jd<|j�jj���jD]\}}|j|g|����d�_|�#|j�s|jd�yyy7��7��7��#ttf$r�t $r7}|�+|j�s|j#|�Yd}~yYd}~yYd}~yd}~wwxYw�w)Nc���t�d�S)Nr)�WriteSubprocessPipeProtorJs�r5�<lambda>z8BaseSubprocessTransport._connect_pipes.<locals>.<lambda>�s ���4�T�1�=rBrc���t�d�S)Nr��ReadSubprocessPipeProtorJs�r5rlz8BaseSubprocessTransport._connect_pipes.<locals>.<lambda>�� ���3�D�!�<rBrc���t�d�S)Nr rnrJs�r5rlz8BaseSubprocessTransport._connect_pipes.<locals>.<lambda>�rprBr )rrr �connect_write_piperr�connect_read_piper� call_soonr�connection_mader� cancelled� set_result� SystemExit�KeyboardInterrupt� BaseException� set_exception) r-r0�procr.�_r=�callback�data�excs ` r5r,z&BaseSubprocessTransport._connect_pipes�s������# (��:�:�D��:�:�D��z�z�%� $� 7� 7�=��J�J�! � ���4�"&����A���{�{�&� $� 6� 6�<��K�K�!!�!���4�"&����A���{�{�&� $� 6� 6�<��K�K�!!�!���4�"&����A�� �N�N�4�>�>�9�9�4�@�"&�"5�"5���$�����x�/�$�/�#6�"&�D���!�&�*:�*:�*<��!�!�$�'�+=�!�; ��!��!���-�.� ��� *��!�&�*:�*:�*<��$�$�S�)�)�+=�!�� *�sh�F?�AE-�E&�AE-�E)�AE-�E+�A*E-�&F?�&E-�)E-�+E-�-F<�#F7�(F?�7F<�<F?c��|j�|jj||f�y|jj|g|���yrD)rr;rrt)r-�cbrs r5�_callzBaseSubprocessTransport._call�s?�����*����&�&��D�z�2� �D�J�J� � ��+�d�+rBc�r�|j|jj||�|j�yrD)r�r�pipe_connection_lost�_try_finish)r-r_r�s r5�_pipe_connection_lostz-BaseSubprocessTransport._pipe_connection_lost�s(��� � �4�>�>�6�6��C�@����rBc�R�|j|jj||�yrD)r�r�pipe_data_received)r-r_rs r5�_pipe_data_receivedz+BaseSubprocessTransport._pipe_data_received�s��� � �4�>�>�4�4�b�$�?rBc�,�|jj�rtjd||�||_|j j�||j _|j|jj�|j�y)Nz%r exited with return code %r)rr&rr@rr� returncoder�r�process_exitedr�)r-r�s r5�_process_exitedz'BaseSubprocessTransport._process_exited�sm���:�:���!��K�K�7��z�J�%����:�:� � �(�%/�D�J�J�!�� � �4�>�>�0�0�1����rBc��K� |j�|jS|jj�}|jj |�|�d{���S7��wrD)rr� create_futurerr;)r-r0s r5�_waitzBaseSubprocessTransport._wait�sU���� '����'��#�#�#����)�)�+�����!�!�&�)��|��|�s�AA�A�Ac��|j�ytd�|jj�D��r$d|_|j|jd�yy)Nc3�@K�|]}|duxr|j���y�wrD)�disconnected)�.0�ps r5� <genexpr>z6BaseSubprocessTransport._try_finish.<locals>.<genexpr>�s(����.�,�1���}�/����/�,�s�T)r�allrrOr r��_call_connection_lostrJs r5r�z#BaseSubprocessTransport._try_finish�sS�����#���.����*�*�,�.�.�!�D�N��J�J�t�1�1�4�8�.rBc�� |jj|�|jD].}|j�r�|j |j ��0d|_d|_d|_d|_y#|jD].}|j�r�|j |j ��0d|_d|_d|_d|_wxYwrD)r�connection_lostrrvrwrrr)r-r�r0s r5r�z-BaseSubprocessTransport._call_connection_lost�s��� "��N�N�*�*�3�/��,�,���'�'�)��%�%�d�&6�&6�7�-�"&�D���D�J��D�J�!�D�N�� �,�,���'�'�)��%�%�d�&6�&6�7�-�"&�D���D�J��D�J�!�D�N�s�A7�7 C�:C)NN)r:� __module__�__qualname__rrAr"rHrKrMr#�warnings�warnrYr[r]r`rbrdrgrRr,r�r�r�r�r�r�r�� __classcell__)r4s@r5rr s����%)�)<�V-�:"�"����6%�M�M�� � ��'�'���$(�L,��@�� �9�"rBrc�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)rkc�<�||_||_d|_d|_y)NF)r|r_r=r�)r-r|r_s r5rz!WriteSubprocessPipeProto.__init__s���� ������ �!��rBc��||_yrD)r=)r-� transports r5ruz(WriteSubprocessPipeProto.connection_mades ���� rBc�j�d|jj�d|j�d|j�d�S)N�<z fd=z pipe=�>)r4r:r_r=rJs r5rAz!WriteSubprocessPipeProto.__repr__ s0���4�>�>�*�*�+�4����y��t�y�y�m�1�M�MrBc�l�d|_|jj|j|�d|_y)NT)r�r|r�r_)r-r�s r5r�z(WriteSubprocessPipeProto.connection_lost s)�� ���� � �'�'�����5��� rBc�L�|jjj�yrD)r|r� pause_writingrJs r5r�z&WriteSubprocessPipeProto.pause_writings��� � ���)�)�+rBc�L�|jjj�yrD)r|r�resume_writingrJs r5r�z'WriteSubprocessPipeProto.resume_writings��� � ���*�*�,rBN) r:r�r�rrurAr�r�r�rrBr5rkrk�s!��"��N�� ,�-rBrkc��eZdZd�Zy)roc�P�|jj|j|�yrD)r|r�r_)r-rs r5� data_receivedz%ReadSubprocessPipeProto.data_receiveds��� � �%�%�d�g�g�t�4rBN)r:r�r�r�rrBr5roros��5rBro)rrr��rr�logr�SubprocessTransportr�BaseProtocolrk�ProtocolrorrBr5�<module>r�sT��������r"�j�<�<�r"�j-�y�5�5�-�45�6�'�0�0�5rB__pycache__/base_subprocess.cpython-312.pyc000064400000037320151706172560014660 0ustar00� T��h�"���ddlZddlZddlZddlmZddlmZddlmZGd�dej�Z Gd�d ej�ZGd �deej�Z y)�N�)� protocols)� transports)�loggerc���eZdZ d�fd� Zd�Zd�Zd�Zd�Zd�Zd�Z e jfd�Zd �Z d �Zd�Zd�Zd �Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z�xZS)�BaseSubprocessTransportc �n��t� |�| �d|_||_||_d|_d|_d|_g|_tj�|_i|_d|_ |tjk(rd|jd<|tjk(rd|jd<|tjk(rd|jd< |j d||||||d�|��|j j$|_|j |j&d<|jj)�r?t+|t,t.f�r|}n|d}t1j2d||j�|jj5|j7| ��y#|j#��xYw) NFrr�)�args�shell�stdin�stdout�stderr�bufsize� subprocesszprocess %r created: pid %s�)�super�__init__�_closed� _protocol�_loop�_proc�_pid�_returncode� _exit_waiters�collections�deque�_pending_calls�_pipes� _finishedr�PIPE�_start�close�pid�_extra� get_debug� isinstance�bytes�strr�debug�create_task�_connect_pipes)�self�loop�protocolrrr rrr�waiter�extra�kwargs�program� __class__s ��0/usr/lib64/python3.12/asyncio/base_subprocess.pyrz BaseSubprocessTransport.__init__sx��� ��������!����� ��� ��� �������)�/�/�1����������J�O�O�#�!�D�K�K��N��Z�_�_�$�!�D�K�K��N��Z�_�_�$�!�D�K�K��N� ��D�K�K� B�T��e�F�%�w� B�:@� B��J�J�N�N�� �$(�J�J����L�!��:�:���!��$����-����q�'���L�L�5� �$�)�)� -� � � ���t�2�2�6�:�;�� ��J�J�L��s�F!�!F4c�^�|jjg}|jr|jd�|j�|jd|j���|j �|jd|j ���n/|j�|jd�n|jd�|jjd�}|�|jd|j���|jjd�}|jjd �}|�#||ur|jd |j���n@|�|jd|j���|�|jd|j���d jdj|��S)N�closedzpid=zreturncode=�runningznot startedrzstdin=rr zstdout=stderr=zstdout=zstderr=z<{}>� )r4�__name__r�appendrrr�get�pipe�format�join)r-�infor rrs r5�__repr__z BaseSubprocessTransport.__repr__7sX�����'�'�(���<�<��K�K��!��9�9� ��K�K�$�t�y�y�k�*�+����'��K�K�+�d�&6�&6�%7�8�9� �Y�Y� "��K�K� �"��K�K� �&�������"�����K�K�&�����-�.�������#��������#����&�F�"2��K�K�.���� �6�7��!����g�f�k�k�]�3�4��!����g�f�k�k�]�3�4��}�}�S�X�X�d�^�,�,�c��t��N)�NotImplementedError)r-rrr rrrr2s r5r"zBaseSubprocessTransport._startTs��!�!rBc��||_yrD�r)r-r/s r5�set_protocolz$BaseSubprocessTransport.set_protocolWs ��!��rBc��|jSrDrG�r-s r5�get_protocolz$BaseSubprocessTransport.get_protocolZs���~�~�rBc��|jSrD)rrJs r5� is_closingz"BaseSubprocessTransport.is_closing]s���|�|�rBc���|jryd|_|jj�D]}|��|jj ��!|j �t|j�g|j j��L|jj�rtjd|� |j j�yyyy#t$rYywxYw)NTz$Close running child process: kill %r)rr�valuesr=r#rr�pollrr&r�warning�kill�ProcessLookupError)r-�protos r5r#zBaseSubprocessTransport.close`s����<�<������[�[�'�'�)�E��}���J�J����*� �J�J�"�� � �(�� � ���!�)��z�z�#�#�%����E�t�L� �� � ���!� *�)� #��&� �� �s�4C� C�Cc�b�|js#|d|��t|��|j�yy)Nzunclosed transport )�source)r�ResourceWarningr#)r-�_warns r5�__del__zBaseSubprocessTransport.__del__{s+���|�|��'��x�0�/�$�O��J�J�L�rBc��|jSrD)rrJs r5�get_pidzBaseSubprocessTransport.get_pid�s���y�y�rBc��|jSrD)rrJs r5�get_returncodez&BaseSubprocessTransport.get_returncode�s�����rBc�R�||jvr|j|jSyrD)rr=)r-�fds r5�get_pipe_transportz*BaseSubprocessTransport.get_pipe_transport�s%�� ������;�;�r�?�'�'�'�rBc�0�|j� t��yrD)rrSrJs r5�_check_procz#BaseSubprocessTransport._check_proc�s���:�:��$�&�&�rBc�Z�|j�|jj|�yrD)rbr�send_signal)r-�signals r5rdz#BaseSubprocessTransport.send_signal�s ������� � ���v�&rBc�X�|j�|jj�yrD)rbr� terminaterJs r5rgz!BaseSubprocessTransport.terminate�s������� � ���rBc�X�|j�|jj�yrD)rbrrRrJs r5rRzBaseSubprocessTransport.kill�s������� � ���rBc���K� �j}�j}|j�9|j�fd�|j��d{���\}}|�jd<|j �9|j �fd�|j ��d{���\}}|�jd<|j�9|j �fd�|j��d{���\}}|�jd<�j�J�|j�jj���jD]\}}|j|g|����d�_|�#|j�s|jd�yyy7��)7��7��#ttf$r�t $r7}|�+|j�s|j#|�Yd}~yYd}~yYd}~yd}~wwxYw�w)Nc���t�d�S)Nr)�WriteSubprocessPipeProtorJs�r5�<lambda>z8BaseSubprocessTransport._connect_pipes.<locals>.<lambda>�s ���4�T�1�=rBrc���t�d�S)Nr��ReadSubprocessPipeProtorJs�r5rlz8BaseSubprocessTransport._connect_pipes.<locals>.<lambda>�� ���3�D�!�<rBrc���t�d�S)Nr rnrJs�r5rlz8BaseSubprocessTransport._connect_pipes.<locals>.<lambda>�rprBr )rrr �connect_write_piperr�connect_read_piperr� call_soonr�connection_made� cancelled� set_result� SystemExit�KeyboardInterrupt� BaseException� set_exception) r-r0�procr.�_r=�callback�data�excs ` r5r,z&BaseSubprocessTransport._connect_pipes�s������# (��:�:�D��:�:�D��z�z�%� $� 7� 7�=��J�J�! � ���4�"&����A���{�{�&� $� 6� 6�<��K�K�!!�!���4�"&����A���{�{�&� $� 6� 6�<��K�K�!!�!���4�"&����A���&�&�2�2�2��N�N�4�>�>�9�9�4�@�"&�"5�"5���$�����x�/�$�/�#6�"&�D���!�&�*:�*:�*<��!�!�$�'�+=�!�; ��!��!���-�.� ��� *��!�&�*:�*:�*<��$�$�S�)�)�+=�!�� *�sh�G �AE;�E4�AE;�E7�AE;�E9�A8E;�&G �4E;�7E;�9E;�;G �#G�6G �G � G c��|j�|jj||f�y|jj|g|���yrD)rr;rrt)r-�cbrs r5�_callzBaseSubprocessTransport._call�s?�����*����&�&��D�z�2� �D�J�J� � ��+�d�+rBc�r�|j|jj||�|j�yrD)r�r�pipe_connection_lost�_try_finish)r-r_r�s r5�_pipe_connection_lostz-BaseSubprocessTransport._pipe_connection_lost�s(��� � �4�>�>�6�6��C�@����rBc�R�|j|jj||�yrD)r�r�pipe_data_received)r-r_rs r5�_pipe_data_receivedz+BaseSubprocessTransport._pipe_data_received�s��� � �4�>�>�4�4�b�$�?rBc�x�|�J|��|j�J|j��|jj�rtjd||�||_|j j�||j _|j|jj�|j�y)Nz%r exited with return code %r)rrr&rr@r� returncoder�r�process_exitedr�)r-r�s r5�_process_exitedz'BaseSubprocessTransport._process_exited�s����%�1�z�1�%����'�9��)9�)9�9�'��:�:���!��K�K�7��z�J�%����:�:� � �(�%/�D�J�J�!�� � �4�>�>�0�0�1����rBc��K�|j�|jS|jj�}|jj |�|�d{���S7��w)zdWait until the process exit and return the process return code. This method is a coroutine.N)rr� create_futurerr;)r-r0s r5�_waitzBaseSubprocessTransport._wait�sP�������'��#�#�#����)�)�+�����!�!�&�)��|��|�s�AA�A�Ac���|jrJ�|j�ytd�|jj �D��r$d|_|j|jd�yy)Nc3�@K�|]}|duxr|j���y�wrD)�disconnected)�.0�ps r5� <genexpr>z6BaseSubprocessTransport._try_finish.<locals>.<genexpr>�s(����.�,�1���}�/����/�,�s�T)r r�allrrOr��_call_connection_lostrJs r5r�z#BaseSubprocessTransport._try_finish�s`���>�>�!�!����#���.����*�*�,�.�.�!�D�N��J�J�t�1�1�4�8�.rBc�� |jj|�|jD].}|j�r�|j |j ��0d|_d|_d|_d|_y#|jD].}|j�r�|j |j ��0d|_d|_d|_d|_wxYwrD)r�connection_lostrrvrwrrr)r-r�r0s r5r�z-BaseSubprocessTransport._call_connection_lost�s��� "��N�N�*�*�3�/��,�,���'�'�)��%�%�d�&6�&6�7�-�"&�D���D�J��D�J�!�D�N�� �,�,���'�'�)��%�%�d�&6�&6�7�-�"&�D���D�J��D�J�!�D�N�s�A7�7 C�:C)NN)r:� __module__�__qualname__rrAr"rHrKrMr#�warnings�warnrYr[r]r`rbrdrgrRr,r�r�r�r�r�r�r�� __classcell__)r4s@r5rr s����%)�)<�V-�:"�"����6%�M�M�� � ��'�'���$(�L,��@�� �9�"rBrc�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)rkc�<�||_||_d|_d|_y)NF)r|r_r=r�)r-r|r_s r5rz!WriteSubprocessPipeProto.__init__s���� ������ �!��rBc��||_yrD)r=)r-� transports r5ruz(WriteSubprocessPipeProto.connection_mades ���� rBc�j�d|jj�d|j�d|j�d�S)N�<z fd=z pipe=�>)r4r:r_r=rJs r5rAz!WriteSubprocessPipeProto.__repr__ s0���4�>�>�*�*�+�4����y��t�y�y�m�1�M�MrBc�l�d|_|jj|j|�d|_y)NT)r�r|r�r_)r-r�s r5r�z(WriteSubprocessPipeProto.connection_lost s)�� ���� � �'�'�����5��� rBc�L�|jjj�yrD)r|r� pause_writingrJs r5r�z&WriteSubprocessPipeProto.pause_writings��� � ���)�)�+rBc�L�|jjj�yrD)r|r�resume_writingrJs r5r�z'WriteSubprocessPipeProto.resume_writings��� � ���*�*�,rBN) r:r�r�rrurAr�r�r�rrBr5rkrk�s!��"��N�� ,�-rBrkc��eZdZd�Zy)roc�P�|jj|j|�yrD)r|r�r_)r-rs r5� data_receivedz%ReadSubprocessPipeProto.data_receiveds��� � �%�%�d�g�g�t�4rBN)r:r�r�r�rrBr5roros��5rBro)rrr��rr�logr�SubprocessTransportr�BaseProtocolrk�ProtocolrorrBr5�<module>r�sT��������r"�j�<�<�r"�j-�y�5�5�-�45�6�'�0�0�5rB__pycache__/base_tasks.cpython-312.opt-1.pyc000064400000007760151706172560014561 0ustar00� T��hp ��t�ddlZddlZddlZddlmZddlmZd�Zej�d��Zd�Z d�Z y) �N�)�base_futures)� coroutinesc��tj|�}|j�r|j�sd|d<|j dd|j�z�|j�|j dd|j���|jr5tj|j�}|j dd|�d��|S) N� cancellingrrzname=%r�z wait_for=zcoro=<�>) r�_future_repr_infor�done�insert�get_name�_fut_waiter�_coror�_format_coroutine)�task�info�coros �+/usr/lib64/python3.12/asyncio/base_tasks.py�_task_repr_infor s����)�)�$�/�D�����������Q���K�K��9�t�}�}��.�/����#����A��4�#3�#3�"6�7�8��z�z��+�+�D�J�J�7�����A���v�Q�'�(��K�c�p�djt|��}d|jj�d|�d�S)N� �<r )�joinr� __class__�__name__)rrs r� _task_reprrs5���8�8�O�D�)�*�D� �t�~�~�&�&�'�q���a�0�0rc�\�g}t|jd�r|jj}n\t|jd�r|jj}n/t|jd�r|jj}nd}|�A|�-|�|dkrn%|dz}|j|�|j}|��-|j�|S|j�Q|jj}|�9|� |dkr |S|dz}|j|j�|j}|��9|S)N�cr_frame�gi_frame�ag_framerr)�hasattrrrr r!�append�f_back�reverse� _exception� __traceback__�tb_frame�tb_next)r�limit�frames�f�tbs r�_task_get_stackr."s �� �F��t�z�z�:�&��J�J���� ����Z� (��J�J���� ����Z� (��J�J���� ���}��m�� ��A�:���� ���M�M�!�����A� �m� �����M� ��� $� �_�_� *� *���n�� ��A�:���M��� ���M�M�"�+�+�&����B� �n��Mrc��g}t�}|j|��D]�}|j}|j}|j}|j } ||vr&|j |�tj|�tj|||j�} |j||| | f���|j}|std|��|��n%|�td|�d�|��ntd|�d�|��tj||��|�4tj |j"|�D]} t| |d���yy) N)r*z No stack for )�filezTraceback for z (most recent call last):z Stack for �)r0�end)�set� get_stack�f_lineno�f_code�co_filename�co_name�add� linecache� checkcache�getline� f_globalsr#r&�print� traceback� print_list�format_exception_onlyr)rr*r0�extracted_list�checkedr,�lineno�co�filename�name�line�excs r�_task_print_stackrJEs&���N��e�G� �^�^�%�^� (������ �X�X���>�>���z�z���7�"��K�K��!�� � ��*�� � ��6�1�;�;�?�����x���t�<�=�)��/�/�C�� � �d�X�&�T�2� �� ��t�h�&?�@�t�L� � �4�(�";�<�4�H� ����d�3� ���3�3�C�M�M�3�G�D��$�T�r�*�H�r)r:�reprlibr?r1rrr�recursive_reprrr.rJ�rr�<module>rNsC��������&�����1��1� �F+r__pycache__/base_tasks.cpython-312.pyc000064400000007760151706172560013622 0ustar00� T��hp ��t�ddlZddlZddlZddlmZddlmZd�Zej�d��Zd�Z d�Z y) �N�)�base_futures)� coroutinesc��tj|�}|j�r|j�sd|d<|j dd|j�z�|j�|j dd|j���|jr5tj|j�}|j dd|�d��|S) N� cancellingrrzname=%r�z wait_for=zcoro=<�>) r�_future_repr_infor�done�insert�get_name�_fut_waiter�_coror�_format_coroutine)�task�info�coros �+/usr/lib64/python3.12/asyncio/base_tasks.py�_task_repr_infor s����)�)�$�/�D�����������Q���K�K��9�t�}�}��.�/����#����A��4�#3�#3�"6�7�8��z�z��+�+�D�J�J�7�����A���v�Q�'�(��K�c�p�djt|��}d|jj�d|�d�S)N� �<r )�joinr� __class__�__name__)rrs r� _task_reprrs5���8�8�O�D�)�*�D� �t�~�~�&�&�'�q���a�0�0rc�\�g}t|jd�r|jj}n\t|jd�r|jj}n/t|jd�r|jj}nd}|�A|�-|�|dkrn%|dz}|j|�|j}|��-|j�|S|j�Q|jj}|�9|� |dkr |S|dz}|j|j�|j}|��9|S)N�cr_frame�gi_frame�ag_framerr)�hasattrrrr r!�append�f_back�reverse� _exception� __traceback__�tb_frame�tb_next)r�limit�frames�f�tbs r�_task_get_stackr."s �� �F��t�z�z�:�&��J�J���� ����Z� (��J�J���� ����Z� (��J�J���� ���}��m�� ��A�:���� ���M�M�!�����A� �m� �����M� ��� $� �_�_� *� *���n�� ��A�:���M��� ���M�M�"�+�+�&����B� �n��Mrc��g}t�}|j|��D]�}|j}|j}|j}|j } ||vr&|j |�tj|�tj|||j�} |j||| | f���|j}|std|��|��n%|�td|�d�|��ntd|�d�|��tj||��|�4tj |j"|�D]} t| |d���yy) N)r*z No stack for )�filezTraceback for z (most recent call last):z Stack for �)r0�end)�set� get_stack�f_lineno�f_code�co_filename�co_name�add� linecache� checkcache�getline� f_globalsr#r&�print� traceback� print_list�format_exception_onlyr)rr*r0�extracted_list�checkedr,�lineno�co�filename�name�line�excs r�_task_print_stackrJEs&���N��e�G� �^�^�%�^� (������ �X�X���>�>���z�z���7�"��K�K��!�� � ��*�� � ��6�1�;�;�?�����x���t�<�=�)��/�/�C�� � �d�X�&�T�2� �� ��t�h�&?�@�t�L� � �4�(�";�<�4�H� ����d�3� ���3�3�C�M�M�3�G�D��$�T�r�*�H�r)r:�reprlibr?r1rrr�recursive_reprrr.rJ�rr�<module>rNsC��������&�����1��1� �F+r__pycache__/constants.cpython-312.opt-2.pyc000064400000001675151706172560014456 0ustar00� T��h���Z�ddlZdZdZdZdZdZdZdZd Zd Z Gd�dej�Zy) �N��� gN@g>@i�ii,c�r�eZdZej�Zej�Zej�Zy)� _SendfileModeN)�__name__� __module__�__qualname__�enum�auto�UNSUPPORTED� TRY_NATIVE�FALLBACK���*/usr/lib64/python3.12/asyncio/constants.pyrr&s)���$�)�)�+�K������J��t�y�y�{�Hrr)r�!LOG_THRESHOLD_FOR_CONNLOST_WRITES�ACCEPT_RETRY_DELAY�DEBUG_STACK_DEPTH�SSL_HANDSHAKE_TIMEOUT�SSL_SHUTDOWN_TIMEOUT�!SENDFILE_FALLBACK_READBUFFER_SIZE� FLOW_CONTROL_HIGH_WATER_SSL_READ�!FLOW_CONTROL_HIGH_WATER_SSL_WRITE�THREAD_JOIN_TIMEOUT�Enumrrrr�<module>rs^�� �%&�!��� ������%/�!�#&� �$'�!����D�I�I�r__pycache__/coroutines.cpython-312.opt-2.pyc000064400000007066151706172560014634 0ustar00� T��h ���dZddlZddlZddlZddlZddlZd�Ze�Z d�Z ejejjfZe�Zd�Zd�Zy))�iscoroutinefunction�iscoroutine�Nc���tjjxsEtjjxr(t t jjd��S)N�PYTHONASYNCIODEBUG)�sys�flags�dev_mode�ignore_environment�bool�os�environ�get���+/usr/lib64/python3.12/asyncio/coroutines.py�_is_debug_moder sF���9�9���N�c�i�i�&B�&B�"B�#M�"&�r�z�z�~�~�6J�'K�"L�Nrc�X� tj|�xst|dd�tuS)N� _is_coroutine)�inspectr�getattrr)�funcs rrrs0��@��'�'��-� B��D�/�4�0�M�A�Crc�� t|�tvryt|t�r1t t�dkrtjt|��yy)NT�dF)�type�_iscoroutine_typecache� isinstance�_COROUTINE_TYPES�len�add)�objs rrr sH��3��C�y�*�*���#�'�(��%�&��,�"�&�&�t�C�y�1��rc���d�}d�}d}t|d�r|jr |j}n$t|d�r|jr|j}||�}|s||�r|�d�S|Sd}t|d�r|jr |j}n$t|d�r|jr|j}|j xsd}d }|�|j}|�d |�d|��}|S|j}|�d|�d|��}|S) Nc���t|d�r|jr |j}n>t|d�r|jr |j}ndt|�j�d�}|�d�S)N�__qualname__�__name__�<z without __name__>z())�hasattrr#r$r)�coro� coro_names r�get_namez#_format_coroutine.<locals>.get_name3sc�� �4��(�T�->�->��)�)�I� �T�:� &�4�=�=�� � �I��D��J�/�/�0�0B�C�I���B��rc�t� |jS#t$r |jcYS#t$rYYywxYwwxYw)NF)� cr_running�AttributeError� gi_running)r's r� is_runningz%_format_coroutine.<locals>.is_runningAsA�� ��?�?�"��� � ����&��!� �� �� �s �� 7�&�7� 3�7�3�7�cr_code�gi_codez running�gi_frame�cr_framez<empty co_filename>rz running at �:z done, defined at )r&r/r0r1r2�co_filename�f_lineno�co_firstlineno) r'r)r.� coro_coder(� coro_frame�filename�lineno� coro_reprs r�_format_coroutiner<0s�� ���I��t�Y��D�L�L��L�L� � ��y� !�d�l�l��L�L� ����I���d���[��)�)����J��t�Z� �T�]�]��]�]� � ��z� "�t�}�}��]�]� ��$�$�=�(=�H� �F����$�$�� �k��h�Z�q���A� ����)�)�� �k�!3�H�:�Q�v�h�G� ��r)�__all__�collections.abc�collectionsrrr�typesr�objectrr� CoroutineType�abc� Coroutiner�setrrr<rrr�<module>rFs]�� .���� � ��N��� �C��'�'����)B�)B�C����� � =r__pycache__/coroutines.cpython-312.pyc000064400000007273151706172560013674 0ustar00� T��h ���dZddlZddlZddlZddlZddlZd�Ze�Z d�Z ejejjfZe�Zd�Zd�Zy))�iscoroutinefunction�iscoroutine�Nc���tjjxsEtjjxr(t t jjd��S)N�PYTHONASYNCIODEBUG)�sys�flags�dev_mode�ignore_environment�bool�os�environ�get���+/usr/lib64/python3.12/asyncio/coroutines.py�_is_debug_moder sF���9�9���N�c�i�i�&B�&B�"B�#M�"&�r�z�z�~�~�6J�'K�"L�Nrc�V�tj|�xst|dd�tuS)z6Return True if func is a decorated coroutine function.� _is_coroutineN)�inspectr�getattrr)�funcs rrrs-���'�'��-� B��D�/�4�0�M�A�Crc��t|�tvryt|t�r1t t�dkrtjt|��yy)z)Return True if obj is a coroutine object.T�dF)�type�_iscoroutine_typecache� isinstance�_COROUTINE_TYPES�len�add)�objs rrr sE���C�y�*�*���#�'�(��%�&��,�"�&�&�t�C�y�1��rc��t|�sJ�d�}d�}d}t|d�r|jr |j}n$t|d�r|jr|j}||�}|s||�r|�d�S|Sd}t|d�r|jr |j}n$t|d�r|j r|j }|jxsd}d }|�|j}|�d |�d|��}|S|j}|�d|�d|��}|S) Nc���t|d�r|jr |j}n>t|d�r|jr |j}ndt|�j�d�}|�d�S)N�__qualname__�__name__�<z without __name__>z())�hasattrr#r$r)�coro� coro_names r�get_namez#_format_coroutine.<locals>.get_name3sc�� �4��(�T�->�->��)�)�I� �T�:� &�4�=�=�� � �I��D��J�/�/�0�0B�C�I���B��rc�t� |jS#t$r |jcYS#t$rYYywxYwwxYw)NF)� cr_running�AttributeError� gi_running)r's r� is_runningz%_format_coroutine.<locals>.is_runningAsA�� ��?�?�"��� � ����&��!� �� �� �s �� 7�&�7� 3�7�3�7�cr_code�gi_codez running�gi_frame�cr_framez<empty co_filename>rz running at �:z done, defined at ) rr&r/r0r1r2�co_filename�f_lineno�co_firstlineno) r'r)r.� coro_coder(� coro_frame�filename�lineno� coro_reprs r�_format_coroutiner<0s"���t���� ���I��t�Y��D�L�L��L�L� � ��y� !�d�l�l��L�L� ����I���d���[��)�)����J��t�Z� �T�]�]��]�]� � ��z� "�t�}�}��]�]� ��$�$�=�(=�H� �F����$�$�� �k��h�Z�q���A� ����)�)�� �k�!3�H�:�Q�v�h�G� ��r)�__all__�collections.abc�collectionsrrr�typesr�objectrr� CoroutineType�abc� Coroutiner�setrrr<rrr�<module>rFs]�� .���� � ��N��� �C��'�'����)B�)B�C����� � =r__pycache__/events.cpython-312.opt-1.pyc000064400000107610151706172560013741 0ustar00� T��h�r���dZdZddlZddlZddlZddlZddlZddlZddlZddl m Z Gd�d�ZGd�d e�ZGd �d�Z Gd�d �ZGd�d�ZGd�de�Zdaej$�ZGd�dej(�Ze�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!eZ"eZ#eZ$eZ% ddl&mZmZmZmZeZ'eZ(eZ)eZ*e,ed �rd!�Z-ej\e-�"�yy#e+$rY�(wxYw)#z!Event loop and event loop policy.)�AbstractEventLoopPolicy�AbstractEventLoop�AbstractServer�Handle�TimerHandle�get_event_loop_policy�set_event_loop_policy�get_event_loop�set_event_loop�new_event_loop�get_child_watcher�set_child_watcher�_set_running_loop�get_running_loop�_get_running_loop�N�)�format_helpersc�@�eZdZdZdZdd�Zd�Zd�Zd�Zd�Z d �Z d �Zy)rz1Object returned by callback registration methods.)� _callback�_args� _cancelled�_loop�_source_traceback�_repr�__weakref__�_contextNc�"�|�tj�}||_||_||_||_d|_d|_|jj�r.tjtjd��|_ yd|_ y)NFr)�contextvars�copy_contextrrrrrr� get_debugr� extract_stack�sys� _getframer)�self�callback�args�loop�contexts �'/usr/lib64/python3.12/asyncio/events.py�__init__zHandle.__init__$sx���?�!�.�.�0�G��� ��� �!����� ������ ��:�:���!�%3�%A�%A�� � �a� �&"�D�"�&*�D�"�c�h�|jjg}|jr|jd�|j�9|jtj|j|j��|jr,|jd}|jd|d�d|d���|S)N� cancelled���zcreated at r�:r) � __class__�__name__r�appendrr�_format_callback_sourcerr)r$�info�frames r)� _repr_infozHandle._repr_info3s������'�'�(���?�?��K�K��$��>�>�%��K�K��>�>����� � �,� -��!�!��*�*�2�.�E��K�K�+�e�A�h�Z�q��q�� �;�<��r+c��|j�|jS|j�}djdj|��S)Nz<{}>� )rr6�format�join)r$r4s r)�__repr__zHandle.__repr__?s9���:�:�!��:�:����� ���}�}�S�X�X�d�^�,�,r+c��|jS�N)r�r$s r)�get_contextzHandle.get_contextEs���}�}�r+c��|js@d|_|jj�rt|�|_d|_d|_yy)NT)rrr �reprrrrr>s r)�cancelz Handle.cancelHs@�����"�D�O��z�z�#�#�%�"�$�Z�� �!�D�N��D�J�r+c��|jSr=)rr>s r)r-zHandle.cancelledSs�����r+c�� |jj|jg|j���d}y#tt f$r�t$rw}tj|j|j�}d|��}|||d�}|jr|j|d<|jj|�Yd}~d}yd}~wwxYw)NzException in callback )�message� exception�handle�source_traceback)r�runrr� SystemExit�KeyboardInterrupt� BaseExceptionrr3rr�call_exception_handler)r$�exc�cb�msgr(s r)�_runzHandle._runVs��� 7��D�M�M���d�n�n�:�t�z�z�:�����-�.� ��� 7��7�7����� � �,�B�*�2�$�/�C�� ���G� �%�%�.2�.D�.D��*�+��J�J�-�-�g�6�6���� 7�s�16�C�A+C�Cr=)r1� __module__�__qualname__�__doc__� __slots__r*r6r;r?rBr-rQ�r+r)rrs/��;��I� *� �-�� ��r+rc�j��eZdZdZddgZd�fd� Z�fd�Zd�Zd�Zd�Z d �Z d �Zd�Z�fd�Z d �Z�xZS)rz7Object returned by timed callback registration methods.� _scheduled�_whenc�x��t�|�||||�|jr |jd=||_d|_y)Nr.F)�superr*rrYrX)r$�whenr%r&r'r(r0s �r)r*zTimerHandle.__init__os;��� ����4��w�7��!�!��&�&�r�*��� ���r+c���t�|��}|jrdnd}|j|d|j���|S)N�rzwhen=)r[r6r�insertrY)r$r4�posr0s �r)r6zTimerHandle._repr_infovs;����w�!�#���?�?�a������C�5�����-�.��r+c�,�t|j�Sr=)�hashrYr>s r)�__hash__zTimerHandle.__hash__|s���D�J�J��r+c�`�t|t�r|j|jkStSr=�� isinstancerrY�NotImplemented�r$�others r)�__lt__zTimerHandle.__lt__�%���e�[�)��:�:����+�+��r+c��t|t�r,|j|jkxs|j|�StSr=�rfrrY�__eq__rgrhs r)�__le__zTimerHandle.__le__��3���e�[�)��:�:����+�A�t�{�{�5�/A�A��r+c�`�t|t�r|j|jkDStSr=rerhs r)�__gt__zTimerHandle.__gt__�rkr+c��t|t�r,|j|jkDxs|j|�StSr=rmrhs r)�__ge__zTimerHandle.__ge__�rpr+c��t|t�rj|j|jk(xrO|j|jk(xr4|j|jk(xr|j |j k(StSr=)rfrrYrrrrgrhs r)rnzTimerHandle.__eq__�sl���e�[�)��J�J�%�+�+�-�8��N�N�e�o�o�5�8��J�J�%�+�+�-�8��O�O�u�'7�'7�7� 9��r+c�p��|js|jj|�t�|��yr=)rr�_timer_handle_cancelledr[rB)r$r0s �r)rBzTimerHandle.cancel�s&�������J�J�.�.�t�4� ���r+c��|jS)z�Return a scheduled callback time. The time is an absolute timestamp, using the same time reference as loop.time(). )rYr>s r)r\zTimerHandle.when�s���z�z�r+r=)r1rRrSrTrUr*r6rcrjrorrrtrnrBr\� __classcell__)r0s@r)rrjsB���A��w�'�I� �� �� � � � �� r+rc�@�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zy )rz,Abstract server returned by create_server().c��t�)z5Stop serving. This leaves existing connections open.��NotImplementedErrorr>s r)�closezAbstractServer.close����!�!r+c��t�)z4Get the event loop the Server object is attached to.r|r>s r)�get_loopzAbstractServer.get_loop�rr+c��t�)z3Return True if the server is accepting connections.r|r>s r)� is_servingzAbstractServer.is_serving�rr+c��K�t��w)z�Start accepting connections. This method is idempotent, so it can be called when the server is already being serving. r|r>s r)� start_servingzAbstractServer.start_serving������"�!��� c��K�t��w)z�Start accepting connections until the coroutine is cancelled. The server is closed when the coroutine is cancelled. r|r>s r)� serve_foreverzAbstractServer.serve_forever������ "�!�r�c��K�t��w)z*Coroutine to wait until service is closed.r|r>s r)�wait_closedzAbstractServer.wait_closed������!�!�r�c��K�|S�wr=rVr>s r)� __aenter__zAbstractServer.__aenter__�s������s�c��`K�|j�|j��d{���y7��wr=)r~r�)r$rNs r)� __aexit__zAbstractServer.__aexit__�s!����� � ����� � � �s�$.�,�.N)r1rRrSrTr~r�r�r�r�r�r�r�rVr+r)rr�s-��6�"�"�"�"�"�"��!r+rc ���eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zdd�d �Z dd�d�Zdd�d�Zd�Zd�Zddd�d�Zdd�d�Zd�Zd�Zddddd�d�ZdJd�Z dKdddddddddddd�d�Z dKej4ej6ddddddddd� d �ZdLdd!�d"�Zd#dddd$�d%�Z dMdddddd&�d'�Z dMddddddd(�d)�Z dddd*�d+�Z! dKdddddddd,�d-�Z"d.�Z#d/�Z$e%jLe%jLe%jLd0�d1�Z'e%jLe%jLe%jLd0�d2�Z(d3�Z)d4�Z*d5�Z+d6�Z,d7�Z-d8�Z.d9�Z/dJd:�Z0d;�Z1d<�Z2d=�Z3d>�Z4dLdd!�d?�Z5d@�Z6dA�Z7dB�Z8dC�Z9dD�Z:dE�Z;dF�Z<dG�Z=dH�Z>dI�Z?y)NrzAbstract event loop.c��t�)z*Run the event loop until stop() is called.r|r>s r)�run_foreverzAbstractEventLoop.run_forever�rr+c��t�)zpRun the event loop until a Future is done. Return the Future's result, or raise its exception. r|)r$�futures r)�run_until_completez$AbstractEventLoop.run_until_complete�s �� "�!r+c��t�)z�Stop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. r|r>s r)�stopzAbstractEventLoop.stop�s ��"�!r+c��t�)z3Return whether the event loop is currently running.r|r>s r)� is_runningzAbstractEventLoop.is_running�rr+c��t�)z*Returns True if the event loop was closed.r|r>s r)� is_closedzAbstractEventLoop.is_closed�rr+c��t�)z�Close the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. r|r>s r)r~zAbstractEventLoop.close�s ��"�!r+c��K�t��w)z,Shutdown all active asynchronous generators.r|r>s r)�shutdown_asyncgensz$AbstractEventLoop.shutdown_asyncgens�r�r�c��K�t��w)z.Schedule the shutdown of the default executor.r|r>s r)�shutdown_default_executorz+AbstractEventLoop.shutdown_default_executorr�r�c��t�)z3Notification that a TimerHandle has been cancelled.r|)r$rGs r)rwz)AbstractEventLoop._timer_handle_cancelledrr+N)r(c�0�|jd|g|��d|i�S)Nrr()� call_later�r$r%r(r&s r)� call_soonzAbstractEventLoop.call_soons���t���q�(�C�T�C�7�C�Cr+c��t�r=r|)r$�delayr%r(r&s r)r�zAbstractEventLoop.call_later���!�!r+c��t�r=r|)r$r\r%r(r&s r)�call_atzAbstractEventLoop.call_atr�r+c��t�r=r|r>s r)�timezAbstractEventLoop.timer�r+c��t�r=r|r>s r)� create_futurezAbstractEventLoop.create_futurer�r+)�namer(c��t�r=r|)r$�coror�r(s r)�create_taskzAbstractEventLoop.create_taskr�r+c��t�r=r|r�s r)�call_soon_threadsafez&AbstractEventLoop.call_soon_threadsafe"r�r+c��t�r=r|)r$�executor�funcr&s r)�run_in_executorz!AbstractEventLoop.run_in_executor%r�r+c��t�r=r|)r$r�s r)�set_default_executorz&AbstractEventLoop.set_default_executor(r�r+r)�family�type�proto�flagsc��K�t��wr=r|)r$�host�portr�r�r�r�s r)�getaddrinfozAbstractEventLoop.getaddrinfo-r�r�c��K�t��wr=r|)r$�sockaddrr�s r)�getnameinfozAbstractEventLoop.getnameinfo1�����!�!�r�)�sslr�r�r��sock� local_addr�server_hostname�ssl_handshake_timeout�ssl_shutdown_timeout�happy_eyeballs_delay� interleavec��K�t��wr=r|)r$�protocol_factoryr�r�r�r�r�r�r�r�r�r�r�r�r�s r)�create_connectionz#AbstractEventLoop.create_connection4s����"�!�r��dT) r�r�r��backlogr�� reuse_address� reuse_portr�r�r�c ��K�t��w)a#A coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. ssl_handshake_timeout is the time in seconds that an SSL server will wait for completion of the SSL handshake before aborting the connection. Default is 60s. ssl_shutdown_timeout is the time in seconds that an SSL server will wait for completion of the SSL shutdown procedure before aborting the connection. Default is 30s. start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. r|)r$r�r�r�r�r�r�r�r�r�r�r�r�r�s r)� create_serverzAbstractEventLoop.create_server>s����p"�!�r�)�fallbackc��K�t��w)zRSend a file through a transport. Return an amount of sent bytes. r|)r$� transport�file�offset�countr�s r)�sendfilezAbstractEventLoop.sendfilexr�r�F)�server_sider�r�r�c��K�t��w)z|Upgrade a transport to TLS. Return a new transport that *protocol* should start using immediately. r|)r$r��protocol� sslcontextr�r�r�r�s r)� start_tlszAbstractEventLoop.start_tls�s����"�!�r�)r�r�r�r�r�c��K�t��wr=r|)r$r��pathr�r�r�r�r�s r)�create_unix_connectionz(AbstractEventLoop.create_unix_connection�r�r�)r�r�r�r�r�r�c��K�t��w)aWA coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file system path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. ssl_handshake_timeout is the time in seconds that an SSL server will wait for the SSL handshake to complete (defaults to 60s). ssl_shutdown_timeout is the time in seconds that an SSL server will wait for the SSL shutdown to finish (defaults to 30s). start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. r|) r$r�r�r�r�r�r�r�r�s r)�create_unix_serverz$AbstractEventLoop.create_unix_server�s����D"�!�r�)r�r�r�c��K�t��w)aHandle an accepted connection. This is used by servers that accept connections outside of asyncio, but use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. r|)r$r�r�r�r�r�s r)�connect_accepted_socketz)AbstractEventLoop.connect_accepted_socket�s����"�!�r�)r�r�r�r�r��allow_broadcastr�c��K�t��w)a�A coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. r|)r$r�r��remote_addrr�r�r�r�r�r�r�s r)�create_datagram_endpointz*AbstractEventLoop.create_datagram_endpoint�s����B"�!�r�c��K�t��w)aRegister read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.r|�r$r��pipes r)�connect_read_pipez#AbstractEventLoop.connect_read_pipe������"�!�r�c��K�t��w)aRegister write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.r|r�s r)�connect_write_pipez$AbstractEventLoop.connect_write_pipe�r�r�)�stdin�stdout�stderrc��K�t��wr=r|)r$r��cmdr�r�r��kwargss r)�subprocess_shellz"AbstractEventLoop.subprocess_shellr�r�c��K�t��wr=r|)r$r�r�r�r�r&r�s r)�subprocess_execz!AbstractEventLoop.subprocess_exec r�r�c��t�r=r|�r$�fdr%r&s r)� add_readerzAbstractEventLoop.add_readerr�r+c��t�r=r|�r$rs r)� remove_readerzAbstractEventLoop.remove_readerr�r+c��t�r=r|rs r)� add_writerzAbstractEventLoop.add_writerr�r+c��t�r=r|rs r)� remove_writerzAbstractEventLoop.remove_writer"r�r+c��K�t��wr=r|)r$r��nbytess r)� sock_recvzAbstractEventLoop.sock_recv'r�r�c��K�t��wr=r|)r$r��bufs r)�sock_recv_intoz AbstractEventLoop.sock_recv_into*r�r�c��K�t��wr=r|)r$r��bufsizes r)� sock_recvfromzAbstractEventLoop.sock_recvfrom-r�r�c��K�t��wr=r|)r$r�rr s r)�sock_recvfrom_intoz$AbstractEventLoop.sock_recvfrom_into0r�r�c��K�t��wr=r|)r$r��datas r)�sock_sendallzAbstractEventLoop.sock_sendall3r�r�c��K�t��wr=r|)r$r�r�addresss r)�sock_sendtozAbstractEventLoop.sock_sendto6r�r�c��K�t��wr=r|)r$r�rs r)�sock_connectzAbstractEventLoop.sock_connect9r�r�c��K�t��wr=r|)r$r�s r)�sock_acceptzAbstractEventLoop.sock_accept<r�r�c��K�t��wr=r|)r$r�r�r�r�r�s r)� sock_sendfilezAbstractEventLoop.sock_sendfile?r�r�c��t�r=r|)r$�sigr%r&s r)�add_signal_handlerz$AbstractEventLoop.add_signal_handlerEr�r+c��t�r=r|)r$r$s r)�remove_signal_handlerz'AbstractEventLoop.remove_signal_handlerHr�r+c��t�r=r|)r$�factorys r)�set_task_factoryz"AbstractEventLoop.set_task_factoryMr�r+c��t�r=r|r>s r)�get_task_factoryz"AbstractEventLoop.get_task_factoryPr�r+c��t�r=r|r>s r)�get_exception_handlerz'AbstractEventLoop.get_exception_handlerUr�r+c��t�r=r|)r$�handlers r)�set_exception_handlerz'AbstractEventLoop.set_exception_handlerXr�r+c��t�r=r|�r$r(s r)�default_exception_handlerz+AbstractEventLoop.default_exception_handler[r�r+c��t�r=r|r3s r)rMz(AbstractEventLoop.call_exception_handler^r�r+c��t�r=r|r>s r)r zAbstractEventLoop.get_debugcr�r+c��t�r=r|)r$�enableds r)� set_debugzAbstractEventLoop.set_debugfr�r+)r�NN)rNr=)@r1rRrSrTr�r�r�r�r�r~r�r�rwr�r�r�r�r�r�r�r�r�r�r�r��socket� AF_UNSPEC� AI_PASSIVEr�r�r�r�r�r�r�r�r�� subprocess�PIPEr�rrrr rrrrrrrrr r"r%r'r*r,r.r1r4rMr r9rVr+r)rr�s?���"�"�"�"�"� "�"�"�"�26�D�:>�"�6:�"�"�"� )-�d�"� =A�"�"�"�"#��!�1�"�"�59�"�����$�4� �"&�!%�!%�$�"�59�8"��&�&��#�#�$���D�T�"&�!%��8"�t"�#'�"�%*�(,�.2�-1� "�*.�"��4� �"&�!%�"�*.�""��s��"&�!%��""�L�"&�!%� "� EI�!"�./�q��59�d�7;�$� !"�J"�"�&0�_�_�&0�o�o�&0�o�o�"�%/�O�O�%/�_�_�%/�_�_�"�"�"�"�"� "�"�"�"�"�"�"�"�"�(,�"�"�"� "�"� "�"�"�"� "�"r+rc�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)rz-Abstract policy for accessing the event loop.c��t�)a>Get the event loop for the current context. Returns an event loop object implementing the AbstractEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.r|r>s r)r z&AbstractEventLoopPolicy.get_event_loopms ��"�!r+c��t�)z3Set the event loop for the current context to loop.r|�r$r's r)r z&AbstractEventLoopPolicy.set_event_loopwrr+c��t�)z�Create and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.r|r>s r)rz&AbstractEventLoopPolicy.new_event_loop{s ��"�!r+c��t�)z$Get the watcher for child processes.r|r>s r)rz)AbstractEventLoopPolicy.get_child_watcher�rr+c��t�)z$Set the watcher for child processes.r|)r$�watchers r)r z)AbstractEventLoopPolicy.set_child_watcher�rr+N) r1rRrSrTr r rrr rVr+r)rrjs��7�"�"�"�"�"r+rc�V�eZdZdZdZGd�dej�Zd�Zd�Z d�Z d�Zy) �BaseDefaultEventLoopPolicya�Default policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). Nc��eZdZdZdZy)�!BaseDefaultEventLoopPolicy._LocalNF)r1rRrSr�_set_calledrVr+r)�_LocalrK�s�����r+rMc�.�|j�|_yr=)rM�_localr>s r)r*z#BaseDefaultEventLoopPolicy.__init__�s���k�k�m��r+c��|jj��|jjs�tj�tj �ur�d} t jd�}|rG|jjd�}|dk(s|jd�sn|j}|dz }|r�F ddl }|jdt|� �|j!|j#��|jj�*t%d tj�j&z��|jjS#t$rY��wxYw)zvGet the event loop for the current context. Returns an instance of EventLoop or raises an exception. Nr^rr1�asynciozasyncio.rzThere is no current event loop)� stacklevelz,There is no current event loop in thread %r.)rOrrL� threading�current_thread�main_threadr"r#� f_globals�get� startswith�f_back�AttributeError�warnings�warn�DeprecationWarningr r�RuntimeErrorr�)r$rR�f�moduler[s r)r z)BaseDefaultEventLoopPolicy.get_event_loop�s/�� �K�K���%��K�K�+�+��(�(�*�i�.C�.C�.E�E��J� $��M�M�!�$����[�[�_�_�Z�8�F�"�i�/�6�3D�3D�Z�3P�����A��!�O�J�� ��M�M�:�,�� � E����� 3� 3� 5�6��;�;���$��M�!*�!9�!9�!;�!@�!@� A�B� B��{�{� � � ��)"� �� �s�E� E�Ec��d|j_|�2t|t�s"t dt|�j�d���||j_y)zSet the event loop.TNz<loop must be an instance of AbstractEventLoop or None, not '�')rOrLrfr� TypeErrorr�r1rrCs r)r z)BaseDefaultEventLoopPolicy.set_event_loop�sN��"&�������J�t�5F�$G��Z�[_�`d�[e�[n�[n�Zo�op�q�r�r� ����r+c�"�|j�S)zvCreate a new event loop. You must call set_event_loop() to make this the current event loop. )� _loop_factoryr>s r)rz)BaseDefaultEventLoopPolicy.new_event_loop�s���!�!�#�#r+)r1rRrSrTrerS�localrMr*r r rrVr+r)rIrI�s3�� ��M������$�!�B!�$r+rIc��eZdZdZy)�_RunningLoopr:N)r1rRrS�loop_pidrVr+r)rhrh�s���Hr+rhc�4�t�}|�td��|S)zrReturn the running event loop. Raise a RuntimeError if there is none. This function is thread-specific. zno running event loop)rr^�r's r)rr�s"����D��|��2�3�3��Kr+c�b�tj\}}|�|tj�k(r|Syy)z�Return the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. N)� _running_loopri�os�getpid)�running_loop�pids r)rr�s5��&�.�.��L�#���C�2�9�9�;�$6���%7�r+c�B�|tj�ft_y)z�Set the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. N)rnrormrirks r)rr�s��#�B�I�I�K�0�M�r+c�`�t5t� ddlm}|�addd�y#1swYyxYw)Nr��DefaultEventLoopPolicy)�_lock�_event_loop_policy�rurts r)�_init_event_loop_policyrys!�� ��%�0�!7�!9�� ���s�$�-c�.�t� t�tS)z"Get the current event loop policy.)rwryrVr+r)rrs���!��!��r+c�p�|�2t|t�s"tdt|�j�d���|ay)zZSet the current event loop policy. If policy is None, the default policy is restored.NzDpolicy must be an instance of AbstractEventLoopPolicy or None, not 'rb)rfrrcr�r1rw)�policys r)rrs>�� ��*�V�5L�"M��^�_c�dj�_k�_t�_t�^u�uv�w�x�x��r+c�N�t�}|�|St�j�S)aGReturn an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. )rrr )�current_loops r)r r s*��%�&�L����� �"�1�1�3�3r+c�6�t�j|�y)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr rks r)r r 0s����*�*�4�0r+c�2�t�j�S)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rrrVr+r)rr5s�� �"�1�1�3�3r+c�2�t�j�S)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rrrVr+r)rr:s�� �"�4�4�6�6r+c�4�t�j|�S)zMEquivalent to calling get_event_loop_policy().set_child_watcher(watcher).)rr )rGs r)r r ?s��!�"�4�4�W�=�=r+)rrrr �forkc��t�tj�t_t d�tjd�y)Nr.)rwrIrMrOr�signal� set_wakeup_fdrVr+r)�on_forkr�]s0���)�(B�(I�(I�(K��%��$�����R� r+)�after_in_child)/rT�__all__rrnr�r;r>r"rSrxrrrrrrrIrw�Lockrvrfrhrmrrrryrrr r rrr �_py__get_running_loop�_py__set_running_loop�_py_get_running_loop�_py_get_event_loop�_asyncio�_c__get_running_loop�_c__set_running_loop�_c_get_running_loop�_c_get_event_loop�ImportError�hasattrr��register_at_forkrVr+r)�<module>r�s]��'� ��� � � �� ���J�J�Z<�&�<�~'!�'!�TT"�T"�n"�"�DD$�!8�D$�V�� � ������9�?�?���� � � �1�:�� � 4� 1� 4� 7� >�*��)��'��#�� '�<�<�-��,��*��&���2�v��!��B���w�/���� �� �s�>C3�3C;�:C;__pycache__/events.cpython-312.pyc000064400000107610151706172560013002 0ustar00� T��h�r���dZdZddlZddlZddlZddlZddlZddlZddlZddl m Z Gd�d�ZGd�d e�ZGd �d�Z Gd�d �ZGd�d�ZGd�de�Zdaej$�ZGd�dej(�Ze�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!eZ"eZ#eZ$eZ% ddl&mZmZmZmZeZ'eZ(eZ)eZ*e,ed �rd!�Z-ej\e-�"�yy#e+$rY�(wxYw)#z!Event loop and event loop policy.)�AbstractEventLoopPolicy�AbstractEventLoop�AbstractServer�Handle�TimerHandle�get_event_loop_policy�set_event_loop_policy�get_event_loop�set_event_loop�new_event_loop�get_child_watcher�set_child_watcher�_set_running_loop�get_running_loop�_get_running_loop�N�)�format_helpersc�@�eZdZdZdZdd�Zd�Zd�Zd�Zd�Z d �Z d �Zy)rz1Object returned by callback registration methods.)� _callback�_args� _cancelled�_loop�_source_traceback�_repr�__weakref__�_contextNc�"�|�tj�}||_||_||_||_d|_d|_|jj�r.tjtjd��|_ yd|_ y)NFr)�contextvars�copy_contextrrrrrr� get_debugr� extract_stack�sys� _getframer)�self�callback�args�loop�contexts �'/usr/lib64/python3.12/asyncio/events.py�__init__zHandle.__init__$sx���?�!�.�.�0�G��� ��� �!����� ������ ��:�:���!�%3�%A�%A�� � �a� �&"�D�"�&*�D�"�c�h�|jjg}|jr|jd�|j�9|jtj|j|j��|jr,|jd}|jd|d�d|d���|S)N� cancelled���zcreated at r�:r) � __class__�__name__r�appendrr�_format_callback_sourcerr)r$�info�frames r)� _repr_infozHandle._repr_info3s������'�'�(���?�?��K�K��$��>�>�%��K�K��>�>����� � �,� -��!�!��*�*�2�.�E��K�K�+�e�A�h�Z�q��q�� �;�<��r+c��|j�|jS|j�}djdj|��S)Nz<{}>� )rr6�format�join)r$r4s r)�__repr__zHandle.__repr__?s9���:�:�!��:�:����� ���}�}�S�X�X�d�^�,�,r+c��|jS�N)r�r$s r)�get_contextzHandle.get_contextEs���}�}�r+c��|js@d|_|jj�rt|�|_d|_d|_yy)NT)rrr �reprrrrr>s r)�cancelz Handle.cancelHs@�����"�D�O��z�z�#�#�%�"�$�Z�� �!�D�N��D�J�r+c��|jSr=)rr>s r)r-zHandle.cancelledSs�����r+c�� |jj|jg|j���d}y#tt f$r�t$rw}tj|j|j�}d|��}|||d�}|jr|j|d<|jj|�Yd}~d}yd}~wwxYw)NzException in callback )�message� exception�handle�source_traceback)r�runrr� SystemExit�KeyboardInterrupt� BaseExceptionrr3rr�call_exception_handler)r$�exc�cb�msgr(s r)�_runzHandle._runVs��� 7��D�M�M���d�n�n�:�t�z�z�:�����-�.� ��� 7��7�7����� � �,�B�*�2�$�/�C�� ���G� �%�%�.2�.D�.D��*�+��J�J�-�-�g�6�6���� 7�s�16�C�A+C�Cr=)r1� __module__�__qualname__�__doc__� __slots__r*r6r;r?rBr-rQ�r+r)rrs/��;��I� *� �-�� ��r+rc�j��eZdZdZddgZd�fd� Z�fd�Zd�Zd�Zd�Z d �Z d �Zd�Z�fd�Z d �Z�xZS)rz7Object returned by timed callback registration methods.� _scheduled�_whenc�x��t�|�||||�|jr |jd=||_d|_y)Nr.F)�superr*rrYrX)r$�whenr%r&r'r(r0s �r)r*zTimerHandle.__init__os;��� ����4��w�7��!�!��&�&�r�*��� ���r+c���t�|��}|jrdnd}|j|d|j���|S)N�rzwhen=)r[r6r�insertrY)r$r4�posr0s �r)r6zTimerHandle._repr_infovs;����w�!�#���?�?�a������C�5�����-�.��r+c�,�t|j�Sr=)�hashrYr>s r)�__hash__zTimerHandle.__hash__|s���D�J�J��r+c�`�t|t�r|j|jkStSr=�� isinstancerrY�NotImplemented�r$�others r)�__lt__zTimerHandle.__lt__�%���e�[�)��:�:����+�+��r+c��t|t�r,|j|jkxs|j|�StSr=�rfrrY�__eq__rgrhs r)�__le__zTimerHandle.__le__��3���e�[�)��:�:����+�A�t�{�{�5�/A�A��r+c�`�t|t�r|j|jkDStSr=rerhs r)�__gt__zTimerHandle.__gt__�rkr+c��t|t�r,|j|jkDxs|j|�StSr=rmrhs r)�__ge__zTimerHandle.__ge__�rpr+c��t|t�rj|j|jk(xrO|j|jk(xr4|j|jk(xr|j |j k(StSr=)rfrrYrrrrgrhs r)rnzTimerHandle.__eq__�sl���e�[�)��J�J�%�+�+�-�8��N�N�e�o�o�5�8��J�J�%�+�+�-�8��O�O�u�'7�'7�7� 9��r+c�p��|js|jj|�t�|��yr=)rr�_timer_handle_cancelledr[rB)r$r0s �r)rBzTimerHandle.cancel�s&�������J�J�.�.�t�4� ���r+c��|jS)z�Return a scheduled callback time. The time is an absolute timestamp, using the same time reference as loop.time(). )rYr>s r)r\zTimerHandle.when�s���z�z�r+r=)r1rRrSrTrUr*r6rcrjrorrrtrnrBr\� __classcell__)r0s@r)rrjsB���A��w�'�I� �� �� � � � �� r+rc�@�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zy )rz,Abstract server returned by create_server().c��t�)z5Stop serving. This leaves existing connections open.��NotImplementedErrorr>s r)�closezAbstractServer.close����!�!r+c��t�)z4Get the event loop the Server object is attached to.r|r>s r)�get_loopzAbstractServer.get_loop�rr+c��t�)z3Return True if the server is accepting connections.r|r>s r)� is_servingzAbstractServer.is_serving�rr+c��K�t��w)z�Start accepting connections. This method is idempotent, so it can be called when the server is already being serving. r|r>s r)� start_servingzAbstractServer.start_serving������"�!��� c��K�t��w)z�Start accepting connections until the coroutine is cancelled. The server is closed when the coroutine is cancelled. r|r>s r)� serve_foreverzAbstractServer.serve_forever������ "�!�r�c��K�t��w)z*Coroutine to wait until service is closed.r|r>s r)�wait_closedzAbstractServer.wait_closed������!�!�r�c��K�|S�wr=rVr>s r)� __aenter__zAbstractServer.__aenter__�s������s�c��`K�|j�|j��d{���y7��wr=)r~r�)r$rNs r)� __aexit__zAbstractServer.__aexit__�s!����� � ����� � � �s�$.�,�.N)r1rRrSrTr~r�r�r�r�r�r�r�rVr+r)rr�s-��6�"�"�"�"�"�"��!r+rc ���eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zdd�d �Z dd�d�Zdd�d�Zd�Zd�Zddd�d�Zdd�d�Zd�Zd�Zddddd�d�ZdJd�Z dKdddddddddddd�d�Z dKej4ej6ddddddddd� d �ZdLdd!�d"�Zd#dddd$�d%�Z dMdddddd&�d'�Z dMddddddd(�d)�Z dddd*�d+�Z! dKdddddddd,�d-�Z"d.�Z#d/�Z$e%jLe%jLe%jLd0�d1�Z'e%jLe%jLe%jLd0�d2�Z(d3�Z)d4�Z*d5�Z+d6�Z,d7�Z-d8�Z.d9�Z/dJd:�Z0d;�Z1d<�Z2d=�Z3d>�Z4dLdd!�d?�Z5d@�Z6dA�Z7dB�Z8dC�Z9dD�Z:dE�Z;dF�Z<dG�Z=dH�Z>dI�Z?y)NrzAbstract event loop.c��t�)z*Run the event loop until stop() is called.r|r>s r)�run_foreverzAbstractEventLoop.run_forever�rr+c��t�)zpRun the event loop until a Future is done. Return the Future's result, or raise its exception. r|)r$�futures r)�run_until_completez$AbstractEventLoop.run_until_complete�s �� "�!r+c��t�)z�Stop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. r|r>s r)�stopzAbstractEventLoop.stop�s ��"�!r+c��t�)z3Return whether the event loop is currently running.r|r>s r)� is_runningzAbstractEventLoop.is_running�rr+c��t�)z*Returns True if the event loop was closed.r|r>s r)� is_closedzAbstractEventLoop.is_closed�rr+c��t�)z�Close the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. r|r>s r)r~zAbstractEventLoop.close�s ��"�!r+c��K�t��w)z,Shutdown all active asynchronous generators.r|r>s r)�shutdown_asyncgensz$AbstractEventLoop.shutdown_asyncgens�r�r�c��K�t��w)z.Schedule the shutdown of the default executor.r|r>s r)�shutdown_default_executorz+AbstractEventLoop.shutdown_default_executorr�r�c��t�)z3Notification that a TimerHandle has been cancelled.r|)r$rGs r)rwz)AbstractEventLoop._timer_handle_cancelledrr+N)r(c�0�|jd|g|��d|i�S)Nrr()� call_later�r$r%r(r&s r)� call_soonzAbstractEventLoop.call_soons���t���q�(�C�T�C�7�C�Cr+c��t�r=r|)r$�delayr%r(r&s r)r�zAbstractEventLoop.call_later���!�!r+c��t�r=r|)r$r\r%r(r&s r)�call_atzAbstractEventLoop.call_atr�r+c��t�r=r|r>s r)�timezAbstractEventLoop.timer�r+c��t�r=r|r>s r)� create_futurezAbstractEventLoop.create_futurer�r+)�namer(c��t�r=r|)r$�coror�r(s r)�create_taskzAbstractEventLoop.create_taskr�r+c��t�r=r|r�s r)�call_soon_threadsafez&AbstractEventLoop.call_soon_threadsafe"r�r+c��t�r=r|)r$�executor�funcr&s r)�run_in_executorz!AbstractEventLoop.run_in_executor%r�r+c��t�r=r|)r$r�s r)�set_default_executorz&AbstractEventLoop.set_default_executor(r�r+r)�family�type�proto�flagsc��K�t��wr=r|)r$�host�portr�r�r�r�s r)�getaddrinfozAbstractEventLoop.getaddrinfo-r�r�c��K�t��wr=r|)r$�sockaddrr�s r)�getnameinfozAbstractEventLoop.getnameinfo1�����!�!�r�)�sslr�r�r��sock� local_addr�server_hostname�ssl_handshake_timeout�ssl_shutdown_timeout�happy_eyeballs_delay� interleavec��K�t��wr=r|)r$�protocol_factoryr�r�r�r�r�r�r�r�r�r�r�r�r�s r)�create_connectionz#AbstractEventLoop.create_connection4s����"�!�r��dT) r�r�r��backlogr�� reuse_address� reuse_portr�r�r�c ��K�t��w)a#A coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. ssl_handshake_timeout is the time in seconds that an SSL server will wait for completion of the SSL handshake before aborting the connection. Default is 60s. ssl_shutdown_timeout is the time in seconds that an SSL server will wait for completion of the SSL shutdown procedure before aborting the connection. Default is 30s. start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. r|)r$r�r�r�r�r�r�r�r�r�r�r�r�r�s r)� create_serverzAbstractEventLoop.create_server>s����p"�!�r�)�fallbackc��K�t��w)zRSend a file through a transport. Return an amount of sent bytes. r|)r$� transport�file�offset�countr�s r)�sendfilezAbstractEventLoop.sendfilexr�r�F)�server_sider�r�r�c��K�t��w)z|Upgrade a transport to TLS. Return a new transport that *protocol* should start using immediately. r|)r$r��protocol� sslcontextr�r�r�r�s r)� start_tlszAbstractEventLoop.start_tls�s����"�!�r�)r�r�r�r�r�c��K�t��wr=r|)r$r��pathr�r�r�r�r�s r)�create_unix_connectionz(AbstractEventLoop.create_unix_connection�r�r�)r�r�r�r�r�r�c��K�t��w)aWA coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file system path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. ssl_handshake_timeout is the time in seconds that an SSL server will wait for the SSL handshake to complete (defaults to 60s). ssl_shutdown_timeout is the time in seconds that an SSL server will wait for the SSL shutdown to finish (defaults to 30s). start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. r|) r$r�r�r�r�r�r�r�r�s r)�create_unix_serverz$AbstractEventLoop.create_unix_server�s����D"�!�r�)r�r�r�c��K�t��w)aHandle an accepted connection. This is used by servers that accept connections outside of asyncio, but use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. r|)r$r�r�r�r�r�s r)�connect_accepted_socketz)AbstractEventLoop.connect_accepted_socket�s����"�!�r�)r�r�r�r�r��allow_broadcastr�c��K�t��w)a�A coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. r|)r$r�r��remote_addrr�r�r�r�r�r�r�s r)�create_datagram_endpointz*AbstractEventLoop.create_datagram_endpoint�s����B"�!�r�c��K�t��w)aRegister read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.r|�r$r��pipes r)�connect_read_pipez#AbstractEventLoop.connect_read_pipe������"�!�r�c��K�t��w)aRegister write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.r|r�s r)�connect_write_pipez$AbstractEventLoop.connect_write_pipe�r�r�)�stdin�stdout�stderrc��K�t��wr=r|)r$r��cmdr�r�r��kwargss r)�subprocess_shellz"AbstractEventLoop.subprocess_shellr�r�c��K�t��wr=r|)r$r�r�r�r�r&r�s r)�subprocess_execz!AbstractEventLoop.subprocess_exec r�r�c��t�r=r|�r$�fdr%r&s r)� add_readerzAbstractEventLoop.add_readerr�r+c��t�r=r|�r$rs r)� remove_readerzAbstractEventLoop.remove_readerr�r+c��t�r=r|rs r)� add_writerzAbstractEventLoop.add_writerr�r+c��t�r=r|rs r)� remove_writerzAbstractEventLoop.remove_writer"r�r+c��K�t��wr=r|)r$r��nbytess r)� sock_recvzAbstractEventLoop.sock_recv'r�r�c��K�t��wr=r|)r$r��bufs r)�sock_recv_intoz AbstractEventLoop.sock_recv_into*r�r�c��K�t��wr=r|)r$r��bufsizes r)� sock_recvfromzAbstractEventLoop.sock_recvfrom-r�r�c��K�t��wr=r|)r$r�rr s r)�sock_recvfrom_intoz$AbstractEventLoop.sock_recvfrom_into0r�r�c��K�t��wr=r|)r$r��datas r)�sock_sendallzAbstractEventLoop.sock_sendall3r�r�c��K�t��wr=r|)r$r�r�addresss r)�sock_sendtozAbstractEventLoop.sock_sendto6r�r�c��K�t��wr=r|)r$r�rs r)�sock_connectzAbstractEventLoop.sock_connect9r�r�c��K�t��wr=r|)r$r�s r)�sock_acceptzAbstractEventLoop.sock_accept<r�r�c��K�t��wr=r|)r$r�r�r�r�r�s r)� sock_sendfilezAbstractEventLoop.sock_sendfile?r�r�c��t�r=r|)r$�sigr%r&s r)�add_signal_handlerz$AbstractEventLoop.add_signal_handlerEr�r+c��t�r=r|)r$r$s r)�remove_signal_handlerz'AbstractEventLoop.remove_signal_handlerHr�r+c��t�r=r|)r$�factorys r)�set_task_factoryz"AbstractEventLoop.set_task_factoryMr�r+c��t�r=r|r>s r)�get_task_factoryz"AbstractEventLoop.get_task_factoryPr�r+c��t�r=r|r>s r)�get_exception_handlerz'AbstractEventLoop.get_exception_handlerUr�r+c��t�r=r|)r$�handlers r)�set_exception_handlerz'AbstractEventLoop.set_exception_handlerXr�r+c��t�r=r|�r$r(s r)�default_exception_handlerz+AbstractEventLoop.default_exception_handler[r�r+c��t�r=r|r3s r)rMz(AbstractEventLoop.call_exception_handler^r�r+c��t�r=r|r>s r)r zAbstractEventLoop.get_debugcr�r+c��t�r=r|)r$�enableds r)� set_debugzAbstractEventLoop.set_debugfr�r+)r�NN)rNr=)@r1rRrSrTr�r�r�r�r�r~r�r�rwr�r�r�r�r�r�r�r�r�r�r�r��socket� AF_UNSPEC� AI_PASSIVEr�r�r�r�r�r�r�r�r�� subprocess�PIPEr�rrrr rrrrrrrrr r"r%r'r*r,r.r1r4rMr r9rVr+r)rr�s?���"�"�"�"�"� "�"�"�"�26�D�:>�"�6:�"�"�"� )-�d�"� =A�"�"�"�"#��!�1�"�"�59�"�����$�4� �"&�!%�!%�$�"�59�8"��&�&��#�#�$���D�T�"&�!%��8"�t"�#'�"�%*�(,�.2�-1� "�*.�"��4� �"&�!%�"�*.�""��s��"&�!%��""�L�"&�!%� "� EI�!"�./�q��59�d�7;�$� !"�J"�"�&0�_�_�&0�o�o�&0�o�o�"�%/�O�O�%/�_�_�%/�_�_�"�"�"�"�"� "�"�"�"�"�"�"�"�"�(,�"�"�"� "�"� "�"�"�"� "�"r+rc�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)rz-Abstract policy for accessing the event loop.c��t�)a>Get the event loop for the current context. Returns an event loop object implementing the AbstractEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.r|r>s r)r z&AbstractEventLoopPolicy.get_event_loopms ��"�!r+c��t�)z3Set the event loop for the current context to loop.r|�r$r's r)r z&AbstractEventLoopPolicy.set_event_loopwrr+c��t�)z�Create and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.r|r>s r)rz&AbstractEventLoopPolicy.new_event_loop{s ��"�!r+c��t�)z$Get the watcher for child processes.r|r>s r)rz)AbstractEventLoopPolicy.get_child_watcher�rr+c��t�)z$Set the watcher for child processes.r|)r$�watchers r)r z)AbstractEventLoopPolicy.set_child_watcher�rr+N) r1rRrSrTr r rrr rVr+r)rrjs��7�"�"�"�"�"r+rc�V�eZdZdZdZGd�dej�Zd�Zd�Z d�Z d�Zy) �BaseDefaultEventLoopPolicya�Default policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). Nc��eZdZdZdZy)�!BaseDefaultEventLoopPolicy._LocalNF)r1rRrSr�_set_calledrVr+r)�_LocalrK�s�����r+rMc�.�|j�|_yr=)rM�_localr>s r)r*z#BaseDefaultEventLoopPolicy.__init__�s���k�k�m��r+c��|jj��|jjs�tj�tj �ur�d} t jd�}|rG|jjd�}|dk(s|jd�sn|j}|dz }|r�F ddl }|jdt|� �|j!|j#��|jj�*t%d tj�j&z��|jjS#t$rY��wxYw)zvGet the event loop for the current context. Returns an instance of EventLoop or raises an exception. Nr^rr1�asynciozasyncio.rzThere is no current event loop)� stacklevelz,There is no current event loop in thread %r.)rOrrL� threading�current_thread�main_threadr"r#� f_globals�get� startswith�f_back�AttributeError�warnings�warn�DeprecationWarningr r�RuntimeErrorr�)r$rR�f�moduler[s r)r z)BaseDefaultEventLoopPolicy.get_event_loop�s/�� �K�K���%��K�K�+�+��(�(�*�i�.C�.C�.E�E��J� $��M�M�!�$����[�[�_�_�Z�8�F�"�i�/�6�3D�3D�Z�3P�����A��!�O�J�� ��M�M�:�,�� � E����� 3� 3� 5�6��;�;���$��M�!*�!9�!9�!;�!@�!@� A�B� B��{�{� � � ��)"� �� �s�E� E�Ec��d|j_|�2t|t�s"t dt|�j�d���||j_y)zSet the event loop.TNz<loop must be an instance of AbstractEventLoop or None, not '�')rOrLrfr� TypeErrorr�r1rrCs r)r z)BaseDefaultEventLoopPolicy.set_event_loop�sN��"&�������J�t�5F�$G��Z�[_�`d�[e�[n�[n�Zo�op�q�r�r� ����r+c�"�|j�S)zvCreate a new event loop. You must call set_event_loop() to make this the current event loop. )� _loop_factoryr>s r)rz)BaseDefaultEventLoopPolicy.new_event_loop�s���!�!�#�#r+)r1rRrSrTrerS�localrMr*r r rrVr+r)rIrI�s3�� ��M������$�!�B!�$r+rIc��eZdZdZy)�_RunningLoopr:N)r1rRrS�loop_pidrVr+r)rhrh�s���Hr+rhc�4�t�}|�td��|S)zrReturn the running event loop. Raise a RuntimeError if there is none. This function is thread-specific. zno running event loop)rr^�r's r)rr�s"����D��|��2�3�3��Kr+c�b�tj\}}|�|tj�k(r|Syy)z�Return the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. N)� _running_loopri�os�getpid)�running_loop�pids r)rr�s5��&�.�.��L�#���C�2�9�9�;�$6���%7�r+c�B�|tj�ft_y)z�Set the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. N)rnrormrirks r)rr�s��#�B�I�I�K�0�M�r+c�`�t5t� ddlm}|�addd�y#1swYyxYw)Nr��DefaultEventLoopPolicy)�_lock�_event_loop_policy�rurts r)�_init_event_loop_policyrys!�� ��%�0�!7�!9�� ���s�$�-c�.�t� t�tS)z"Get the current event loop policy.)rwryrVr+r)rrs���!��!��r+c�p�|�2t|t�s"tdt|�j�d���|ay)zZSet the current event loop policy. If policy is None, the default policy is restored.NzDpolicy must be an instance of AbstractEventLoopPolicy or None, not 'rb)rfrrcr�r1rw)�policys r)rrs>�� ��*�V�5L�"M��^�_c�dj�_k�_t�_t�^u�uv�w�x�x��r+c�N�t�}|�|St�j�S)aGReturn an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. )rrr )�current_loops r)r r s*��%�&�L����� �"�1�1�3�3r+c�6�t�j|�y)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr rks r)r r 0s����*�*�4�0r+c�2�t�j�S)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rrrVr+r)rr5s�� �"�1�1�3�3r+c�2�t�j�S)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rrrVr+r)rr:s�� �"�4�4�6�6r+c�4�t�j|�S)zMEquivalent to calling get_event_loop_policy().set_child_watcher(watcher).)rr )rGs r)r r ?s��!�"�4�4�W�=�=r+)rrrr �forkc��t�tj�t_t d�tjd�y)Nr.)rwrIrMrOr�signal� set_wakeup_fdrVr+r)�on_forkr�]s0���)�(B�(I�(I�(K��%��$�����R� r+)�after_in_child)/rT�__all__rrnr�r;r>r"rSrxrrrrrrrIrw�Lockrvrfrhrmrrrryrrr r rrr �_py__get_running_loop�_py__set_running_loop�_py_get_running_loop�_py_get_event_loop�_asyncio�_c__get_running_loop�_c__set_running_loop�_c_get_running_loop�_c_get_event_loop�ImportError�hasattrr��register_at_forkrVr+r)�<module>r�s]��'� ��� � � �� ���J�J�Z<�&�<�~'!�'!�TT"�T"�n"�"�DD$�!8�D$�V�� � ������9�?�?���� � � �1�:�� � 4� 1� 4� 7� >�*��)��'��#�� '�<�<�-��,��*��&���2�v��!��B���w�/���� �� �s�>C3�3C;�:C;__pycache__/exceptions.cpython-312.opt-1.pyc000064400000006013151706172560014611 0ustar00� T��h����dZdZGd�de�ZeZGd�de�ZGd�de�ZGd�d e �Z Gd �de�ZGd�d e�Zy)zasyncio exceptions.)�BrokenBarrierError�CancelledError�InvalidStateError�TimeoutError�IncompleteReadError�LimitOverrunError�SendfileNotAvailableErrorc��eZdZdZy)rz!The Future or Task was cancelled.N��__name__� __module__�__qualname__�__doc__���+/usr/lib64/python3.12/asyncio/exceptions.pyrr s��+rrc��eZdZdZy)rz+The operation is not allowed in this state.Nr rrrrrs��5rrc��eZdZdZy)rz~Sendfile syscall is not available. Raised if OS does not support sendfile syscall for given socket or file type. Nr rrrrrs��rrc�(��eZdZdZ�fd�Zd�Z�xZS)rz� Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) c�|��|�dn t|�}t�|� t|��d|�d��||_||_y)N� undefinedz bytes read on a total of z expected bytes)�repr�super�__init__�len�partial�expected)�selfrr� r_expected� __class__s �rrzIncompleteReadError.__init__$sE���$,�$4�[�$�x�.� � ���C��L�>�)C�&�<��8� 9���� �� rc�H�t|�|j|jffS�N)�typerr�rs r� __reduce__zIncompleteReadError.__reduce__+s���D�z�D�L�L�$�-�-�8�8�8r�rrr rrr$� __classcell__�rs@rrrs����!�9rrc�(��eZdZdZ�fd�Zd�Z�xZS)rz�Reached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. c�2��t�|�|�||_yr!)rr�consumed)r�messager*rs �rrzLimitOverrunError.__init__5s��� ����!� �� rc�N�t|�|jd|jffS)N�)r"�argsr*r#s rr$zLimitOverrunError.__reduce__9s"���D�z�D�I�I�a�L�$�-�-�8�8�8rr%r's@rrr/s���� !�9rrc��eZdZdZy)rz*Barrier is broken by barrier.abort() call.Nr rrrrr=s��4rrN) r�__all__� BaseExceptionrr� Exceptionr�RuntimeErrorr�EOFErrorrrrrrr�<module>r5s^���(��,�]�,���6� �6����9�(�9�$9� �9�5��5r__pycache__/exceptions.cpython-312.pyc000064400000006013151706172560013652 0ustar00� T��h����dZdZGd�de�ZeZGd�de�ZGd�de�ZGd�d e �Z Gd �de�ZGd�d e�Zy)zasyncio exceptions.)�BrokenBarrierError�CancelledError�InvalidStateError�TimeoutError�IncompleteReadError�LimitOverrunError�SendfileNotAvailableErrorc��eZdZdZy)rz!The Future or Task was cancelled.N��__name__� __module__�__qualname__�__doc__���+/usr/lib64/python3.12/asyncio/exceptions.pyrr s��+rrc��eZdZdZy)rz+The operation is not allowed in this state.Nr rrrrrs��5rrc��eZdZdZy)rz~Sendfile syscall is not available. Raised if OS does not support sendfile syscall for given socket or file type. Nr rrrrrs��rrc�(��eZdZdZ�fd�Zd�Z�xZS)rz� Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) c�|��|�dn t|�}t�|� t|��d|�d��||_||_y)N� undefinedz bytes read on a total of z expected bytes)�repr�super�__init__�len�partial�expected)�selfrr� r_expected� __class__s �rrzIncompleteReadError.__init__$sE���$,�$4�[�$�x�.� � ���C��L�>�)C�&�<��8� 9���� �� rc�H�t|�|j|jffS�N)�typerr�rs r� __reduce__zIncompleteReadError.__reduce__+s���D�z�D�L�L�$�-�-�8�8�8r�rrr rrr$� __classcell__�rs@rrrs����!�9rrc�(��eZdZdZ�fd�Zd�Z�xZS)rz�Reached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. c�2��t�|�|�||_yr!)rr�consumed)r�messager*rs �rrzLimitOverrunError.__init__5s��� ����!� �� rc�N�t|�|jd|jffS)N�)r"�argsr*r#s rr$zLimitOverrunError.__reduce__9s"���D�z�D�I�I�a�L�$�-�-�8�8�8rr%r's@rrr/s���� !�9rrc��eZdZdZy)rz*Barrier is broken by barrier.abort() call.Nr rrrrr=s��4rrN) r�__all__� BaseExceptionrr� Exceptionr�RuntimeErrorr�EOFErrorrrrrrr�<module>r5s^���(��,�]�,���6� �6����9�(�9�$9� �9�5��5r__pycache__/format_helpers.cpython-312.pyc000064400000007435151706172560014514 0ustar00� T��hd ��Z�ddlZddlZddlZddlZddlZddlmZd�Zd�Zd�Z d d�Z d d�Zy)�N�)� constantsc�\�tj|�}tj|�r$|j}|j|j fSt |tj�rt|j�St |tj�rt|j�Sy�N)�inspect�unwrap� isfunction�__code__�co_filename�co_firstlineno� isinstance� functools�partial�_get_function_source�func� partialmethod)r�codes �//usr/lib64/python3.12/asyncio/format_helpers.pyrr s���>�>�$��D����$���}�}��� � �$�"5�"5�6�6��$� �)�)�*�#�D�I�I�.�.��$� �/�/�0�#�D�I�I�.�.��c�\�t||d�}t|�}|r|d|d�d|d��z }|S)Nz at r�:r)�_format_callbackr)r�args� func_repr�sources r�_format_callback_sourcersB�� ��t�T�2�I� !�$� '�F� ��t�F�1�I�;�a��q� �{�3�3� ��rc���g}|r|jd�|D��|r&|jd�|j�D��djdj|��S)z�Format function arguments and keyword arguments. Special case for a single parameter: ('hello',) is formatted as ('hello'). c3�FK�|]}tj|����y�wr��reprlib�repr)�.0�args r� <genexpr>z*_format_args_and_kwargs.<locals>.<genexpr>&s����7�$�3�W�\�\�#�&�$�s�!c3�VK�|]!\}}|�dtj|������#y�w)�=Nr)r"�k�vs rr$z*_format_args_and_kwargs.<locals>.<genexpr>(s)����I�.�$�!�Q��s�!�G�L�L��O�,�-�.�s�')z({})z, )�extend�items�format�join)r�kwargsr*s r�_format_args_and_kwargsr.sQ�� �E�� ���7�$�7�7� � ���I�&�,�,�.�I�I��=�=����5�)�*�*rc��t|tj�r;t||�|z}t |j |j|j|�St|d�r|jr |j}n0t|d�r|jr |j}nt|�}|t||�z }|r||z }|S)N�__qualname__�__name__)r rrr.rrr�keywords�hasattrr0r1r!)rrr-�suffixrs rrr,s����$� �)�)�*�(��v�6��?���� � �4�9�9�d�m�m�V�L�L��t�^�$��):�):��%�%� � ��z� "�t�}�}��M�M� ���J� � �(��v�6�6�I� ��V�� ��rc���|�tj�j}|�tj}t jjtj|�|d��}|j�|S)zlReplacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. F)�limit�lookup_lines) �sys� _getframe�f_backr�DEBUG_STACK_DEPTH� traceback�StackSummary�extract� walk_stack�reverse)�fr6�stacks r� extract_stackrC>sj�� �y��M�M�O�"�"���}��+�+���"�"�*�*�9�+?�+?��+B�16�8=� +� ?�E� �M�M�O��Lr)�)NN)rrr r8r<rDrrrr.rrC�rr�<module>rFs0����� ��� ��+��$r__pycache__/futures.cpython-312.opt-2.pyc000064400000032401151706172560014126 0ustar00� T��h8��h� dZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlmZddlmZe jZ e jZe jZe j Zej"dz ZGd �d �ZeZd�Zd�Zd �Zd�Zd�Zd�Zdd�d�Z ddlZej&xZZy#e$rYywxYw))�Future�wrap_future�isfuture�N)�GenericAlias�)�base_futures)�events)� exceptions)�format_helpersc���eZdZ eZdZdZdZdZdZ dZ dZdZdd�d�Z d�Zd�Zee�Zed��Zej*d��Zd �Zd �Zdd�Zd�Zd �Zd�Zd�Zd�Zdd�d�Zd�Zd�Z d�Z!d�Z"e"Z#y)rNF��loopc��� |�tj�|_n||_g|_|jj �r.tjtjd��|_ yy)Nr) r �get_event_loop�_loop� _callbacks� get_debugr� extract_stack�sys� _getframe�_source_traceback��selfrs �(/usr/lib64/python3.12/asyncio/futures.py�__init__zFuture.__init__Hs`�� ��<��.�.�0�D�J��D�J�����:�:���!�%3�%A�%A�� � �a� �&"�D�"�"�c�,�tj|�S�N)r�_future_repr�rs r�__repr__zFuture.__repr__Xs���(�(��.�.rc���|jsy|j}|jj�d�||d�}|jr|j|d<|j j |�y)Nz exception was never retrieved)�message� exception�future�source_traceback)�_Future__log_traceback� _exception� __class__�__name__rr�call_exception_handler)r�exc�contexts r�__del__zFuture.__del__[sl���#�#� ��o�o���>�>�*�*�+�+I�J��� ���!�!�*.�*@�*@�G�&�'�� � �)�)�'�2rc��|jSr)r'r s r�_log_tracebackzFuture._log_tracebackms���#�#�#rc�,�|rtd��d|_y)Nz'_log_traceback can only be set to FalseF)� ValueErrorr')r�vals rr0zFuture._log_tracebackqs����F�G�G�$��rc�:� |j}|�td��|S)Nz!Future object is not initialized.)r�RuntimeErrorrs r�get_loopzFuture.get_loopws$��;��z�z���<��B�C�C��rc�� |j�|j}d|_|S|j�tj�}ntj|j�}|j|_d|_|Sr)�_cancelled_exc�_cancel_messager �CancelledError�__context__)rr,s r�_make_cancelled_errorzFuture._make_cancelled_error~sw�� � ���*��%�%�C�"&�D���J����'��+�+�-�C��+�+�D�,@�,@�A�C��-�-���"���� rc�� d|_|jtk7ryt|_||_|j�y)NFT)r'�_state�_PENDING� _CANCELLEDr9�_Future__schedule_callbacks)r�msgs r�cancelz Future.cancel�s>�� � %����;�;�(�"�� ���"����!�!�#�rc�� |jdd}|syg|jdd|D]#\}}|jj|||���%y�N�r-)rr� call_soon)r� callbacks�callback�ctxs r�__schedule_callbackszFuture.__schedule_callbacks�sR�� � �O�O�A�&� ���������&�M�H�c��J�J� � ��4�� �=�'rc�*� |jtk(Sr)r>r@r s r� cancelledzFuture.cancelled�s��6��{�{�j�(�(rc�*� |jtk7Sr)r>r?r s r�donezFuture.done�s�� � �{�{�h�&�&rc�"� |jtk(r|j��|jtk7rt j d��d|_|j�%|jj|j��|jS)NzResult is not ready.F)r>r@r<� _FINISHEDr �InvalidStateErrorr'r(�with_traceback� _exception_tb�_resultr s r�resultz Future.result�sy�� ��;�;�*�$��,�,�.�.��;�;�)�#��.�.�/E�F�F�$����?�?�&��/�/�0�0��1C�1C�D�D��|�|�rc�� |jtk(r|j��|jtk7rt j d��d|_|jS)NzException is not set.F)r>r@r<rQr rRr'r(r s rr$zFuture.exception�sT�� ��;�;�*�$��,�,�.�.��;�;�)�#��.�.�/F�G�G�$������rrFc��� |jtk7r|jj|||��y|�t j �}|jj||f�yrE)r>r?rrG�contextvars�copy_contextr�append)r�fnr-s r�add_done_callbackzFuture.add_done_callback�sW�� ��;�;�(�"��J�J� � ��T�7� �;���%�2�2�4���O�O�"�"�B��=�1rc��� |jD��cgc]\}}||k7r||f��}}}t|j�t|�z }|r||jdd|Scc}}wr)r�len)rr\�frJ�filtered_callbacks� removed_counts r�remove_done_callbackzFuture.remove_done_callback�ss�� � /3�o�o�*�.=�(�1�c�!"�b�� !�#�h�.=� �*��D�O�O�,�s�3E�/F�F� ��!3�D�O�O�A����� *s�Ac�� |jtk7r$tj|j�d|����||_t |_|j �y)N�: )r>r?r rRrUrQrA)rrVs r� set_resultzFuture.set_result�sO�� � �;�;�(�"��.�.�$�+�+��b���/I�J�J��������!�!�#rc�l� |jtk7r$tj|j�d|����t |t �r|�}t |t�rtd�}||_||_ |}||_ |j|_t|_|j�d|_y)NrezPStopIteration interacts badly with generators and cannot be raised into a FutureT)r>r?r rR� isinstance�type� StopIterationr5� __cause__r;r(� __traceback__rTrQrAr')rr$�new_excs r� set_exceptionzFuture.set_exceptions��� � �;�;�(�"��.�.�$�+�+��b���/I�J�J��i��&�!��I��i��/�"�$,�-�G�!*�G��"+�G���I�#���&�4�4�������!�!�#�#��rc#�K�|j�sd|_|��|j�std��|j�S�w)NTzawait wasn't used with future)rO�_asyncio_future_blockingr5rVr s r� __await__zFuture.__await__s=�����y�y�{�,0�D�)��J��y�y�{��>�?�?��{�{�}��s�AA r)$r*� __module__�__qualname__r?r>rUr(rrr9r8rpr'rr!r.�classmethodr�__class_getitem__�propertyr0�setterr6r<rCrArMrOrVr$r]rcrfrnrq�__iter__�rrrrs����&�F��G��J��E����O��N� %���O�#�"� /�3� $�L�1�� �$��$����%��%� ��( �>�)�'�� �04�2� � $�$�.��Hrrc�^� |j}|�S#t$rY|jSwxYwr)r6�AttributeErrorr)�futr6s r� _get_loopr}-s:����<�<���z���� ���9�9�� �s�� ,�,c�J� |j�ry|j|�yr)rMrf)r|rVs r�_set_result_unless_cancelledr9s��I� �}�}����N�N�6�rc�l�t|�}|tjjurt j|j �S|tjjurt j|j �S|tjjurt j|j �S|Sr)ri� concurrent�futuresr:r �args�TimeoutErrorrR)r,� exc_classs r�_convert_future_excr�@s����S� �I��J�&�&�5�5�5��(�(�#�(�(�3�3� �j�(�(�5�5� 5��&�&����1�1� �j�(�(�:�:� :��+�+�S�X�X�6�6�� rc�� |j�r|j�|j�sy|j�}|�|jt|��y|j �}|j|�yr)rMrC�set_running_or_notify_cancelr$rnr�rVrf)r��sourcer$rVs r�_set_concurrent_future_stater�Lsu��B� ����� ����2�:�2�2�4��� � �"�I��� � � � �!4�Y�!?�@������� ���f�%rc�� |j�ry|j�r|j�y|j�}|�|jt |��y|j�}|j |�yr)rMrCr$rnr�rVrf)r��destr$rVs r�_copy_future_stater�[sj��� �~�~��� ������� ��$�$�&� �� ����2�9�=�>��]�]�_�F��O�O�F�#rc������� t��s/t�tjj�std��t��s/t�tjj�std��t��rt ��nd�t��rt ��nd�d�����fd�}����fd�}�j|��j|�y)Nz(A future is required for source argumentz-A future is required for destination argumentc�L�t|�r t||�yt||�yr)rr�r�)r%�others r� _set_statez!_chain_future.<locals>._set_states���F���u�f�-�(���7rc���|j�r3����ur�j�y�j�j�yyr)rMrC�call_soon_threadsafe)�destination� dest_loopr��source_loops ���r�_call_check_cancelz)_chain_future.<locals>._call_check_cancel�s<���� � �"��"�k�Y�&>�� � ���0�0����?� #rc����j�r���j�ry����ur ��|�y�j�ry�j��|�yr)rM� is_closedr�)r�r�r�r�r�s ����r�_call_set_statez&_chain_future.<locals>._call_set_state�s[����!�!�#��%�)�*=�*=�*?���� �[� 8��{�F�+��"�"�$���*�*�:�{�F�Kr)rrhr�r�r� TypeErrorr}r])r�r�r�r�r�r�r�s`` @@@r� _chain_futurer�os������F��J�v�/9�/A�/A�/H�/H�%J��B�C�C��K� ��K�4>�4F�4F�4M�4M�*O��G�H�H�'/��'7�)�F�#�T�K�*2�;�*?� �+�&�T�I�8�@� L��!�!�"4�5� ���_�-rr c�� t|�r|S|�tj�}|j�}t ||�|Sr)rr r� create_futurer�)r%r� new_futures rrr�sE��0����� ��|��$�$�&���#�#�%�J��&�*�%��r)�__all__�concurrent.futuresr�rY�loggingr�typesr�rr r rrr?r@rQ�DEBUG�STACK_DEBUGr� _PyFuturer}rr�r�r�r�r�_asyncio�_CFuture�ImportErrorryrr�<module>r�s���4������ ������� � ��� � �� � $� $� ��"�"� ��m�m�a���H�H�X � � �� �&�$�().�X!%� �(�� !���'�F�X�� � �� �s�B)�)B1�0B1__pycache__/futures.cpython-312.pyc000064400000041634151706172560013176 0ustar00� T��h8��j�dZdZddlZddlZddlZddlZddlmZddl m Z ddl mZddl mZdd l m Z e jZe jZe j Ze j"Zej$dz ZGd �d�ZeZd�Zd �Zd�Zd�Zd�Zd�Zdd�d�Z ddlZej(xZZy#e$rYywxYw)z.A Future class similar to the one in PEP 3148.)�Future�wrap_future�isfuture�N)�GenericAlias�)�base_futures)�events)� exceptions)�format_helpersc���eZdZdZeZdZdZdZdZ dZ dZdZdZ dd�d�Zd�Zd�Zee�Zed��Zej,d ��Zd �Zd�Zdd�Zd �Zd�Zd�Zd�Zd�Zdd�d�Zd�Z d�Z!d�Z"d�Z#e#Z$y)ra,This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NF��loopc���|�tj�|_n||_g|_|jj �r.tjtjd��|_ yy)z�Initialize the future. The optional event_loop argument allows explicitly setting the event loop object used by the future. If it's not provided, the future uses the default event loop. Nr) r �get_event_loop�_loop� _callbacks� get_debugr� extract_stack�sys� _getframe�_source_traceback��selfrs �(/usr/lib64/python3.12/asyncio/futures.py�__init__zFuture.__init__Hs[���<��.�.�0�D�J��D�J�����:�:���!�%3�%A�%A�� � �a� �&"�D�"�"�c�,�tj|�S�N)r�_future_repr�rs r�__repr__zFuture.__repr__Xs���(�(��.�.rc���|jsy|j}|jj�d�||d�}|jr|j|d<|j j |�y)Nz exception was never retrieved)�message� exception�future�source_traceback)�_Future__log_traceback� _exception� __class__�__name__rr�call_exception_handler)r�exc�contexts r�__del__zFuture.__del__[sl���#�#� ��o�o���>�>�*�*�+�+I�J��� ���!�!�*.�*@�*@�G�&�'�� � �)�)�'�2rc��|jSr)r'r s r�_log_tracebackzFuture._log_tracebackms���#�#�#rc�,�|rtd��d|_y)Nz'_log_traceback can only be set to FalseF)� ValueErrorr')r�vals rr0zFuture._log_tracebackqs����F�G�G�$��rc�8�|j}|�td��|S)z-Return the event loop the Future is bound to.z!Future object is not initialized.)r�RuntimeErrorrs r�get_loopzFuture.get_loopws!���z�z���<��B�C�C��rc��|j�|j}d|_|S|j�tj�}ntj|j�}|j|_d|_|S)z�Create the CancelledError to raise if the Future is cancelled. This should only be called once when handling a cancellation since it erases the saved context exception value. N)�_cancelled_exc�_cancel_messager �CancelledError�__context__)rr,s r�_make_cancelled_errorzFuture._make_cancelled_error~sr�����*��%�%�C�"&�D���J����'��+�+�-�C��+�+�D�,@�,@�A�C��-�-���"���� rc�~�d|_|jtk7ryt|_||_|j�y)z�Cancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)r'�_state�_PENDING� _CANCELLEDr9�_Future__schedule_callbacks)r�msgs r�cancelz Future.cancel�s9�� %����;�;�(�"�� ���"����!�!�#�rc��|jdd}|syg|jdd|D]#\}}|jj|||���%y)z�Internal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. N�r-)rr� call_soon)r� callbacks�callback�ctxs r�__schedule_callbackszFuture.__schedule_callbacks�sM���O�O�A�&� ���������&�M�H�c��J�J� � ��4�� �=�'rc�(�|jtk(S)z(Return True if the future was cancelled.)r>r@r s r� cancelledzFuture.cancelled�s���{�{�j�(�(rc�(�|jtk7S)z�Return True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. )r>r?r s r�donezFuture.done�s���{�{�h�&�&rc� �|jtk(r|j��|jtk7rt j d��d|_|j�%|jj|j��|jS)aReturn the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. zResult is not ready.F)r>r@r<� _FINISHEDr �InvalidStateErrorr'r(�with_traceback� _exception_tb�_resultr s r�resultz Future.result�st���;�;�*�$��,�,�.�.��;�;�)�#��.�.�/E�F�F�$����?�?�&��/�/�0�0��1C�1C�D�D��|�|�rc��|jtk(r|j��|jtk7rt j d��d|_|jS)a&Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.F)r>r@r<rPr rQr'r(r s rr$zFuture.exception�sO���;�;�*�$��,�,�.�.��;�;�)�#��.�.�/F�G�G�$������rrEc���|jtk7r|jj|||��y|�t j �}|jj||f�y)z�Add a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. rEN)r>r?rrF�contextvars�copy_contextr�append)r�fnr-s r�add_done_callbackzFuture.add_done_callback�sR���;�;�(�"��J�J� � ��T�7� �;���%�2�2�4���O�O�"�"�B��=�1rc��|jD��cgc]\}}||k7r||f��}}}t|j�t|�z }|r||jdd|Scc}}w)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. N)r�len)rr[�frI�filtered_callbacks� removed_counts r�remove_done_callbackzFuture.remove_done_callback�sn��/3�o�o�*�.=�(�1�c�!"�b�� !�#�h�.=� �*��D�O�O�,�s�3E�/F�F� ��!3�D�O�O�A����� *s�Ac��|jtk7r$tj|j�d|����||_t |_|j �y)z�Mark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. �: N)r>r?r rQrTrPrA)rrUs r� set_resultzFuture.set_result�sJ���;�;�(�"��.�.�$�+�+��b���/I�J�J��������!�!�#rc�j�|jtk7r$tj|j�d|����t |t �r|�}t |t�rtd�}||_||_ |}||_ |j|_t|_|j�d|_y)z�Mark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. rdzPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r>r?r rQ� isinstance�type� StopIterationr5� __cause__r;r(� __traceback__rSrPrAr')rr$�new_excs r� set_exceptionzFuture.set_exceptions����;�;�(�"��.�.�$�+�+��b���/I�J�J��i��&�!��I��i��/�"�$,�-�G�!*�G��"+�G���I�#���&�4�4�������!�!�#�#��rc#�K�|j�sd|_|��|j�std��|j�S�w)NTzawait wasn't used with future)rN�_asyncio_future_blockingr5rUr s r� __await__zFuture.__await__s=�����y�y�{�,0�D�)��J��y�y�{��>�?�?��{�{�}��s�AA r)%r*� __module__�__qualname__�__doc__r?r>rTr(rrr9r8ror'rr!r.�classmethodr�__class_getitem__�propertyr0�setterr6r<rCrArLrNrUr$r\rbrermrp�__iter__�rrrrs����&�F��G��J��E����O��N� %���O�#�"� /�3� $�L�1�� �$��$����%��%� ��( �>�)�'�� �04�2� � $�$�.��Hrrc�^� |j}|�S#t$rY|jSwxYwr)r6�AttributeErrorr)�futr6s r� _get_loopr}-s:����<�<���z���� ���9�9�� �s�� ,�,c�H�|j�ry|j|�y)z?Helper setting the result only if the future was not cancelled.N)rLre)r|rUs r�_set_result_unless_cancelledr9s�� �}�}����N�N�6�rc�l�t|�}|tjjurt j|j �S|tjjurt j|j �S|tjjurt j|j �S|Sr)rh� concurrent�futuresr:r �args�TimeoutErrorrQ)r,� exc_classs r�_convert_future_excr�@s����S� �I��J�&�&�5�5�5��(�(�#�(�(�3�3� �j�(�(�5�5� 5��&�&����1�1� �j�(�(�:�:� :��+�+�S�X�X�6�6�� rc�.�|j�sJ�|j�r|j�|j�sy|j �}|�|j t |��y|j�}|j|�y)z8Copy state from a future to a concurrent.futures.Future.N) rNrLrC�set_running_or_notify_cancelr$rmr�rUre)r��sourcer$rUs r�_set_concurrent_future_stater�Ls����;�;�=��=� ����� ����2�:�2�2�4��� � �"�I��� � � � �!4�Y�!?�@������� ���f�%rc�L�|j�sJ�|j�ry|j�rJ�|j�r|j�y|j�}|�|j t|��y|j �}|j|�y)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N)rNrLrCr$rmr�rUre)r��destr$rUs r�_copy_future_stater�[s��� �;�;�=��=��~�~����y�y�{��?� ������� ��$�$�&� �� ����2�9�=�>��]�]�_�F��O�O�F�#rc�������t��s/t�tjj�std��t��s/t�tjj�std��t��rt ��nd�t��rt ��nd�d�����fd�}����fd�}�j|��j|�y)aChain two futures so that when one completes, so does the other. The result (or exception) of source will be copied to destination. If destination is cancelled, source gets cancelled too. Compatible with both asyncio.Future and concurrent.futures.Future. z(A future is required for source argumentz-A future is required for destination argumentNc�L�t|�r t||�yt||�yr)rr�r�)r%�others r� _set_statez!_chain_future.<locals>._set_states���F���u�f�-�(���7rc���|j�r3����ur�j�y�j�j�yyr)rLrC�call_soon_threadsafe)�destination� dest_loopr��source_loops ���r�_call_check_cancelz)_chain_future.<locals>._call_check_cancel�s<���� � �"��"�k�Y�&>�� � ���0�0����?� #rc����j�r���j�ry����ur ��|�y�j�ry�j��|�yr)rL� is_closedr�)r�r�r�r�r�s ����r�_call_set_statez&_chain_future.<locals>._call_set_state�s[����!�!�#��%�)�*=�*=�*?���� �[� 8��{�F�+��"�"�$���*�*�:�{�F�Kr)rrgr�r�r� TypeErrorr}r\)r�r�r�r�r�r�r�s`` @@@r� _chain_futurer�os�����F��J�v�/9�/A�/A�/H�/H�%J��B�C�C��K� ��K�4>�4F�4F�4M�4M�*O��G�H�H�'/��'7�)�F�#�T�K�*2�;�*?� �+�&�T�I�8�@� L��!�!�"4�5� ���_�-rr c���t|�r|St|tjj�s Jd|����|�tj�}|j�}t||�|S)z&Wrap concurrent.futures.Future object.z+concurrent.futures.Future is expected, got ) rrgr�r�rr r� create_futurer�)r%r� new_futures rrr�so������ ��f�j�0�0�7�7�8�A� 5�f�Z�@�A�8��|��$�$�&���#�#�%�J��&�*�%��r) rs�__all__�concurrent.futuresr�rX�loggingr�typesr�rr r rrr?r@rP�DEBUG�STACK_DEBUGr� _PyFuturer}rr�r�r�r�r�_asyncio�_CFuture�ImportErrorryrr�<module>r�s���4������ ������� � ��� � �� � $� $� ��"�"� ��m�m�a���H�H�X � � �� �&�$�().�X!%� �(�� !���'�F�X�� � �� �s�B*�*B2�1B2__pycache__/locks.cpython-312.opt-1.pyc000064400000065435151706172560013560 0ustar00� T��h3J��`�dZdZddlZddlZddlmZddlmZGd�d�ZGd �d eej�Z Gd�dej�Z Gd �deej�ZGd�deej�ZGd�de�Z Gd�dej�ZGd�dej�Zy)zSynchronization primitives.)�Lock�Event� Condition� Semaphore�BoundedSemaphore�Barrier�N�)� exceptions)�mixinsc��eZdZd�Zd�Zy)�_ContextManagerMixinc��@K�|j��d{���y7��w�N)�acquire��selfs �&/usr/lib64/python3.12/asyncio/locks.py� __aenter__z_ContextManagerMixin.__aenter__ s�����l�l�n���� �s���c��,K�|j�y�wr)�release)r�exc_type�exc�tbs r� __aexit__z_ContextManagerMixin.__aexit__s��������s�N)�__name__� __module__�__qualname__rr��rr r s���rr c�@��eZdZdZd�Z�fd�Zd�Zd�Zd�Zd�Z �xZ S)ra�Primitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'await'. Locks also support the asynchronous context management protocol. 'async with lock' statement should be used. Usage: lock = Lock() ... await lock.acquire() try: ... finally: lock.release() Context manager usage: lock = Lock() ... async with lock: ... Lock objects can be tested for locking state: if not lock.locked(): await lock.acquire() else: # lock is acquired ... c� �d|_d|_y�NF)�_waiters�_lockedrs r�__init__z Lock.__init__Ms���� ���rc���t�|��}|jrdnd}|jr|�dt |j���}d|dd�d|�d�S� N�locked�unlocked� , waiters:�<r ���� [�]>)�super�__repr__r$r#�len�r�res�extra� __class__s �rr0z Lock.__repr__QsY����g�� �� �L�L��j���=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)rc��|jS)z Return True if lock is acquired.)r$rs rr(zLock.lockedXs���|�|�rc��JK�|js0|j�td�|jD��rd|_y|j�tj�|_|j�j �}|jj|� |�d{���|jj|� d|_y7�(#|jj|�wxYw#tj$r|js|j��wxYw�w)z�Acquire a lock. This method blocks until the lock is unlocked, then sets it to locked and returns True. Nc3�<K�|]}|j����y�wr�� cancelled��.0�ws r� <genexpr>zLock.acquire.<locals>.<genexpr>cs����9�=�a�A�K�K�M�=�s�T)r$r#�all�collections�deque� _get_loop� create_future�append�remover �CancelledError�_wake_up_first�r�futs rrzLock.acquire\s��������$�-�-�"7��9�4�=�=�9�9��D�L���=�=� �'�-�-�/�D�M��n�n��,�,�.��� � ���S�!� � *�� � �� � �$�$�S�)�������� � �$�$�S�)���(�(� ��<�<��#�#�%�� �sB�BD#�C�$C �%C�)C/�D#� C�C,�,C/�/1D � D#c�`�|jrd|_|j�ytd��)aGRelease a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. FzLock is not acquired.N)r$rG�RuntimeErrorrs rrzLock.release|s*���<�<� �D�L����!��6�7�7rc��|jsy tt|j��}|j �s|jd�yy#t$rYywxYw)z*Wake up the first waiter if it isn't done.NT)r#�next�iter� StopIteration�done� set_resultrHs rrGzLock._wake_up_first�sT���}�}�� ��t�D�M�M�*�+�C��x�x�z��N�N�4� ��� � �� �s�A� A�A)rrr�__doc__r%r0r(rrrG� __classcell__�r5s@rrrs(���3�j�*���@8�" !rrc�@��eZdZdZd�Z�fd�Zd�Zd�Zd�Zd�Z �xZ S)ra#Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. c�D�tj�|_d|_yr")r@rAr#�_valuers rr%zEvent.__init__�s��#�)�)�+�� ���rc���t�|��}|jrdnd}|jr|�dt |j���}d|dd�d|�d�S) N�set�unsetr*r+r r,r-r.)r/r0rWr#r1r2s �rr0zEvent.__repr__�sY����g�� ������'���=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)rc��|jS)z5Return True if and only if the internal flag is true.�rWrs r�is_setzEvent.is_set�s���{�{�rc��|js;d|_|jD]$}|j�r�|jd��&yy)z�Set the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all. TN)rWr#rPrQrHs rrYz Event.set�s:�� �{�{��D�K��}�}���x�x�z��N�N�4�(�%�rc��d|_y)z�Reset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.FNr\rs r�clearzEvent.clear�s����rc��*K�|jry|j�j�}|jj |� |�d{��� |jj|�y7�!#|jj|�wxYw�w)z�Block until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. TN)rWrBrCr#rDrErHs r�waitz Event.wait�st�����;�;���n�n��,�,�.��� � ���S�!� &��I�I���M�M� � ��%� �� �M�M� � ��%�s0�AB� A3�A1�A3�B�1A3�3B�B)rrrrRr%r0r]rYr`rbrSrTs@rrr�s&�����*�� )��&rrc�D��eZdZdZdd�Z�fd�Zd�Zd�Zd d�Zd�Z �xZ S) raAsynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more coroutines to wait until they are notified by another coroutine. A new Lock object is created and used as the underlying lock. c���|� t�}||_|j|_|j|_|j|_tj�|_yr)r�_lockr(rrr@rAr#)r�locks rr%zCondition.__init__�sF���<��6�D��� ��k�k����|�|����|�|���#�)�)�+�� rc���t�|��}|j�rdnd}|jr|�dt |j���}d|dd�d|�d�Sr')r/r0r(r#r1r2s �rr0zCondition.__repr__�s[����g�� �� �K�K�M��z���=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)rc��K�|j�std��|j� |j�j �}|j j |� |�d{��� |j j|�d} |j��d{��� |rtj�y7�P7�#tj$rd}YnwxYw�M#|j j|�wxYw#d} |j��d{���7n#tj$rd}YnwxYw�7|rtj�wxYw�w)a�Wait until notified. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another coroutine. Once awakened, it re-acquires the lock and returns True. zcannot wait on un-acquired lockNFT)r(rKrrBrCr#rDrErr rF)rrIr:s rrbzCondition.wait�s@�����{�{�}��@�A�A����� 0��.�.�"�0�0�2�C��M�M� � ��%� *�� � ��� � �$�$�S�)��I��%��,�,�.�(�(��� �/�/�/����)��!�0�0�%� $�I�%�� ��� � �$�$�S�)���I��%��,�,�.�(�(���!�0�0�%� $�I�%�� �� �/�/�/��s��,E�9C?�)C�.B?�/C�4C?�E�C�&C�'C�+E�?C�C�C�E�C�E�C<�<C?�?E �D�D�D�E �D6�3E �5D6�6E � Ec��hK�|�}|s"|j��d{���|�}|s�"|S7��w)z�Wait until a predicate becomes true. The predicate should be a callable which result will be interpreted as a boolean value. The final predicate value is the return value. N�rb)r� predicate�results r�wait_forzCondition.wait_fors9���������)�)�+����[�F��� � �s�2�0� 2�2c��|j�std��d}|jD]0}||k\ry|j�r�|dz }|j d��2y)aBy default, wake up one coroutine waiting on this condition, if any. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the coroutines waiting for the condition variable; it is a no-op if no coroutines are waiting. Note: an awakened coroutine does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. z!cannot notify on un-acquired lockrr FN)r(rKr#rPrQ)r�n�idxrIs r�notifyzCondition.notify)sT���{�{�}��B�C�C����=�=�C��a�x���8�8�:��q������u�%� !rc�L�|jt|j��y)aWake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. N)rqr1r#rs r� notify_allzCondition.notify_allAs�� ���C�� � �&�'rr�r )rrrrRr%r0rbrmrqrsrSrTs@rrr�s'���� ,�*�#0�J�&�0(rrc�B��eZdZdZdd�Z�fd�Zd�Zd�Zd�Zd�Z �xZ S) raA Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. c�@�|dkrtd��d|_||_y)Nrz$Semaphore initial value must be >= 0)� ValueErrorr#rW)r�values rr%zSemaphore.__init__Ys#���1�9��C�D�D��� ���rc����t�|��}|j�rdnd|j��}|jr|�dt|j���}d|dd�d|�d�S) Nr(zunlocked, value:r*r+r r,r-r.)r/r0r(rWr#r1r2s �rr0zSemaphore.__repr___sg����g�� �� �K�K�M��1A�$�+�+��/O���=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)rc�d�|jdk(xs td�|jxsdD��S)z9Returns True if semaphore cannot be acquired immediately.rc3�>K�|]}|j����y�wrr9r;s rr>z#Semaphore.locked.<locals>.<genexpr>is����A�,?�a�A�K�K�M�!�,?�s�r)rW�anyr#rs rr(zSemaphore.lockedfs4���{�{�a��C��A�D�M�M�,?�R�,?�A�A� Crc��K�|j�s|xjdzc_y|j�tj�|_|j�j �}|jj|� |�d{���|jj|� |jdkDr|j�y7�@#|jj|�wxYw#tj$r7|j�s%|xjdz c_|j��wxYw�w)a5Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. r TNr) r(rWr#r@rArBrCrDrEr rFr:� _wake_up_nextrHs rrzSemaphore.acquireks������{�{�}��K�K�1��K���=�=� �'�-�-�/�D�M��n�n��,�,�.��� � ���S�!� � *�� � �� � �$�$�S�)��;�;��?���� ����� � �$�$�S�)���(�(� ��=�=�?����q� ���"�"�$�� �sC�BD>� C�C�C�C1�.!D>�C�C.�.C1�1A D;�;D>c�N�|xjdz c_|j�y)z�Release a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. r N)rWr~rs rrzSemaphore.release�s�� ���q������rc��|jsy|jD]:}|j�r�|xjdzc_|jd�yy)z)Wake up the first waiter that isn't done.Nr T)r#rPrWrQrHs rr~zSemaphore._wake_up_next�s@���}�}���=�=�C��8�8�:����q� �����t�$�� !rrt)rrrrRr%r0r(rrr~rSrTs@rrrJs(�����*�C� "�H� rrc�.��eZdZdZd�fd� Z�fd�Z�xZS)rz�A bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. c�2��||_t�|� |�yr)�_bound_valuer/r%)rrxr5s �rr%zBoundedSemaphore.__init__�s���!��� ����rc�j��|j|jk\rtd��t�|��y)Nz(BoundedSemaphore released too many times)rWr�rwr/r)rr5s �rrzBoundedSemaphore.release�s+����;�;�$�+�+�+��G�H�H� ���rrt)rrrrRr%rrSrTs@rrr�s���� ��rrc��eZdZdZdZdZdZy)� _BarrierState�filling�draining� resetting�brokenN)rrr�FILLING�DRAINING� RESETTING�BROKENrrrr�r��s���G��H��I� �Frr�c���eZdZdZd�Z�fd�Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zd�Z d�Zed ��Zed��Zed��Z�xZS)ra Asyncio equivalent to threading.Barrier Implements a Barrier primitive. Useful for synchronizing a fixed number of tasks at known synchronization points. Tasks block on 'wait()' and are simultaneously awoken once they have all made their call. c��|dkrtd��t�|_||_tj |_d|_y)z1Create a barrier, initialised to 'parties' tasks.r zparties must be >= 1rN)rwr�_cond�_partiesr�r��_state�_count)r�partiess rr%zBarrier.__init__�s9���Q�;��3�4�4��[�� ��� �#�+�+�����rc���t�|��}|jj�}|js|d|j �d|j��z }d|dd�d|�d�S)Nr*�/r+r r,r-r.)r/r0r�rxr�� n_waitingr�r2s �rr0zBarrier.__repr__�sd����g�� ���;�;�$�$�%���{�{��z�$�.�.�!1��4�<�<�.�A�A�E��3�q��9�+�R��w�b�)�)rc��>K�|j��d{���S7��wrrjrs rrzBarrier.__aenter__�s�����Y�Y�[� � � �s���c��K�y�wrr)r�argss rrzBarrier.__aexit__�s �����s�c��0K�|j4�d{���|j��d{��� |j}|xjdz c_|dz|jk(r|j ��d{���n|j��d{���||xjdzc_|j �cddd��d{���S7��7��7�Y7�B7� #|xjdzc_|j �wxYw#1�d{���7swYyxYw�w)z�Wait for the barrier. When the specified number of tasks have started waiting, they are all simultaneously awoken. Returns an unique and individual index number from 0 to 'parties-1'. Nr )r��_blockr�r��_release�_wait�_exit)r�indexs rrbzBarrier.wait�s������:�:�:��+�+�-��� ��������q� ���1�9�� � �-��-�-�/�)�)��*�*�,�&�&�����q� ��� � ���:�:����*��&�������q� ��� � ����:�:�s��D�C �D�D�C�D�AC�7C�8C�C�C�%D�;D�C�D�D�C�C�D�'C>�>D�D�D �D�Dc���K��jj�fd���d{����jtjurtjd��y7�6�w)Nc�\���jtjtjfvSr)r�r�r�r�rs�r�<lambda>z Barrier._block.<locals>.<lambda>�s$���D�K�K��&�&� �(?�(?�(�rzBarrier aborted)r�rmr�r�r�r �BrokenBarrierErrorrs`rr�zBarrier._block�sZ������j�j�!�!� � � � ��;�;�-�.�.�.��/�/�0A�B�B�/� �s�"A�A�7Ac��jK�tj|_|jj �y�wr)r�r�r�r�rsrs rr�zBarrier._releases%���� $�,�,���� � ����s�13c����K��jj�fd���d{����jtjtj fvrt jd��y7�F�w)Nc�<���jtjuSr)r�r�r�rs�rr�zBarrier._wait.<locals>.<lambda>s���$�+�+�]�=R�=R�*RrzAbort or reset of barrier)r�rmr�r�r�r�r r�rs`rr�z Barrier._waits]������j�j�!�!�"R�S�S�S��;�;�=�/�/��1H�1H�I�I��/�/�0K�L�L�J� T�s�"A.�A,�AA.c���|jdk(r\|jtjtjfvrtj |_|jj�yy)Nr)r�r�r�r�r�r�r�rsrs rr�z Barrier._exitsO���;�;�!���{�{�}�6�6� �8N�8N�O�O�+�3�3����J�J�!�!�#�rc��hK�|j4�d{���|jdkDr2|jtjur+tj|_ntj |_|jj �ddd��d{���y7��7�#1�d{���7swYyxYw�w)z�Reset the barrier to the initial state. Any tasks currently waiting will get the BrokenBarrier exception raised. Nr)r�r�r�r�r�r�rsrs r�resetz Barrier.reset"sk�����:�:�:��{�{�Q���;�;�m�&=�&=�=�"/�"9�"9�D�K�+�3�3����J�J�!�!�#��:�:��:��:�:�:�sE�B2�B�B2�A1B�B2�B�B2�B2�B/�#B&�$B/�+B2c���K�|j4�d{���tj|_|jj �ddd��d{���y7�D7�#1�d{���7swYyxYw�w)z�Place the barrier into a 'broken' state. Useful in case of error. Any currently waiting tasks and tasks attempting to 'wait()' will have BrokenBarrierError raised. N)r�r�r�r�rsrs r�abortz Barrier.abort1sA�����:�:�:�'�.�.�D�K��J�J�!�!�#��:�:��:��:�:�:�sD�A1�A�A1�0A�A1�A�A1�A1�A.�"A%�#A.�*A1c��|jS)z8Return the number of tasks required to trip the barrier.)r�rs rr�zBarrier.parties;s���}�}�rc�T�|jtjur|jSy)z<Return the number of tasks currently waiting at the barrier.r)r�r�r�r�rs rr�zBarrier.n_waiting@s#���;�;�-�/�/�/��;�;��rc�:�|jtjuS)z0Return True if the barrier is in a broken state.)r�r�r�rs rr�zBarrier.brokenGs���{�{�m�2�2�2�2r)rrrrRr%r0rrrbr�r�r�r�r�r��propertyr�r�r�rSrTs@rrr�s}���� �*�!� ��.C� � M�$� $�$����������3��3rr)rR�__all__r@�enum�r rr �_LoopBoundMixinrrrrr�Enumr�rrrr�<module>r�s���!�*��������C!���!7�!7�C!�L:&�F�"�"�:&�zm(�$�f�&<�&<�m(�`W�$�f�&<�&<�W�t�y��$�D�I�I��M3�f�$�$�M3r__pycache__/locks.cpython-312.opt-2.pyc000064400000047435151706172560013561 0ustar00� T��h3J��^� dZddlZddlZddlmZddlmZGd�d�ZGd�d eej�ZGd �dej�Z Gd�d eej�Z Gd�deej�ZGd�de�ZGd�dej�ZGd�dej�Zy))�Lock�Event� Condition� Semaphore�BoundedSemaphore�Barrier�N�)� exceptions)�mixinsc��eZdZd�Zd�Zy)�_ContextManagerMixinc��@K�|j��d{���y7��w�N)�acquire��selfs �&/usr/lib64/python3.12/asyncio/locks.py� __aenter__z_ContextManagerMixin.__aenter__ s�����l�l�n���� �s���c��,K�|j�y�wr)�release)r�exc_type�exc�tbs r� __aexit__z_ContextManagerMixin.__aexit__s��������s�N)�__name__� __module__�__qualname__rr��rr r s���rr c�>��eZdZ d�Z�fd�Zd�Zd�Zd�Zd�Z�xZ S)rc� �d|_d|_y�NF)�_waiters�_lockedrs r�__init__z Lock.__init__Ms���� ���rc���t�|��}|jrdnd}|jr|�dt |j���}d|dd�d|�d�S� N�locked�unlocked� , waiters:�<r ���� [�]>)�super�__repr__r$r#�len�r�res�extra� __class__s �rr0z Lock.__repr__QsY����g�� �� �L�L��j���=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)rc�� |jSr)r$rs rr(zLock.lockedXs��.��|�|�rc��LK� |js0|j�td�|jD��rd|_y|j�tj�|_|j�j �}|jj|� |�d{���|jj|� d|_y7�(#|jj|�wxYw#tj$r|js|j��wxYw�w)Nc3�<K�|]}|j����y�wr�� cancelled��.0�ws r� <genexpr>zLock.acquire.<locals>.<genexpr>cs����9�=�a�A�K�K�M�=�s�T)r$r#�all�collections�deque� _get_loop� create_future�append�remover �CancelledError�_wake_up_first�r�futs rrzLock.acquire\s����� � ���$�-�-�"7��9�4�=�=�9�9��D�L���=�=� �'�-�-�/�D�M��n�n��,�,�.��� � ���S�!� � *�� � �� � �$�$�S�)�������� � �$�$�S�)���(�(� ��<�<��#�#�%�� �sB�BD$� C�%C�&C�*C0�D$�C�C-�-C0�01D!�!D$c�b� |jrd|_|j�ytd��)NFzLock is not acquired.)r$rG�RuntimeErrorrs rrzLock.release|s/�� ��<�<� �D�L����!��6�7�7rc�� |jsy tt|j��}|j �s|jd�yy#t$rYywxYw�NT)r#�next�iter� StopIteration�done� set_resultrHs rrGzLock._wake_up_first�sW��8��}�}�� ��t�D�M�M�*�+�C��x�x�z��N�N�4� ��� � �� �s�A� A�A) rrrr%r0r(rrrG� __classcell__�r5s@rrrs(���3�j�*���@8�" !rrc�>��eZdZ d�Z�fd�Zd�Zd�Zd�Zd�Z�xZ S)rc�D�tj�|_d|_yr")r@rAr#�_valuers rr%zEvent.__init__�s��#�)�)�+�� ���rc���t�|��}|jrdnd}|jr|�dt |j���}d|dd�d|�d�S) N�set�unsetr*r+r r,r-r.)r/r0rWr#r1r2s �rr0zEvent.__repr__�sY����g�� ������'���=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)rc�� |jSr�rWrs r�is_setzEvent.is_set�s��C��{�{�rc�� |js;d|_|jD]$}|j�r�|jd��&yyrM)rWr#rQrRrHs rrYz Event.set�s?�� ��{�{��D�K��}�}���x�x�z��N�N�4�(�%�rc�� d|_yr"r\rs r�clearzEvent.clear�s�� ���rc��,K� |jry|j�j�}|jj |� |�d{��� |jj|�y7�!#|jj|�wxYw�wrM)rWrBrCr#rDrErHs r�waitz Event.wait�sy���� ��;�;���n�n��,�,�.��� � ���S�!� &��I�I���M�M� � ��%� �� �M�M� � ��%�s0�AB�A4�A2�A4�B�2A4�4B�B) rrrr%r0r]rYr`rbrSrTs@rrr�s&�����*�� )��&rrc�B��eZdZ dd�Z�fd�Zd�Zd�Zdd�Zd�Z�xZ S) rc���|� t�}||_|j|_|j|_|j|_tj�|_yr)r�_lockr(rrr@rAr#)r�locks rr%zCondition.__init__�sF���<��6�D��� ��k�k����|�|����|�|���#�)�)�+�� rc���t�|��}|j�rdnd}|jr|�dt |j���}d|dd�d|�d�Sr')r/r0r(r#r1r2s �rr0zCondition.__repr__�s[����g�� �� �K�K�M��z���=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)rc��K� |j�std��|j� |j�j �}|j j |� |�d{��� |j j|�d} |j��d{��� |rtj�y7�P7�#tj$rd}YnwxYw�M#|j j|�wxYw#d} |j��d{���7n#tj$rd}YnwxYw�7|rtj�wxYw�w)Nzcannot wait on un-acquired lockFT)r(rKrrBrCr#rDrErr rF)rrIr:s rrbzCondition.wait�sE���� ��{�{�}��@�A�A����� 0��.�.�"�0�0�2�C��M�M� � ��%� *�� � ��� � �$�$�S�)��I��%��,�,�.�(�(��� �/�/�/����)��!�0�0�%� $�I�%�� ��� � �$�$�S�)���I��%��,�,�.�(�(���!�0�0�%� $�I�%�� �� �/�/�/��s��-E�9D�*C �/C�0C �5D�E�C�'C�(C�,E�C �C�C�E�C�E� C=�=D�E�D�D�D�E�D7�4E�6D7�7E�Ec��jK� |�}|s"|j��d{���|�}|s�"|S7��wr�rb)r� predicate�results r�wait_forzCondition.wait_fors>���� ������)�)�+����[�F��� � �s�3�1� 3�3c�� |j�std��d}|jD]0}||k\ry|j�r�|dz }|j d��2y)Nz!cannot notify on un-acquired lockrr F)r(rKr#rQrR)r�n�idxrIs r�notifyzCondition.notify)sY�� ��{�{�}��B�C�C����=�=�C��a�x���8�8�:��q������u�%� !rc�N� |jt|j��yr)rqr1r#rs r� notify_allzCondition.notify_allAs�� � ���C�� � �&�'rr�r ) rrrr%r0rbrmrqrsrSrTs@rrr�s'���� ,�*�#0�J�&�0(rrc�@��eZdZ dd�Z�fd�Zd�Zd�Zd�Zd�Z�xZ S)rc�@�|dkrtd��d|_||_y)Nrz$Semaphore initial value must be >= 0)� ValueErrorr#rW)r�values rr%zSemaphore.__init__Ys#���1�9��C�D�D��� ���rc����t�|��}|j�rdnd|j��}|jr|�dt|j���}d|dd�d|�d�S) Nr(zunlocked, value:r*r+r r,r-r.)r/r0r(rWr#r1r2s �rr0zSemaphore.__repr___sg����g�� �� �K�K�M��1A�$�+�+��/O���=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)rc�f� |jdk(xs td�|jxsdD��S)Nrc3�>K�|]}|j����y�wrr9r;s rr>z#Semaphore.locked.<locals>.<genexpr>is����A�,?�a�A�K�K�M�!�,?�s�r)rW�anyr#rs rr(zSemaphore.lockedfs7��G��{�{�a��C��A�D�M�M�,?�R�,?�A�A� Crc��K� |j�s|xjdzc_y|j�tj�|_|j�j �}|jj|� |�d{���|jj|� |jdkDr|j�y7�@#|jj|�wxYw#tj$r7|j�s%|xjdz c_|j��wxYw�w)Nr Tr) r(rWr#r@rArBrCrDrEr rFr:� _wake_up_nextrHs rrzSemaphore.acquireks����� ��{�{�}��K�K�1��K���=�=� �'�-�-�/�D�M��n�n��,�,�.��� � ���S�!� � *�� � �� � �$�$�S�)��;�;��?���� ����� � �$�$�S�)���(�(� ��=�=�?����q� ���"�"�$�� �sC�BD?� C�C�C�C2�/!D?�C�C/�/C2�2A D<�<D?c�P� |xjdz c_|j�y�Nr )rWr~rs rrzSemaphore.release�s#�� � ���q������rc�� |jsy|jD]:}|j�r�|xjdzc_|jd�yy)Nr T)r#rQrWrRrHs rr~zSemaphore._wake_up_next�sC��7��}�}���=�=�C��8�8�:����q� �����t�$�� !rrt) rrrr%r0r(rrr~rSrTs@rrrJs(�����*�C� "�H� rrc�,��eZdZ d�fd� Z�fd�Z�xZS)rc�2��||_t�|� |�yr)�_bound_valuer/r%)rrxr5s �rr%zBoundedSemaphore.__init__�s���!��� ����rc�j��|j|jk\rtd��t�|��y)Nz(BoundedSemaphore released too many times)rWr�rwr/r)rr5s �rrzBoundedSemaphore.release�s+����;�;�$�+�+�+��G�H�H� ���rrt)rrrr%rrSrTs@rrr�s���� ��rrc��eZdZdZdZdZdZy)� _BarrierState�filling�draining� resetting�brokenN)rrr�FILLING�DRAINING� RESETTING�BROKENrrrr�r��s���G��H��I� �Frr�c���eZdZ d�Z�fd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zd�Z ed��Zed ��Zed��Z�xZS)rc�� |dkrtd��t�|_||_tj |_d|_y)Nr zparties must be >= 1r)rwr�_cond�_partiesr�r��_state�_count)r�partiess rr%zBarrier.__init__�s<��?��Q�;��3�4�4��[�� ��� �#�+�+�����rc���t�|��}|jj�}|js|d|j �d|j��z }d|dd�d|�d�S)Nr*�/r+r r,r-r.)r/r0r�rxr�� n_waitingr�r2s �rr0zBarrier.__repr__�sd����g�� ���;�;�$�$�%���{�{��z�$�.�.�!1��4�<�<�.�A�A�E��3�q��9�+�R��w�b�)�)rc��>K�|j��d{���S7��wrrjrs rrzBarrier.__aenter__�s�����Y�Y�[� � � �s���c��K�y�wrr)r�argss rrzBarrier.__aexit__�s �����s�c��2K� |j4�d{���|j��d{��� |j}|xjdz c_|dz|jk(r|j ��d{���n|j��d{���||xjdzc_|j �cddd��d{���S7��7��7�Y7�B7� #|xjdzc_|j �wxYw#1�d{���7swYyxYw�wr�)r��_blockr�r��_release�_wait�_exit)r�indexs rrbzBarrier.wait�s����� ��:�:�:��+�+�-��� ��������q� ���1�9�� � �-��-�-�/�)�)��*�*�,�&�&�����q� ��� � ���:�:����*��&�������q� ��� � ����:�:�s��D�C�D�D�C�D�AC�8C�9C�C�C�%D�<D�C� D�D�C�C�D�'C?�?D�D�D� D�Dc���K��jj�fd���d{����jtjurtjd��y7�6�w)Nc�\���jtjtjfvSr)r�r�r�r�rs�r�<lambda>z Barrier._block.<locals>.<lambda>�s$���D�K�K��&�&� �(?�(?�(�rzBarrier aborted)r�rmr�r�r�r �BrokenBarrierErrorrs`rr�zBarrier._block�sZ������j�j�!�!� � � � ��;�;�-�.�.�.��/�/�0A�B�B�/� �s�"A�A�7Ac��jK�tj|_|jj �y�wr)r�r�r�r�rsrs rr�zBarrier._releases%���� $�,�,���� � ����s�13c����K��jj�fd���d{����jtjtj fvrt jd��y7�F�w)Nc�<���jtjuSr)r�r�r�rs�rr�zBarrier._wait.<locals>.<lambda>s���$�+�+�]�=R�=R�*RrzAbort or reset of barrier)r�rmr�r�r�r�r r�rs`rr�z Barrier._waits]������j�j�!�!�"R�S�S�S��;�;�=�/�/��1H�1H�I�I��/�/�0K�L�L�J� T�s�"A.�A,�AA.c���|jdk(r\|jtjtjfvrtj |_|jj�yy�Nr)r�r�r�r�r�r�r�rsrs rr�z Barrier._exitsO���;�;�!���{�{�}�6�6� �8N�8N�O�O�+�3�3����J�J�!�!�#�rc��jK� |j4�d{���|jdkDr2|jtjur+tj|_ntj |_|jj �ddd��d{���y7��7�#1�d{���7swYyxYw�wr�)r�r�r�r�r�r�rsrs r�resetz Barrier.reset"sp���� � �:�:�:��{�{�Q���;�;�m�&=�&=�=�"/�"9�"9�D�K�+�3�3����J�J�!�!�#��:�:��:��:�:�:�sE�B3�B�B3�A1B� B3�B�B3�B3�B0�$B'�%B0�,B3c���K� |j4�d{���tj|_|jj �ddd��d{���y7�D7�#1�d{���7swYyxYw�wr)r�r�r�r�rsrs r�abortz Barrier.abort1sF���� � �:�:�:�'�.�.�D�K��J�J�!�!�#��:�:��:��:�:�:�sD�A2�A�A2�0A�A2�A�A2�A2�A/�#A&�$A/�+A2c�� |jSr)r�rs rr�zBarrier.parties;s��F��}�}�rc�V� |jtjur|jSyr�)r�r�r�r�rs rr�zBarrier.n_waiting@s$��J��;�;�-�/�/�/��;�;��rc�<� |jtjuSr)r�r�r�rs rr�zBarrier.brokenGs��>��{�{�m�2�2�2�2r)rrrr%r0rrrbr�r�r�r�r�r��propertyr�r�r�rSrTs@rrr�s}���� �*�!� ��.C� � M�$� $�$����������3��3rr)�__all__r@�enum�r rr �_LoopBoundMixinrrrrr�Enumr�rrrr�<module>r�s���!�*��������C!���!7�!7�C!�L:&�F�"�"�:&�zm(�$�f�&<�&<�m(�`W�$�f�&<�&<�W�t�y��$�D�I�I��M3�f�$�$�M3r__pycache__/locks.cpython-312.pyc000064400000065435151706172560012621 0ustar00� T��h3J��`�dZdZddlZddlZddlmZddlmZGd�d�ZGd �d eej�Z Gd�dej�Z Gd �deej�ZGd�deej�ZGd�de�Z Gd�dej�ZGd�dej�Zy)zSynchronization primitives.)�Lock�Event� Condition� Semaphore�BoundedSemaphore�Barrier�N�)� exceptions)�mixinsc��eZdZd�Zd�Zy)�_ContextManagerMixinc��@K�|j��d{���y7��w�N)�acquire��selfs �&/usr/lib64/python3.12/asyncio/locks.py� __aenter__z_ContextManagerMixin.__aenter__ s�����l�l�n���� �s���c��,K�|j�y�wr)�release)r�exc_type�exc�tbs r� __aexit__z_ContextManagerMixin.__aexit__s��������s�N)�__name__� __module__�__qualname__rr��rr r s���rr c�@��eZdZdZd�Z�fd�Zd�Zd�Zd�Zd�Z �xZ S)ra�Primitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'await'. Locks also support the asynchronous context management protocol. 'async with lock' statement should be used. Usage: lock = Lock() ... await lock.acquire() try: ... finally: lock.release() Context manager usage: lock = Lock() ... async with lock: ... Lock objects can be tested for locking state: if not lock.locked(): await lock.acquire() else: # lock is acquired ... c� �d|_d|_y�NF)�_waiters�_lockedrs r�__init__z Lock.__init__Ms���� ���rc���t�|��}|jrdnd}|jr|�dt |j���}d|dd�d|�d�S� N�locked�unlocked� , waiters:�<r ���� [�]>)�super�__repr__r$r#�len�r�res�extra� __class__s �rr0z Lock.__repr__QsY����g�� �� �L�L��j���=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)rc��|jS)z Return True if lock is acquired.)r$rs rr(zLock.lockedXs���|�|�rc��JK�|js0|j�td�|jD��rd|_y|j�tj�|_|j�j �}|jj|� |�d{���|jj|� d|_y7�(#|jj|�wxYw#tj$r|js|j��wxYw�w)z�Acquire a lock. This method blocks until the lock is unlocked, then sets it to locked and returns True. Nc3�<K�|]}|j����y�wr�� cancelled��.0�ws r� <genexpr>zLock.acquire.<locals>.<genexpr>cs����9�=�a�A�K�K�M�=�s�T)r$r#�all�collections�deque� _get_loop� create_future�append�remover �CancelledError�_wake_up_first�r�futs rrzLock.acquire\s��������$�-�-�"7��9�4�=�=�9�9��D�L���=�=� �'�-�-�/�D�M��n�n��,�,�.��� � ���S�!� � *�� � �� � �$�$�S�)�������� � �$�$�S�)���(�(� ��<�<��#�#�%�� �sB�BD#�C�$C �%C�)C/�D#� C�C,�,C/�/1D � D#c�`�|jrd|_|j�ytd��)aGRelease a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. FzLock is not acquired.N)r$rG�RuntimeErrorrs rrzLock.release|s*���<�<� �D�L����!��6�7�7rc��|jsy tt|j��}|j �s|jd�yy#t$rYywxYw)z*Wake up the first waiter if it isn't done.NT)r#�next�iter� StopIteration�done� set_resultrHs rrGzLock._wake_up_first�sT���}�}�� ��t�D�M�M�*�+�C��x�x�z��N�N�4� ��� � �� �s�A� A�A)rrr�__doc__r%r0r(rrrG� __classcell__�r5s@rrrs(���3�j�*���@8�" !rrc�@��eZdZdZd�Z�fd�Zd�Zd�Zd�Zd�Z �xZ S)ra#Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. c�D�tj�|_d|_yr")r@rAr#�_valuers rr%zEvent.__init__�s��#�)�)�+�� ���rc���t�|��}|jrdnd}|jr|�dt |j���}d|dd�d|�d�S) N�set�unsetr*r+r r,r-r.)r/r0rWr#r1r2s �rr0zEvent.__repr__�sY����g�� ������'���=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)rc��|jS)z5Return True if and only if the internal flag is true.�rWrs r�is_setzEvent.is_set�s���{�{�rc��|js;d|_|jD]$}|j�r�|jd��&yy)z�Set the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all. TN)rWr#rPrQrHs rrYz Event.set�s:�� �{�{��D�K��}�}���x�x�z��N�N�4�(�%�rc��d|_y)z�Reset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.FNr\rs r�clearzEvent.clear�s����rc��*K�|jry|j�j�}|jj |� |�d{��� |jj|�y7�!#|jj|�wxYw�w)z�Block until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. TN)rWrBrCr#rDrErHs r�waitz Event.wait�st�����;�;���n�n��,�,�.��� � ���S�!� &��I�I���M�M� � ��%� �� �M�M� � ��%�s0�AB� A3�A1�A3�B�1A3�3B�B)rrrrRr%r0r]rYr`rbrSrTs@rrr�s&�����*�� )��&rrc�D��eZdZdZdd�Z�fd�Zd�Zd�Zd d�Zd�Z �xZ S) raAsynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more coroutines to wait until they are notified by another coroutine. A new Lock object is created and used as the underlying lock. c���|� t�}||_|j|_|j|_|j|_tj�|_yr)r�_lockr(rrr@rAr#)r�locks rr%zCondition.__init__�sF���<��6�D��� ��k�k����|�|����|�|���#�)�)�+�� rc���t�|��}|j�rdnd}|jr|�dt |j���}d|dd�d|�d�Sr')r/r0r(r#r1r2s �rr0zCondition.__repr__�s[����g�� �� �K�K�M��z���=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)rc��K�|j�std��|j� |j�j �}|j j |� |�d{��� |j j|�d} |j��d{��� |rtj�y7�P7�#tj$rd}YnwxYw�M#|j j|�wxYw#d} |j��d{���7n#tj$rd}YnwxYw�7|rtj�wxYw�w)a�Wait until notified. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another coroutine. Once awakened, it re-acquires the lock and returns True. zcannot wait on un-acquired lockNFT)r(rKrrBrCr#rDrErr rF)rrIr:s rrbzCondition.wait�s@�����{�{�}��@�A�A����� 0��.�.�"�0�0�2�C��M�M� � ��%� *�� � ��� � �$�$�S�)��I��%��,�,�.�(�(��� �/�/�/����)��!�0�0�%� $�I�%�� ��� � �$�$�S�)���I��%��,�,�.�(�(���!�0�0�%� $�I�%�� �� �/�/�/��s��,E�9C?�)C�.B?�/C�4C?�E�C�&C�'C�+E�?C�C�C�E�C�E�C<�<C?�?E �D�D�D�E �D6�3E �5D6�6E � Ec��hK�|�}|s"|j��d{���|�}|s�"|S7��w)z�Wait until a predicate becomes true. The predicate should be a callable which result will be interpreted as a boolean value. The final predicate value is the return value. N�rb)r� predicate�results r�wait_forzCondition.wait_fors9���������)�)�+����[�F��� � �s�2�0� 2�2c��|j�std��d}|jD]0}||k\ry|j�r�|dz }|j d��2y)aBy default, wake up one coroutine waiting on this condition, if any. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the coroutines waiting for the condition variable; it is a no-op if no coroutines are waiting. Note: an awakened coroutine does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. z!cannot notify on un-acquired lockrr FN)r(rKr#rPrQ)r�n�idxrIs r�notifyzCondition.notify)sT���{�{�}��B�C�C����=�=�C��a�x���8�8�:��q������u�%� !rc�L�|jt|j��y)aWake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. N)rqr1r#rs r� notify_allzCondition.notify_allAs�� ���C�� � �&�'rr�r )rrrrRr%r0rbrmrqrsrSrTs@rrr�s'���� ,�*�#0�J�&�0(rrc�B��eZdZdZdd�Z�fd�Zd�Zd�Zd�Zd�Z �xZ S) raA Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. c�@�|dkrtd��d|_||_y)Nrz$Semaphore initial value must be >= 0)� ValueErrorr#rW)r�values rr%zSemaphore.__init__Ys#���1�9��C�D�D��� ���rc����t�|��}|j�rdnd|j��}|jr|�dt|j���}d|dd�d|�d�S) Nr(zunlocked, value:r*r+r r,r-r.)r/r0r(rWr#r1r2s �rr0zSemaphore.__repr___sg����g�� �� �K�K�M��1A�$�+�+��/O���=�=��g�Z��D�M�M�(:�';�<�E��3�q��9�+�R��w�b�)�)rc�d�|jdk(xs td�|jxsdD��S)z9Returns True if semaphore cannot be acquired immediately.rc3�>K�|]}|j����y�wrr9r;s rr>z#Semaphore.locked.<locals>.<genexpr>is����A�,?�a�A�K�K�M�!�,?�s�r)rW�anyr#rs rr(zSemaphore.lockedfs4���{�{�a��C��A�D�M�M�,?�R�,?�A�A� Crc��K�|j�s|xjdzc_y|j�tj�|_|j�j �}|jj|� |�d{���|jj|� |jdkDr|j�y7�@#|jj|�wxYw#tj$r7|j�s%|xjdz c_|j��wxYw�w)a5Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. r TNr) r(rWr#r@rArBrCrDrEr rFr:� _wake_up_nextrHs rrzSemaphore.acquireks������{�{�}��K�K�1��K���=�=� �'�-�-�/�D�M��n�n��,�,�.��� � ���S�!� � *�� � �� � �$�$�S�)��;�;��?���� ����� � �$�$�S�)���(�(� ��=�=�?����q� ���"�"�$�� �sC�BD>� C�C�C�C1�.!D>�C�C.�.C1�1A D;�;D>c�N�|xjdz c_|j�y)z�Release a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. r N)rWr~rs rrzSemaphore.release�s�� ���q������rc��|jsy|jD]:}|j�r�|xjdzc_|jd�yy)z)Wake up the first waiter that isn't done.Nr T)r#rPrWrQrHs rr~zSemaphore._wake_up_next�s@���}�}���=�=�C��8�8�:����q� �����t�$�� !rrt)rrrrRr%r0r(rrr~rSrTs@rrrJs(�����*�C� "�H� rrc�.��eZdZdZd�fd� Z�fd�Z�xZS)rz�A bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. c�2��||_t�|� |�yr)�_bound_valuer/r%)rrxr5s �rr%zBoundedSemaphore.__init__�s���!��� ����rc�j��|j|jk\rtd��t�|��y)Nz(BoundedSemaphore released too many times)rWr�rwr/r)rr5s �rrzBoundedSemaphore.release�s+����;�;�$�+�+�+��G�H�H� ���rrt)rrrrRr%rrSrTs@rrr�s���� ��rrc��eZdZdZdZdZdZy)� _BarrierState�filling�draining� resetting�brokenN)rrr�FILLING�DRAINING� RESETTING�BROKENrrrr�r��s���G��H��I� �Frr�c���eZdZdZd�Z�fd�Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zd�Z d�Zed ��Zed��Zed��Z�xZS)ra Asyncio equivalent to threading.Barrier Implements a Barrier primitive. Useful for synchronizing a fixed number of tasks at known synchronization points. Tasks block on 'wait()' and are simultaneously awoken once they have all made their call. c��|dkrtd��t�|_||_tj |_d|_y)z1Create a barrier, initialised to 'parties' tasks.r zparties must be >= 1rN)rwr�_cond�_partiesr�r��_state�_count)r�partiess rr%zBarrier.__init__�s9���Q�;��3�4�4��[�� ��� �#�+�+�����rc���t�|��}|jj�}|js|d|j �d|j��z }d|dd�d|�d�S)Nr*�/r+r r,r-r.)r/r0r�rxr�� n_waitingr�r2s �rr0zBarrier.__repr__�sd����g�� ���;�;�$�$�%���{�{��z�$�.�.�!1��4�<�<�.�A�A�E��3�q��9�+�R��w�b�)�)rc��>K�|j��d{���S7��wrrjrs rrzBarrier.__aenter__�s�����Y�Y�[� � � �s���c��K�y�wrr)r�argss rrzBarrier.__aexit__�s �����s�c��0K�|j4�d{���|j��d{��� |j}|xjdz c_|dz|jk(r|j ��d{���n|j��d{���||xjdzc_|j �cddd��d{���S7��7��7�Y7�B7� #|xjdzc_|j �wxYw#1�d{���7swYyxYw�w)z�Wait for the barrier. When the specified number of tasks have started waiting, they are all simultaneously awoken. Returns an unique and individual index number from 0 to 'parties-1'. Nr )r��_blockr�r��_release�_wait�_exit)r�indexs rrbzBarrier.wait�s������:�:�:��+�+�-��� ��������q� ���1�9�� � �-��-�-�/�)�)��*�*�,�&�&�����q� ��� � ���:�:����*��&�������q� ��� � ����:�:�s��D�C �D�D�C�D�AC�7C�8C�C�C�%D�;D�C�D�D�C�C�D�'C>�>D�D�D �D�Dc���K��jj�fd���d{����jtjurtjd��y7�6�w)Nc�\���jtjtjfvSr)r�r�r�r�rs�r�<lambda>z Barrier._block.<locals>.<lambda>�s$���D�K�K��&�&� �(?�(?�(�rzBarrier aborted)r�rmr�r�r�r �BrokenBarrierErrorrs`rr�zBarrier._block�sZ������j�j�!�!� � � � ��;�;�-�.�.�.��/�/�0A�B�B�/� �s�"A�A�7Ac��jK�tj|_|jj �y�wr)r�r�r�r�rsrs rr�zBarrier._releases%���� $�,�,���� � ����s�13c����K��jj�fd���d{����jtjtj fvrt jd��y7�F�w)Nc�<���jtjuSr)r�r�r�rs�rr�zBarrier._wait.<locals>.<lambda>s���$�+�+�]�=R�=R�*RrzAbort or reset of barrier)r�rmr�r�r�r�r r�rs`rr�z Barrier._waits]������j�j�!�!�"R�S�S�S��;�;�=�/�/��1H�1H�I�I��/�/�0K�L�L�J� T�s�"A.�A,�AA.c���|jdk(r\|jtjtjfvrtj |_|jj�yy)Nr)r�r�r�r�r�r�r�rsrs rr�z Barrier._exitsO���;�;�!���{�{�}�6�6� �8N�8N�O�O�+�3�3����J�J�!�!�#�rc��hK�|j4�d{���|jdkDr2|jtjur+tj|_ntj |_|jj �ddd��d{���y7��7�#1�d{���7swYyxYw�w)z�Reset the barrier to the initial state. Any tasks currently waiting will get the BrokenBarrier exception raised. Nr)r�r�r�r�r�r�rsrs r�resetz Barrier.reset"sk�����:�:�:��{�{�Q���;�;�m�&=�&=�=�"/�"9�"9�D�K�+�3�3����J�J�!�!�#��:�:��:��:�:�:�sE�B2�B�B2�A1B�B2�B�B2�B2�B/�#B&�$B/�+B2c���K�|j4�d{���tj|_|jj �ddd��d{���y7�D7�#1�d{���7swYyxYw�w)z�Place the barrier into a 'broken' state. Useful in case of error. Any currently waiting tasks and tasks attempting to 'wait()' will have BrokenBarrierError raised. N)r�r�r�r�rsrs r�abortz Barrier.abort1sA�����:�:�:�'�.�.�D�K��J�J�!�!�#��:�:��:��:�:�:�sD�A1�A�A1�0A�A1�A�A1�A1�A.�"A%�#A.�*A1c��|jS)z8Return the number of tasks required to trip the barrier.)r�rs rr�zBarrier.parties;s���}�}�rc�T�|jtjur|jSy)z<Return the number of tasks currently waiting at the barrier.r)r�r�r�r�rs rr�zBarrier.n_waiting@s#���;�;�-�/�/�/��;�;��rc�:�|jtjuS)z0Return True if the barrier is in a broken state.)r�r�r�rs rr�zBarrier.brokenGs���{�{�m�2�2�2�2r)rrrrRr%r0rrrbr�r�r�r�r�r��propertyr�r�r�rSrTs@rrr�s}���� �*�!� ��.C� � M�$� $�$����������3��3rr)rR�__all__r@�enum�r rr �_LoopBoundMixinrrrrr�Enumr�rrrr�<module>r�s���!�*��������C!���!7�!7�C!�L:&�F�"�"�:&�zm(�$�f�&<�&<�m(�`W�$�f�&<�&<�W�t�y��$�D�I�I��M3�f�$�$�M3r__pycache__/log.cpython-312.pyc000064400000000433151706172560012252 0ustar00� T��h|��4�dZddlZeje�Zy)zLogging configuration.�N)�__doc__�logging� getLogger�__package__�logger���$/usr/lib64/python3.12/asyncio/log.py�<module>rs���� �� � �;� '�r __pycache__/mixins.cpython-312.opt-1.pyc000064400000002006151706172560013735 0ustar00� T��h���R�dZddlZddlmZej�ZGd�d�Zy)zEvent loop mixins.�N�)�eventsc��eZdZdZd�Zy)�_LoopBoundMixinNc���tj�}|j�"t5|j�||_ddd�||jurt |�d���|S#1swY�'xYw)Nz# is bound to a different event loop)r�_get_running_loop�_loop�_global_lock�RuntimeError)�self�loops �'/usr/lib64/python3.12/asyncio/mixins.py� _get_loopz_LoopBoundMixin._get_loopsa���'�'�)���:�:����:�:�%�!%�D�J���t�z�z�!��$��)L�M�N�N�����s�A!�!A*)�__name__� __module__�__qualname__r r��rrr s���E� rr)�__doc__� threading�r�Lockr rrrr�<module>rs&������y�~�~����r__pycache__/mixins.cpython-312.pyc000064400000002006151706172560012776 0ustar00� T��h���R�dZddlZddlmZej�ZGd�d�Zy)zEvent loop mixins.�N�)�eventsc��eZdZdZd�Zy)�_LoopBoundMixinNc���tj�}|j�"t5|j�||_ddd�||jurt |�d���|S#1swY�'xYw)Nz# is bound to a different event loop)r�_get_running_loop�_loop�_global_lock�RuntimeError)�self�loops �'/usr/lib64/python3.12/asyncio/mixins.py� _get_loopz_LoopBoundMixin._get_loopsa���'�'�)���:�:����:�:�%�!%�D�J���t�z�z�!��$��)L�M�N�N�����s�A!�!A*)�__name__� __module__�__qualname__r r��rrr s���E� rr)�__doc__� threading�r�Lockr rrrr�<module>rs&������y�~�~����r__pycache__/proactor_events.cpython-312.opt-2.pyc000064400000125222151706172560015652 0ustar00� T��h܂��� dZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlmZddlmZddlm Z dd lmZdd lmZddlmZddlmZd �ZGd�dej(ej*�ZGd�deej.�ZGd�deej2�ZGd�de�ZGd�deej8�ZGd�deeej<�ZGd�deeej<�Z Gd�de jB�Z"y))�BaseProactorEventLoop�N�)�base_events)� constants)�futures)� exceptions)� protocols)�sslproto)� transports)�trsock)�loggerc���tj|�|jd< |j�|jd<d|jvr |j�|jd<yy#tj $r5|jj�rtjd|d��Y�uwxYw#tj $rd|jd<YywxYw)N�socket�socknamezgetsockname() failed on %rT��exc_info�peername)r�TransportSocket�_extra�getsocknamer�error�_loop� get_debugr �warning�getpeername)� transport�socks �0/usr/lib64/python3.12/asyncio/proactor_events.py�_set_socket_extrars���!'�!7�!7��!=�I���X��C�'+�'7�'7�'9� ����$���)�)�)� 0�+/�+;�+;�+=�I���Z�(�*���<�<�C��?�?�$�$�&��N�N�,�d�T� C��C���|�|� 0�+/�I���Z�(� 0�s$�A/�B:�/AB7�6B7�:"C�Cc���eZdZ d �fd� Zd�Zd�Zd�Zd�Zd�Zd�Z e jfd�Zdd �Z d �Zd�Zd�Z�xZS)�_ProactorBasePipeTransportc���t�|�||�|j|�||_|j |�||_d|_d|_d|_d|_ d|_ d|_d|_d|_ |j �|j j�|jj!|j"j$|�|�,|jj!t&j(|d�yy)NrF)�super�__init__� _set_extra�_sock�set_protocol�_server�_buffer� _read_fut� _write_fut�_pending_write� _conn_lost�_closing�_called_connection_lost�_eof_written�_attachr� call_soon� _protocol�connection_mader�_set_result_unless_cancelled��self�loopr�protocol�waiter�extra�server� __class__s �rr$z#_ProactorBasePipeTransport.__init__2s���� �����%�������� ����(�#��������������������� �',��$�!����<�<�#��L�L� � �"�� � ���T�^�^�;�;�T�B����J�J� � ��!E�!E�!'�� /��c��|jjg}|j�|jd�n|jr|jd�|j�,|jd|jj����|j�|jd|j���|j�|jd|j���|jr'|jdt|j����|jr|jd�djd j|��S) N�closed�closingzfd=zread=zwrite=zwrite_bufsize=zEOF writtenz<{}>� ) r=�__name__r&�appendr.�filenor*r+r)�lenr0�format�join)r7�infos r�__repr__z#_ProactorBasePipeTransport.__repr__Is������'�'�(���:�:���K�K��!� �]�]��K�K� �"��:�:�!��K�K�#�d�j�j�/�/�1�2�3�4��>�>�%��K�K�%����1�2�3��?�?�&��K�K�&���� 3�4�5��<�<��K�K�.��T�\�\�):�(;�<�=�����K�K� �&��}�}�S�X�X�d�^�,�,r>c�"�||jd<y)N�pipe)r�r7rs rr%z%_ProactorBasePipeTransport._set_extra[s��"����F�r>c��||_y�N�r3)r7r9s rr'z'_ProactorBasePipeTransport.set_protocol^s ��!��r>c��|jSrOrP�r7s r�get_protocolz'_ProactorBasePipeTransport.get_protocolas���~�~�r>c��|jSrO)r.rRs r� is_closingz%_ProactorBasePipeTransport.is_closingds���}�}�r>c�.�|jryd|_|xjdz c_|js2|j�&|jj|jd�|j�"|jj�d|_yy)NTr) r.r-r)r+rr2�_call_connection_lostr*�cancelrRs r�closez _ProactorBasePipeTransport.closegsq���=�=���� ����1����|�|���� 7��J�J� � ��!;�!;�T�B��>�>�%��N�N�!�!�#�!�D�N�&r>c�v�|j�-|d|��t|��|jj�yy)Nzunclosed transport )�source)r&�ResourceWarningrY)r7�_warns r�__del__z"_ProactorBasePipeTransport.__del__rs5���:�:�!��'��x�0�/�$�O��J�J����"r>c�0� t|t�r4|jj�rDt j d||d��n*|jj ||||jd��|j|�y#|j|�wxYw)Nz%r: %sTr)�message� exceptionrr9) � isinstance�OSErrorrrr �debug�call_exception_handlerr3�_force_close)r7�excr`s r�_fatal_errorz'_ProactorBasePipeTransport._fatal_errorwsy�� #��#�w�'��:�:�'�'�)��L�L��4��4�H�� � �1�1�&�!$�!%� $��� 3�� ���c�"��D���c�"�s�A.B�Bc�H�|j�S|jj�s9|�|jjd�n|jj|�|jr |j ryd|_|xjdz c_|jr!|jj�d|_|jr!|jj�d|_ d|_ d|_|jj|j|�y)NTrr)� _empty_waiter�done� set_result� set_exceptionr.r/r-r+rXr*r,r)rr2rW)r7rgs rrfz'_ProactorBasePipeTransport._force_close�s������)�$�2D�2D�2I�2I�2K��{��"�"�-�-�d�3��"�"�0�0��5��=�=�T�9�9���� ����1����?�?��O�O�"�"�$�"�D�O��>�>��N�N�!�!�#�!�D�N�������� � ���T�7�7��=r>c��|jry |jj|�t|jd�rF|jj�dk7r)|jj tj�|jj�d|_|j}|�|j�d|_ d|_y#t|jd�rF|jj�dk7r)|jj tj�|jj�d|_|j}|�|j�d|_ d|_wxYw)N�shutdown���T)r/r3�connection_lost�hasattrr&rEror� SHUT_RDWRrYr(�_detach)r7rgr<s rrWz0_ProactorBasePipeTransport._call_connection_lost�s���'�'�� 0��N�N�*�*�3�/��t�z�z�:�.�4�:�:�3D�3D�3F�"�3L�� � �#�#�F�$4�$4�5��J�J�����D�J��\�\�F��!���� �#���+/�D�(���t�z�z�:�.�4�:�:�3D�3D�3F�"�3L�� � �#�#�F�$4�$4�5��J�J�����D�J��\�\�F��!���� �#���+/�D�(�s�C�B+E?c�f�|j}|j�|t|j�z }|SrO)r,r)rF)r7�sizes r�get_write_buffer_sizez0_ProactorBasePipeTransport.get_write_buffer_size�s/���"�"���<�<�#��C����%�%�D��r>�NNN)zFatal error on pipe transport)rC� __module__�__qualname__r$rJr%r'rSrUrY�warnings�warnr^rhrfrWrw� __classcell__�r=s@rr!r!.sQ���4�48�$(�/�.-�$#�"��� "�%�M�M�� #�>�(0�(r>r!c�L��eZdZ d�fd� Zd�Zd�Zd�Zd�Zd�Zd d�Z �xZ S) �_ProactorReadPipeTransportc����d|_d|_t�|� ||||||�t |�|_|jj|j�d|_y)NrpTF) �_pending_data_length�_pausedr#r$� bytearray�_datarr2� _loop_reading) r7r8rr9r:r;r<�buffer_sizer=s �rr$z#_ProactorReadPipeTransport.__init__�sT���$&��!���� ����t�X�v�u�f�E��{�+�� �� � ���T�/�/�0���r>c�:�|jxr |jSrO)r�r.rRs r� is_readingz%_ProactorReadPipeTransport.is_reading�s���<�<��5�� � �$5�5r>c��|js|jryd|_|jj�rt j d|�yy)NTz%r pauses reading)r.r�rrr rdrRs r� pause_readingz(_ProactorReadPipeTransport.pause_reading�s?���=�=�D�L�L������:�:���!��L�L�,�d�3�"r>c��|js|jsyd|_|j�&|jj |j d�|j}d|_|dkDr4|jj |j|jd||�|jj�rtjd|�yy)NFrpz%r resumes reading)r.r�r*rr2r�r��_data_receivedr�rr rd)r7�lengths r�resume_readingz)_ProactorReadPipeTransport.resume_reading�s����=�=���������>�>�!��J�J� � ��!3�!3�T�:��*�*��$&��!��B�;� �J�J� � ��!4�!4�d�j�j��&�6I�6�R��:�:���!��L�L�-�t�4�"r>c�.�|jj�rtjd|� |jj�}|s|j�yy#ttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.)rrr rdr3�eof_received� SystemExit�KeyboardInterrupt� BaseExceptionrhrY)r7� keep_openrgs r� _eof_receivedz(_ProactorReadPipeTransport._eof_received�s����:�:���!��L�L�*�D�1� ����3�3�5�I���J�J�L����-�.� ��� �����H� J��� �s�A � B�8B�Bc��|jr||_y|dk(r|j�yt|jt j�r" tj|j|�y|jj|�y#ttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nrz3Fatal error: protocol.buffer_updated() call failed.) r�r�r�rbr3r �BufferedProtocol�_feed_data_to_buffered_protor�r�r�rh� data_received)r7�datar�rgs rr�z)_ProactorReadPipeTransport._data_received�s����<�<�)/�D�%���Q�;���� ���d�n�n�i�&@�&@�A� ��6�6�t�~�~�t�L� �N�N�(�(��.��� 1�2� �� � ��!�!�#�#1�2��� �s� B � C�%B<�<Cc�J�d}d} |�xd|_|j�rQ|j�}|dk(r |dkDr|j||�yyt t|j�d|�}n|j�|jr |dkDr|j||�yy|js?|jjj|j|j�|_|js&|jj|j� |dkDr|j||�yy#t $rZ}|js|j#|d�n1|jj%�rt'j(dd��Yd}~�wd}~wt*$r}|j-|�Yd}~��d}~wt.$r}|j#|d�Yd}~��d}~wt0j2$r|js�Y��wxYw#|dkDr|j||�wwxYw)Nrprz"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)r*rk�resultr��bytes� memoryviewr�rXr.r�r� _proactor� recv_intor&�add_done_callbackr��ConnectionAbortedErrorrhrr rd�ConnectionResetErrorrfrcr�CancelledError)r7�futr�r�rgs rr�z(_ProactorReadPipeTransport._loop_readings�������. 2���"&����8�8�:� �Z�Z�\�F���{��F��{��#�#�D�&�1��A!��D�J�J�!7���!@�A�D��J�J�L��}�}��2��{��#�#�D�&�1��)�<�<�!%���!5�!5�!?�!?�� � �D�J�J�!W����<�<����0�0��1C�1C�D���{��#�#�D�&�1���#&� ,��=�=��!�!�#�'K�L����%�%�'����I�&*�,���#� #����c�"�"��� I����c�#G�H�H���(�(� ��=�=��!� ����{��#�#�D�&�1��sm�.D<�>D<�&AD<�12H�< H�AF�H�H�&F<�7H�<H�G�H�#H�H�H�H�H")NNNirO)rCryrzr$r�r�r�r�r�r�r}r~s@rr�r��s/���#�48�6;��6�4�&5�$� /�212r>r�c�P��eZdZ dZ�fd�Zd�Zd d�Zd�Zd�Zd�Z d�Z d �Z�xZS)�_ProactorBaseWritePipeTransportTc�2��t�|�|i|��d|_yrO)r#r$rj�r7�args�kwr=s �rr$z(_ProactorBaseWritePipeTransport.__init__Ns��� ���$�%�"�%�!��r>c��t|tttf�s!t dt|�j����|jrtd��|j�td��|sy|jrH|jtjk\rtjd�|xjdz c_ y|j�|j!t|���y|j"s!t|�|_|j%�y|j"j'|�|j%�y)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)r�)rbr�r�r�� TypeError�typerCr0�RuntimeErrorrjr-r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr rr+� _loop_writingr)�_maybe_pause_protocol�extend)r7r�s r�writez%_ProactorBaseWritePipeTransport.writeRs���$�� �:� >�?����D�z�*�*�+�-�.� .�����;�<�<����)��I�J�J����?�?����)�"M�"M�M����@�A��O�O�q� �O���?�?�"� ���E�$�K��0����$�T�?�D�L��&�&�(� �L�L����%��&�&�(r>c�� |�|j� |jryd|_d|_|r|j�|�|j}d|_|sx|jr&|j j |jd�|jr)|jjtj�|j�n�|j jj|j|�|_|jj!�sFt#|�|_|jj%|j&�|j)�n%|jj%|j&�|j*�)|j�|j*j-d�yyy#t.$r}|j1|�Yd}~yd}~wt2$r}|j5|d�Yd}~yd}~wwxYw)Nrz#Fatal write error on pipe transport)r+r.r,r�r)rr2rWr0r&ror�SHUT_WR�_maybe_resume_protocolr��sendrkrFr�r�r�rjrlr�rfrcrh)r7�fr�rgs rr�z-_ProactorBaseWritePipeTransport._loop_writingxs���& J��}����!8�T�]�]��"�D�O�"#�D������ ��|��|�|��#�����=�=��J�J�(�(��)C�)C�T�J��$�$��J�J�'�'����7��+�+�-�"&�*�*�"6�"6�";�";�D�J�J��"M������+�+�-�*-�d�)�D�'��O�O�5�5�d�6H�6H�I��.�.�0��O�O�5�5�d�6H�6H�I��!�!�-�$�/�/�2I��"�"�-�-�d�3�3J�-��#� #����c�"�"��� J����c�#H�I�I�� J�s)�F<�FF<�< H�G�H�'G>�>Hc��y�NT�rRs r� can_write_eofz-_ProactorBaseWritePipeTransport.can_write_eof����r>c�$�|j�yrO)rYrRs r� write_eofz)_ProactorBaseWritePipeTransport.write_eof�s��� � �r>c�&�|jd�yrO�rfrRs r�abortz%_ProactorBaseWritePipeTransport.abort�������$�r>c���|j�td��|jj�|_|j�|jjd�|jS)NzEmpty waiter is already set)rjr�r� create_futurer+rlrRs r�_make_empty_waiterz2_ProactorBaseWritePipeTransport._make_empty_waiter�sY�����)��<�=�=�!�Z�Z�5�5�7����?�?�"����)�)�$�/��!�!�!r>c��d|_yrO)rjrRs r�_reset_empty_waiterz3_ProactorBaseWritePipeTransport._reset_empty_waiter�s ��!��r>�NN) rCryrz�_start_tls_compatibler$r�r�r�r�r�r�r�r}r~s@rr�r�Hs7���$� ��"�$)�L'J�R�� �"�"r>r�c�$��eZdZ�fd�Zd�Z�xZS)�_ProactorWritePipeTransportc����t�|�|i|��|jjj |j d�|_|jj|j�y)N�) r#r$rr��recvr&r*r��_pipe_closedr�s �rr$z$_ProactorWritePipeTransport.__init__�sO��� ���$�%�"�%����-�-�2�2�4�:�:�r�B������(�(��):�):�;r>c��|j�ry|jryd|_|j�|j t��y|j �yrO)� cancelledr.r*r+rf�BrokenPipeErrorrY)r7r�s rr�z(_ProactorWritePipeTransport._pipe_closed�sC���=�=�?���=�=������?�?�&����o�/�0��J�J�Lr>)rCryrzr$r�r}r~s@rr�r��s ���<� r>r�c�R��eZdZdZ d �fd� Zd�Zd�Zd�Zd d�Zd d�Z d d�Z �xZS)�_ProactorDatagramTransportic����||_d|_d|_t�|�|||||��tj�|_|jj|j�y)Nr)r:r;)�_addressrj�_buffer_sizer#r$�collections�dequer)rr2r�)r7r8rr9�addressr:r;r=s �rr$z#_ProactorDatagramTransport.__init__�s^����� �!������ ����t�X�f�E��J�#�(�(�*���� � ���T�/�/�0r>c��t||�yrO�rrMs rr%z%_ProactorDatagramTransport._set_extra�����$��%r>c��|jSrO)r�rRs rrwz0_ProactorDatagramTransport.get_write_buffer_size�s��� � � r>c�&�|jd�yrOr�rRs rr�z _ProactorDatagramTransport.abort�r�r>c�r�t|tttf�st dt|���|sy|j�(|d|jfvrtd|j����|jrT|jrH|jtjk\rtjd�|xjdz c_y|jjt|�|f�|xjt!|�z c_|j"�|j%�|j'�y)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rbr�r�r�r�r�r�� ValueErrorr-rr�r rr)rDr�rFr+r�r�)r7r��addrs r�sendtoz!_ProactorDatagramTransport.sendto�s����$�� �:� >�?��J� ��J�(� (����=�=�$��d�D�M�M�5J�)J��3�D�M�M�?�C�E� E��?�?�t�}�}����)�"M�"M�M����B�C��O�O�q� �O�� �����U�4�[�$�/�0����S��Y�&���?�?�"���� � �"�"�$r>c�z� |jryd|_|r|j�|jr|jr?|jr3|j r&|jj|jd�y|jj�\}}|xjt|�zc_ |j�6|jjj|j|�|_n7|jjj|j||��|_|jj!|j"�|j%�y#t&$r%}|j(j+|�Yd}~yd}~wt,$r}|j/|d�Yd}~yd}~wwxYw)N)r�z'Fatal write error on datagram transport)r-r+r�r)r�r.rr2rW�popleftr�rFr�r�r&r�r�r�r�rcr3�error_received� Exceptionrh)r7r�r�r�rgs rr�z(_ProactorDatagramTransport._loop_writingsT�� *�����#�D�O��� � ���<�<�D�O�O�� � ��=�=��J�J�(�(��)C�)C�T�J�����-�-�/�J�D�$�����T��*���}�}�(�"&�*�*�"6�"6�";�";�D�J�J�<@�#B���#'�*�*�"6�"6�"=�"=�d�j�j�>B�CG�#>�#I��� �O�O�-�-�d�.@�.@�A��'�'�)�� � /��N�N�)�)�#�.�.��� N����c�#L�M�M�� N�s0�E)�A/E)�?B4E)�) F:�2F�F:�F5�5F:c�2�d} |jr! |r|jj|�yyd|_|�_|j �}|j r#d} |r|jj|�yy|j�||j}}n|\}}|jr! |r|jj|�yy|j�@|jjj|j|j�|_n?|jjj|j|j�|_|j�&|jj|j� |r|jj|�yy#t$r%}|jj!|�Yd}~�Id}~wt"j$$r|j s�Y�nwxYw#|r|jj|�wwxYwrO)r-r3�datagram_receivedr*r�r.r�rr�r�r&�max_size�recvfromr�r�rcr�rr�)r7r�r�r��resrgs rr�z(_ProactorDatagramTransport._loop_reading$s�����' =�����H����0�0��t�<��?"�D�N����j�j�l���=�=��D��0����0�0��t�<��-�=�=�,�!$�d�m�m�$�D�!$�J�D�$����� ����0�0��t�<���}�}�(�!%���!5�!5�!:�!:�4�:�:�;?�=�=�"J���"&���!5�!5�!>�!>�t�z�z�?C�}�}�"N����~�~�)����0�0��1C�1C�D�����0�0��t�<���� /��N�N�)�)�#�.�.���(�(� ��=�=��!� ������0�0��t�<��sM�F#�'F#�9,F#�BF#�2G5�# G2�,G�G5�#G2�/G5�1G2�2G5�5!HrxrO)rCryrzr�r$r%rwr�r�r�r�r}r~s@rr�r��s2����H�59�$(�1�&�!� �%�: *�D)=r>r�c��eZdZ d�Zd�Zy)�_ProactorDuplexPipeTransportc��y)NFr�rRs rr�z*_ProactorDuplexPipeTransport.can_write_eofUs��r>c��t�rO)�NotImplementedErrorrRs rr�z&_ProactorDuplexPipeTransport.write_eofXs��!�!r>N)rCryrzr�r�r�r>rr�r�Ps��&��"r>r�c�d��eZdZ ejj Z d�fd� Zd�Zd�Z d�Z �xZS)�_ProactorSocketTransportc�X��t�|�||||||�tj|�yrO)r#r$r�_set_nodelayr6s �rr$z!_ProactorSocketTransport.__init__cs(��� ����t�X�v�u�f�E�� � ��&r>c��t||�yrOr�rMs rr%z#_ProactorSocketTransport._set_extrahr�r>c��yr�r�rRs rr�z&_ProactorSocketTransport.can_write_eofkr�r>c��|js|jryd|_|j�*|jj t j�yyr�)r.r0r+r&rorr�rRs rr�z"_ProactorSocketTransport.write_eofnsA���=�=�D�-�-�� ����?�?�"��J�J������/�#r>rx)rCryrzr� _SendfileMode� TRY_NATIVE�_sendfile_compatibler$r%r�r�r}r~s@rr�r�\s4���+�$�2�2�=�=��48�$(�'� &��0r>r�c����eZdZ�fd�Z dd�Z dddddddd�d�Z dd�Z d d�Z d d �Z d d �Z �fd�Z d�Zd �Zd�Z d!d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�Z d"d�Zd�Zd�Zd�Z�xZS)#rc���t�|��tjd|jj �||_||_d|_i|_ |j|�|j�tj�tj�ur.tj |j"j%��yy)NzUsing proactor: %s)r#r$r rdr=rCr�� _selector�_self_reading_future�_accept_futures�set_loop�_make_self_pipe� threading�current_thread�main_thread�signal� set_wakeup_fd�_csockrE)r7�proactorr=s �rr$zBaseProactorEventLoop.__init__xs���� �������)�8�+=�+=�+F�+F�G�!���!���$(��!�!������$�������#�#�%��)>�)>�)@�@�� � ����!3�!3�!5�6�Ar>Nc�"�t||||||�SrO)r�)r7rr9r:r;r<s r�_make_socket_transportz,BaseProactorEventLoop._make_socket_transport�s��'��d�H�f�(-�v�7� 7r>F)�server_side�server_hostnamer;r<�ssl_handshake_timeout�ssl_shutdown_timeoutc �t�tj||||||| | ��}t|||||��|jS)N)rr�r;r<)r �SSLProtocolr��_app_transport)r7�rawsockr9� sslcontextr:rrr;r<rr�ssl_protocols r�_make_ssl_transportz)BaseProactorEventLoop._make_ssl_transport�sI�� �+�+��h� �F��_�&;�%9� ;�� !��w��',�V� =��*�*�*r>c�"�t||||||�SrO)r�)r7rr9r�r:r;s r�_make_datagram_transportz.BaseProactorEventLoop._make_datagram_transport�s��)�$��h��*0�%�9� 9r>c� �t|||||�SrO)r��r7rr9r:r;s r�_make_duplex_pipe_transportz1BaseProactorEventLoop._make_duplex_pipe_transport�s��+�D�,0�(�F�E�K� Kr>c� �t|||||�SrO)r�rs r�_make_read_pipe_transportz/BaseProactorEventLoop._make_read_pipe_transport�s��)�$��h���N�Nr>c� �t|||||�SrO)r�rs r�_make_write_pipe_transportz0BaseProactorEventLoop._make_write_pipe_transport�s��+�4�+/��6�5�J� Jr>c���|j�rtd��|j�rytj�tj �urt jd�|j�|j�|jj�d|_ d|_t�|�-�y)Nz!Cannot close a running event looprp)� is_runningr�� is_closedrrrr r �_stop_accept_futures�_close_self_piper�rYrr#)r7r=s �rrYzBaseProactorEventLoop.close�s�����?�?���B�C�C��>�>����#�#�%��)>�)>�)@�@�� � ��$� �!�!�#����������������� �� �r>c��VK�|jj||��d{���S7��wrO)r�r�)r7r�ns r� sock_recvzBaseProactorEventLoop.sock_recv�s#�����^�^�(�(��q�1�1�1�1��� )�'�)c��VK�|jj||��d{���S7��wrO)r�r�)r7r�bufs r�sock_recv_intoz$BaseProactorEventLoop.sock_recv_into�s#�����^�^�-�-�d�C�8�8�8�8�r,c��VK�|jj||��d{���S7��wrO)r�r�)r7r�bufsizes r� sock_recvfromz#BaseProactorEventLoop.sock_recvfrom�s#�����^�^�,�,�T�7�;�;�;�;�r,c��rK�|st|�}|jj|||��d{���S7��wrO)rFr�� recvfrom_into)r7rr.�nbytess r�sock_recvfrom_intoz(BaseProactorEventLoop.sock_recvfrom_into�s1�������X�F��^�^�1�1�$��V�D�D�D�D�s�.7�5�7c��VK�|jj||��d{���S7��wrO)r�r�)r7rr�s r�sock_sendallz"BaseProactorEventLoop.sock_sendall�s#�����^�^�(�(��t�4�4�4�4�r,c��ZK�|jj||d|��d{���S7��w)Nr)r�r�)r7rr�r�s r�sock_sendtoz!BaseProactorEventLoop.sock_sendto�s'�����^�^�*�*�4��q�'�B�B�B�B�s�"+�)�+c��K�|jr|j�dk7rtd��|jj ||��d{���S7��w)Nrzthe socket must be non-blocking)�_debug� gettimeoutr�r��connect)r7rr�s r�sock_connectz"BaseProactorEventLoop.sock_connect�sD�����;�;�4�?�?�,��1��>�?�?��^�^�+�+�D�'�:�:�:�:�s�A A�A� Ac��TK�|jj|��d{���S7��wrO)r��acceptrMs r�sock_acceptz!BaseProactorEventLoop.sock_accept�s!�����^�^�*�*�4�0�0�0�0�s�(�&�(c��K� |j�} t j|�j}|r|n|}|syt|d�}|rt||z|�n|} t||�}d} t| |z |�}|dkr| | dkDr|j|�SS|jj||||��d{���||z }| |z } �^#ttjf$r}t j d��d}~wwxYw#t$rt j d��wxYw7�g#| dkDr|j|�wwxYw�w)Nznot a regular filerl��)rE�AttributeError�io�UnsupportedOperationr�SendfileNotAvailableError�os�fstat�st_sizerc�min�seekr��sendfile)r7r�file�offset�countrE�err�fsize� blocksize�end_pos� total_sents r�_sock_sendfile_nativez+BaseProactorEventLoop._sock_sendfile_native�s_���� M��[�[�]�F� M��H�H�V�$�,�,�E�#�E�� ���� �;�/� �05�#�f�u�n�e�,�5���V�U�#��� � "����&� 0�)�<� ���>�%� �A�~�� � �&�!�� �n�n�-�-�d�D�&�)�L�L�L��)�#���i�'� � ���� 7� 7�8� M��6�6�7K�L�L�� M��� M��6�6�7K�L�L� M��M���A�~�� � �&�!��sh�E�C �D�6E�+D$�E�!D$�:D"�;D$� C=�#C8�8C=�=E�D�E�"D$�$D=�=Ec��jK�|j�}|j�|j��d{��� |j|j|||d���d{���|j�|r|j �SS7�P7�)#|j�|r|j �wwxYw�w)NF)�fallback)r�r�r�� sock_sendfiler&r�r�)r7�transprNrOrPr�s r�_sendfile_nativez&BaseProactorEventLoop._sendfile_native�s������*�*�,�������'�'�)�)�)� (��+�+�F�L�L�$���5:�,�<�<� �&�&�(���%�%�'�� *��<�� �&�&�(���%�%�'��s8�4B3�B�B3�#B�B � B�#%B3� B�%B0�0B3c��|j�!|jj�d|_|jj�d|_|jj�d|_|xj dzc_y)Nr)rrX�_ssockrYr� _internal_fdsrRs rr(z&BaseProactorEventLoop._close_self_pipesg���$�$�0��%�%�,�,�.�(,�D�%����������������������a��r>c���tj�\|_|_|jj d�|jj d�|xj dz c_y)NFr)r� socketpairr]r�setblockingr^rRs rrz%BaseProactorEventLoop._make_self_pipesN��#)�#4�#4�#6� ���T�[�������&�������&����a��r>c�t� |�|j�|j|ury|jj|jd�}||_|j|j�y#tj$rYyttf$r�t$r}|jd||d��Yd}~yd}~wwxYw)Niz.Error on reading from the event loop self pipe)r`rar8) r�rr�r�r]r��_loop_self_readingrr�r�r�r�re)r7r�rgs rrcz(BaseProactorEventLoop._loop_self_readings��� 9��}���� ��(�(��1�����#�#�D�K�K��6�A�)*�D�%� ���� 7� 7�8���(�(� ���-�.� ��� ��'�'�K� ��)� � �� �s"� A,�&A,�,B7�B7�B2�2B7c��|j}|�y |jd�y#t$r(|jrt j dd��YyYywxYw)N�z3Fail to write a null byte into the self-pipe socketTr)rr�rcr<r rd)r7�csocks r�_write_to_selfz$BaseProactorEventLoop._write_to_self4sU�������=�� ,��J�J�u���� ,��{�{����0�&*�,�� ,�s�#�,A�Ac �P���������d��������fd� ��j��y)Nc ��� |�s|j�\}}�jrtjd�||���}���j ||�dd|i�� ���n�j||d|i����j �ry�jj� �}|�j� j�<|j��y#t$r�}� j�dk7r9�jd|tj� �d��� j!�n.�jrtjd � d� �Yd}~yYd}~yYd}~yd}~wt"j$$r� j!�YywxYw)Nz#%r got a new connection from %r: %rTr)rr;r<rrrrpzAccept failed on a socket)r`rarzAccept failed on socket %rr)r�r<r rdrrr&r�rArrEr�rcrerrrYrr�) r��connr�r9rgr8�protocol_factoryr7r<rrrrs ��������rr8z2BaseProactorEventLoop._start_serving.<locals>.loopKsw���# *��=�!"����J�D�$��{�{����%J�%+�T�4�9�/�1�H�!�-��0�0� �(�J�D�#-�t�"4�V�2G�1E� 1�G��3�3� �(�#-�t�"4�V�4�E��>�>�#���N�N�)�)�$�/��78��$�$�T�[�[�]�3��#�#�D�)��� 6��;�;�=�B�&��/�/�#>�%(�"(�"8�"8��">�1�� �J�J�L��[�[��L�L�!=�!%��6�6�!�!���,�,� �� � �� �s%�BC� C� F�A0E�&F�FrO)r2) r7rkrrr<�backlogrrr8s ````` ``@r�_start_servingz$BaseProactorEventLoop._start_servingFs��� $ *�$ *�L ���t�r>c��yrOr�)r7� event_lists r�_process_eventsz%BaseProactorEventLoop._process_eventsss��r>c��|jj�D]}|j��|jj�yrO)r�valuesrX�clear)r7�futures rr'z*BaseProactorEventLoop._stop_accept_futuresws6���*�*�1�1�3�F��M�M�O�4����"�"�$r>c���|jj|j�d�}|r|j�|jj|�|j �yrO)r�poprErXr�� _stop_servingrY)r7rrts rrwz#BaseProactorEventLoop._stop_serving|sG���%�%�)�)�$�+�+�-��>����M�M�O����$�$�T�*�� � �r>rxrOr�)r)NN�dNN)rCryrzr$rrrrr!r#rYr+r/r2r6r8r:r?rBrVr[r(rrcrgrmrpr'rwr}r~s@rrrvs����7�=A�26�7�9=� +� �$��t�"&�!%� +� CG�9� BF�*.�K� @D�(,�O�AE�)-�J��(2�9�<�E�5�C�;� 1�"�: (� � �9�8,�&>A�-1�,0�+�Z �%� r>r)#�__all__rErHrr{r rr��rrrrr r rr�logr r�_FlowControlMixin� BaseTransportr!� ReadTransportr��WriteTransportr�r��DatagramTransportr�� Transportr�r�� BaseEventLooprr�r>r�<module>r�s���#�� � � �� ������������0�$D��!=�!=�!+�!9�!9�D�NP2�!;�!+�!9�!9�P2�fk"�&@�&0�&?�&?�k"�\�"A��,A=�!;�!+�!=�!=�A=�H "�#=�#B�#-�#7�#7� "�0�9�>�)�3�3�0�4K�K�5�5�Kr>__pycache__/proactor_events.cpython-312.pyc000064400000127314151706172560014716 0ustar00� T��h܂���dZdZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl mZddl mZddl m Z dd l mZdd l mZddl mZddl mZdd lmZd�ZGd�dej*ej,�ZGd�deej0�ZGd�deej4�ZGd�de�ZGd�deej:�ZGd�deeej>�Z Gd�deeej>�Z!Gd�de jD�Z#y)z�Event loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. )�BaseProactorEventLoop�N�)�base_events)� constants)�futures)� exceptions)� protocols)�sslproto)� transports)�trsock)�loggerc���tj|�|jd< |j�|jd<d|jvr |j�|jd<yy#tj $r5|jj�rtjd|d��Y�uwxYw#tj $rd|jd<YywxYw)N�socket�socknamezgetsockname() failed on %rT��exc_info�peername)r�TransportSocket�_extra�getsocknamer�error�_loop� get_debugr �warning�getpeername)� transport�socks �0/usr/lib64/python3.12/asyncio/proactor_events.py�_set_socket_extrars���!'�!7�!7��!=�I���X��C�'+�'7�'7�'9� ����$���)�)�)� 0�+/�+;�+;�+=�I���Z�(�*���<�<�C��?�?�$�$�&��N�N�,�d�T� C��C���|�|� 0�+/�I���Z�(� 0�s$�A/�B:�/AB7�6B7�:"C�Cc���eZdZdZ d�fd� Zd�Zd�Zd�Zd�Zd�Z d�Z ejfd �Z dd �Zd�Zd�Zd �Z�xZS)�_ProactorBasePipeTransportz*Base class for pipe and socket transports.c���t�|�||�|j|�||_|j |�||_d|_d|_d|_d|_ d|_ d|_d|_d|_ |j �|j j�|jj!|j"j$|�|�,|jj!t&j(|d�yy)NrF)�super�__init__� _set_extra�_sock�set_protocol�_server�_buffer� _read_fut� _write_fut�_pending_write� _conn_lost�_closing�_called_connection_lost�_eof_written�_attachr� call_soon� _protocol�connection_mader�_set_result_unless_cancelled��self�loopr�protocol�waiter�extra�server� __class__s �rr$z#_ProactorBasePipeTransport.__init__2s���� �����%�������� ����(�#��������������������� �',��$�!����<�<�#��L�L� � �"�� � ���T�^�^�;�;�T�B����J�J� � ��!E�!E�!'�� /��c��|jjg}|j�|jd�n|jr|jd�|j�,|jd|jj����|j�|jd|j���|j�|jd|j���|jr'|jdt|j����|jr|jd�djd j|��S) N�closed�closingzfd=zread=zwrite=zwrite_bufsize=zEOF writtenz<{}>� ) r=�__name__r&�appendr.�filenor*r+r)�lenr0�format�join)r7�infos r�__repr__z#_ProactorBasePipeTransport.__repr__Is������'�'�(���:�:���K�K��!� �]�]��K�K� �"��:�:�!��K�K�#�d�j�j�/�/�1�2�3�4��>�>�%��K�K�%����1�2�3��?�?�&��K�K�&���� 3�4�5��<�<��K�K�.��T�\�\�):�(;�<�=�����K�K� �&��}�}�S�X�X�d�^�,�,r>c�"�||jd<y)N�pipe)r�r7rs rr%z%_ProactorBasePipeTransport._set_extra[s��"����F�r>c��||_y�N�r3)r7r9s rr'z'_ProactorBasePipeTransport.set_protocol^s ��!��r>c��|jSrOrP�r7s r�get_protocolz'_ProactorBasePipeTransport.get_protocolas���~�~�r>c��|jSrO)r.rRs r� is_closingz%_ProactorBasePipeTransport.is_closingds���}�}�r>c�.�|jryd|_|xjdz c_|js2|j�&|jj|jd�|j�"|jj�d|_yy)NTr) r.r-r)r+rr2�_call_connection_lostr*�cancelrRs r�closez _ProactorBasePipeTransport.closegsq���=�=���� ����1����|�|���� 7��J�J� � ��!;�!;�T�B��>�>�%��N�N�!�!�#�!�D�N�&r>c�v�|j�-|d|��t|��|jj�yy)Nzunclosed transport )�source)r&�ResourceWarningrY)r7�_warns r�__del__z"_ProactorBasePipeTransport.__del__rs5���:�:�!��'��x�0�/�$�O��J�J����"r>c�0� t|t�r4|jj�rDt j d||d��n*|jj ||||jd��|j|�y#|j|�wxYw)Nz%r: %sTr)�message� exceptionrr9) � isinstance�OSErrorrrr �debug�call_exception_handlerr3�_force_close)r7�excr`s r�_fatal_errorz'_ProactorBasePipeTransport._fatal_errorwsy�� #��#�w�'��:�:�'�'�)��L�L��4��4�H�� � �1�1�&�!$�!%� $��� 3�� ���c�"��D���c�"�s�A.B�Bc�H�|j�S|jj�s9|�|jjd�n|jj|�|jr |j ryd|_|xjdz c_|jr!|jj�d|_|jr!|jj�d|_ d|_ d|_|jj|j|�y)NTrr)� _empty_waiter�done� set_result� set_exceptionr.r/r-r+rXr*r,r)rr2rW)r7rgs rrfz'_ProactorBasePipeTransport._force_close�s������)�$�2D�2D�2I�2I�2K��{��"�"�-�-�d�3��"�"�0�0��5��=�=�T�9�9���� ����1����?�?��O�O�"�"�$�"�D�O��>�>��N�N�!�!�#�!�D�N�������� � ���T�7�7��=r>c��|jry |jj|�t|jd�rF|jj�dk7r)|jj tj�|jj�d|_|j}|�|j�d|_ d|_y#t|jd�rF|jj�dk7r)|jj tj�|jj�d|_|j}|�|j�d|_ d|_wxYw)N�shutdown���T)r/r3�connection_lost�hasattrr&rEror� SHUT_RDWRrYr(�_detach)r7rgr<s rrWz0_ProactorBasePipeTransport._call_connection_lost�s���'�'�� 0��N�N�*�*�3�/��t�z�z�:�.�4�:�:�3D�3D�3F�"�3L�� � �#�#�F�$4�$4�5��J�J�����D�J��\�\�F��!���� �#���+/�D�(���t�z�z�:�.�4�:�:�3D�3D�3F�"�3L�� � �#�#�F�$4�$4�5��J�J�����D�J��\�\�F��!���� �#���+/�D�(�s�C�B+E?c�f�|j}|j�|t|j�z }|SrO)r,r)rF)r7�sizes r�get_write_buffer_sizez0_ProactorBasePipeTransport.get_write_buffer_size�s/���"�"���<�<�#��C����%�%�D��r>�NNN)zFatal error on pipe transport)rC� __module__�__qualname__�__doc__r$rJr%r'rSrUrY�warnings�warnr^rhrfrWrw� __classcell__�r=s@rr!r!.sQ���4�48�$(�/�.-�$#�"��� "�%�M�M�� #�>�(0�(r>r!c�N��eZdZdZ d �fd� Zd�Zd�Zd�Zd�Zd�Z d d�Z �xZS)�_ProactorReadPipeTransportzTransport for read pipes.c����d|_d|_t�|� ||||||�t |�|_|jj|j�d|_y)NrpTF) �_pending_data_length�_pausedr#r$� bytearray�_datarr2� _loop_reading) r7r8rr9r:r;r<�buffer_sizer=s �rr$z#_ProactorReadPipeTransport.__init__�sT���$&��!���� ����t�X�v�u�f�E��{�+�� �� � ���T�/�/�0���r>c�:�|jxr |jSrO)r�r.rRs r� is_readingz%_ProactorReadPipeTransport.is_reading�s���<�<��5�� � �$5�5r>c��|js|jryd|_|jj�rt j d|�yy)NTz%r pauses reading)r.r�rrr rdrRs r� pause_readingz(_ProactorReadPipeTransport.pause_reading�s?���=�=�D�L�L������:�:���!��L�L�,�d�3�"r>c��|js|jsyd|_|j�&|jj |j d�|j}d|_|dkDr4|jj |j|jd||�|jj�rtjd|�yy)NFrpz%r resumes reading)r.r�r*rr2r�r��_data_receivedr�rr rd)r7�lengths r�resume_readingz)_ProactorReadPipeTransport.resume_reading�s����=�=���������>�>�!��J�J� � ��!3�!3�T�:��*�*��$&��!��B�;� �J�J� � ��!4�!4�d�j�j��&�6I�6�R��:�:���!��L�L�-�t�4�"r>c�.�|jj�rtjd|� |jj�}|s|j�yy#ttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.)rrr rdr3�eof_received� SystemExit�KeyboardInterrupt� BaseExceptionrhrY)r7� keep_openrgs r� _eof_receivedz(_ProactorReadPipeTransport._eof_received�s����:�:���!��L�L�*�D�1� ����3�3�5�I���J�J�L����-�.� ��� �����H� J��� �s�A � B�8B�Bc��|jr|jdk(sJ�||_y|dk(r|j�yt|jt j�r" tj|j|�y|jj|�y#ttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nrprz3Fatal error: protocol.buffer_updated() call failed.) r�r�r�rbr3r �BufferedProtocol�_feed_data_to_buffered_protor�r�r�rh� data_received)r7�datar�rgs rr�z)_ProactorReadPipeTransport._data_received�s����<�<��,�,��2�2�2�(.�D�%���Q�;���� ���d�n�n�i�&@�&@�A� ��6�6�t�~�~�t�L� �N�N�(�(��.��� 1�2� �� � ��!�!�#�#1�2��� �s�! B�C�6C � Cc��d}d} |��|j|us|j�|jsJ�d|_|j�rQ|j�}|dk(r |dkDr|j ||�yytt |j�d|�}n|j�|jr |dkDr|j ||�yy|js?|jjj|j|j�|_|js&|jj|j� |dkDr|j ||�yy#t $rZ}|js|j#|d�n1|jj%�rt'j(dd��Yd}~�wd}~wt*$r}|j-|�Yd}~��d}~wt.$r}|j#|d�Yd}~��d}~wt0j2$r|js�Y��wxYw#|dkDr|j ||�wwxYw)Nrprz"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)r*r.rk�resultr��bytes� memoryviewr�rXr�r� _proactor� recv_intor&�add_done_callbackr��ConnectionAbortedErrorrhrr rd�ConnectionResetErrorrfrcr�CancelledError)r7�futr�r�rgs rr�z(_ProactorReadPipeTransport._loop_readings�������. 2����~�~��,����1G�15���@�@�!%����8�8�:� �Z�Z�\�F���{��F��{��#�#�D�&�1��A!��D�J�J�!7���!@�A�D��J�J�L��}�}��2��{��#�#�D�&�1��)�<�<�!%���!5�!5�!?�!?�� � �D�J�J�!W����<�<����0�0��1C�1C�D���{��#�#�D�&�1���#&� ,��=�=��!�!�#�'K�L����%�%�'����I�&*�,���#� #����c�"�"��� I����c�#G�H�H���(�(� ��=�=��!� ����{��#�#�D�&�1��sn�AE$�6>E$�AE$�2H0�$ H-�-AG�=H0�H-�G$�H0�$H-�0H�H0�#H-�*H0�,H-�-H0�0I )NNNirO)rCryrzr{r$r�r�r�r�r�r�r~rs@rr�r��s/���#�48�6;��6�4�&5�$� /�212r>r�c�R��eZdZdZdZ�fd�Zd�Zdd�Zd�Zd�Z d�Z d �Zd �Z�xZ S)�_ProactorBaseWritePipeTransportzTransport for write pipes.Tc�2��t�|�|i|��d|_yrO)r#r$rj�r7�args�kwr=s �rr$z(_ProactorBaseWritePipeTransport.__init__Ns��� ���$�%�"�%�!��r>c��t|tttf�s!t dt|�j����|jrtd��|j�td��|sy|jrH|jtjk\rtjd�|xjdz c_ y|j�*|j �J�|j#t|���y|j s!t|�|_|j%�y|j j'|�|j%�y)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)r�)rbr�r�r�� TypeError�typerCr0�RuntimeErrorrjr-r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr rr+r)� _loop_writing�_maybe_pause_protocol�extend)r7r�s r�writez%_ProactorBaseWritePipeTransport.writeRs���$�� �:� >�?����D�z�*�*�+�-�.� .�����;�<�<����)��I�J�J����?�?����)�"M�"M�M����@�A��O�O�q� �O���?�?�"��<�<�'�'�'����E�$�K��0����$�T�?�D�L��&�&�(� �L�L����%��&�&�(r>c�N� |�|j� |jry||jusJ�d|_d|_|r|j�|�|j}d|_|sx|jr&|j j |jd�|jr)|jjtj�|j�n�|j jj|j|�|_|jj!�sW|jdk(sJ�t#|�|_|jj%|j&�|j)�n%|jj%|j&�|j*�)|j�|j*j-d�yyy#t.$r}|j1|�Yd}~yd}~wt2$r}|j5|d�Yd}~yd}~wwxYw)Nrz#Fatal write error on pipe transport)r+r.r,r�r)rr2rWr0r&ror�SHUT_WR�_maybe_resume_protocolr��sendrkrFr�r�r�rjrlr�rfrcrh)r7�fr�rgs rr�z-_ProactorBaseWritePipeTransport._loop_writingxs���& J��}����!8�T�]�]������'�'�'�"�D�O�"#�D������ ��|��|�|��#�����=�=��J�J�(�(��)C�)C�T�J��$�$��J�J�'�'����7��+�+�-�"&�*�*�"6�"6�";�";�D�J�J��"M������+�+�-��.�.�!�3�3�3�*-�d�)�D�'��O�O�5�5�d�6H�6H�I��.�.�0��O�O�5�5�d�6H�6H�I��!�!�-�$�/�/�2I��"�"�-�-�d�3�3J�-��#� #����c�"�"��� J����c�#H�I�I�� J�s)�G�F=G� H$�&G<�<H$�H�H$c��y�NT�rRs r� can_write_eofz-_ProactorBaseWritePipeTransport.can_write_eof����r>c�$�|j�yrO)rYrRs r� write_eofz)_ProactorBaseWritePipeTransport.write_eof�s��� � �r>c�&�|jd�yrO�rfrRs r�abortz%_ProactorBaseWritePipeTransport.abort�������$�r>c���|j�td��|jj�|_|j�|jjd�|jS)NzEmpty waiter is already set)rjr�r� create_futurer+rlrRs r�_make_empty_waiterz2_ProactorBaseWritePipeTransport._make_empty_waiter�sY�����)��<�=�=�!�Z�Z�5�5�7����?�?�"����)�)�$�/��!�!�!r>c��d|_yrO)rjrRs r�_reset_empty_waiterz3_ProactorBaseWritePipeTransport._reset_empty_waiter�s ��!��r>�NN)rCryrzr{�_start_tls_compatibler$r�r�r�r�r�r�r�r~rs@rr�r�Hs7���$� ��"�$)�L'J�R�� �"�"r>r�c�$��eZdZ�fd�Zd�Z�xZS)�_ProactorWritePipeTransportc����t�|�|i|��|jjj |j d�|_|jj|j�y)N�) r#r$rr��recvr&r*r��_pipe_closedr�s �rr$z$_ProactorWritePipeTransport.__init__�sO��� ���$�%�"�%����-�-�2�2�4�:�:�r�B������(�(��):�):�;r>c�B�|j�ry|j�dk(sJ�|jr|j�J�y||jusJ||jf��d|_|j�|jt ��y|j�y)Nr>)� cancelledr�r.r*r+rf�BrokenPipeErrorrY)r7r�s rr�z(_ProactorWritePipeTransport._pipe_closed�s����=�=�?���z�z�|�s�"�"�"��=�=��>�>�)�)�)���d�n�n�$�;�s�D�N�N�&;�;�$�����?�?�&����o�/�0��J�J�Lr>)rCryrzr$r�r~rs@rr�r��s ���<� r>r�c�R��eZdZdZ d �fd� Zd�Zd�Zd�Zd d�Zd d�Z d d�Z �xZS)�_ProactorDatagramTransportic����||_d|_d|_t�|�|||||��tj�|_|jj|j�y)Nr)r:r;)�_addressrj�_buffer_sizer#r$�collections�dequer)rr2r�)r7r8rr9�addressr:r;r=s �rr$z#_ProactorDatagramTransport.__init__�s^����� �!������ ����t�X�f�E��J�#�(�(�*���� � ���T�/�/�0r>c��t||�yrO�rrMs rr%z%_ProactorDatagramTransport._set_extra�����$��%r>c��|jSrO)r�rRs rrwz0_ProactorDatagramTransport.get_write_buffer_size�s��� � � r>c�&�|jd�yrOr�rRs rr�z _ProactorDatagramTransport.abort�r�r>c�r�t|tttf�st dt|���|sy|j�(|d|jfvrtd|j����|jrT|jrH|jtjk\rtjd�|xjdz c_y|jjt|�|f�|xjt!|�z c_|j"�|j%�|j'�y)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rbr�r�r�r�r�r�� ValueErrorr-rr�r rr)rDr�rFr+r�r�)r7r��addrs r�sendtoz!_ProactorDatagramTransport.sendto�s����$�� �:� >�?��J� ��J�(� (����=�=�$��d�D�M�M�5J�)J��3�D�M�M�?�C�E� E��?�?�t�}�}����)�"M�"M�M����B�C��O�O�q� �O�� �����U�4�[�$�/�0����S��Y�&���?�?�"���� � �"�"�$r>c�� |jry||jusJ�d|_|r|j�|jr|jr?|jr3|j r&|jj|jd�y|jj�\}}|xjt|�zc_ |j�6|jjj|j|�|_n7|jjj|j||��|_|jj!|j"�|j%�y#t&$r%}|j(j+|�Yd}~yd}~wt,$r}|j/|d�Yd}~yd}~wwxYw)N)r�z'Fatal write error on datagram transport)r-r+r�r)r�r.rr2rW�popleftr�rFr�r�r&r�r�r�r�rcr3�error_received� Exceptionrh)r7r�r�r�rgs rr�z(_ProactorDatagramTransport._loop_writingsd�� *������$�/�/�)�)�)�"�D�O��� � ���<�<�D�O�O�� � ��=�=��J�J�(�(��)C�)C�T�J�����-�-�/�J�D�$�����T��*���}�}�(�"&�*�*�"6�"6�";�";�D�J�J�<@�#B���#'�*�*�"6�"6�"=�"=�d�j�j�>B�CG�#>�#I��� �O�O�-�-�d�.@�.@�A��'�'�)�� � /��N�N�)�)�#�.�.��� N����c�#L�M�M�� N�s0�E9�A?E9�B4E9�9 G �F"�"G �.G�G c��d} |jr! |r|jj|�yy|j|us|j�|jsJ�d|_|�_|j�}|jr#d} |r|jj|�yy|j�||j}}n|\}}|jr! |r|jj|�yy|j�@|jjj|j|j�|_n?|jjj|j|j�|_|j�&|jj|j� |r|jj|�yy#t$r%}|jj!|�Yd}~�Id}~wt"j$$r|js�Y�nwxYw#|r|jj|�wwxYwrO)r-r3�datagram_receivedr*r.r�r�rr�r�r&�max_size�recvfromr�r�rcr�rr�)r7r�r�r��resrgs rr�z(_ProactorDatagramTransport._loop_reading$s�����' =�����H����0�0��t�<��E�>�>�S�(�T�^�^�-C�-1�]�]� <�<�"�D�N����j�j�l���=�=��D��0����0�0��t�<��-�=�=�,�!$�d�m�m�$�D�!$�J�D�$����� ����0�0��t�<���}�}�(�!%���!5�!5�!:�!:�4�:�:�;?�=�=�"J���"&���!5�!5�!>�!>�t�z�z�?C�}�}�"N����~�~�)����0�0��1C�1C�D�����0�0��t�<���� /��N�N�)�)�#�.�.���(�(� ��=�=��!� ������0�0��t�<��sN�G�AG�!,G�.BG�92H� H�G4�/H�4#H�H�H�H�!H>rxrO)rCryrzr�r$r%rwr�r�r�r�r~rs@rr�r��s2����H�59�$(�1�&�!� �%�: *�D)=r>r�c��eZdZdZd�Zd�Zy)�_ProactorDuplexPipeTransportzTransport for duplex pipes.c��y)NFr�rRs rr�z*_ProactorDuplexPipeTransport.can_write_eofUs��r>c��t�rO)�NotImplementedErrorrRs rr�z&_ProactorDuplexPipeTransport.write_eofXs��!�!r>N)rCryrzr{r�r�r�r>rr�r�Ps��&��"r>r�c�f��eZdZdZej jZ d�fd� Zd�Z d�Z d�Z�xZS)�_ProactorSocketTransportz Transport for connected sockets.c�X��t�|�||||||�tj|�yrO)r#r$r�_set_nodelayr6s �rr$z!_ProactorSocketTransport.__init__cs(��� ����t�X�v�u�f�E�� � ��&r>c��t||�yrOr�rMs rr%z#_ProactorSocketTransport._set_extrahr�r>c��yr�r�rRs rr�z&_ProactorSocketTransport.can_write_eofkr�r>c��|js|jryd|_|j�*|jj t j�yyr�)r.r0r+r&rorr�rRs rr�z"_ProactorSocketTransport.write_eofnsA���=�=�D�-�-�� ����?�?�"��J�J������/�#r>rx) rCryrzr{r� _SendfileMode� TRY_NATIVE�_sendfile_compatibler$r%r�r�r~rs@rr�r�\s4���+�$�2�2�=�=��48�$(�'� &��0r>r�c����eZdZ�fd�Z dd�Z dddddddd�d�Z dd�Z d d�Z d d �Z d d �Z �fd�Z d�Zd �Zd�Z d!d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�Z d"d�Zd�Zd�Zd�Z�xZS)#rc���t�|��tjd|jj �||_||_d|_i|_ |j|�|j�tj�tj�ur.tj |j"j%��yy)NzUsing proactor: %s)r#r$r rdr=rCr�� _selector�_self_reading_future�_accept_futures�set_loop�_make_self_pipe� threading�current_thread�main_thread�signal� set_wakeup_fd�_csockrE)r7�proactorr=s �rr$zBaseProactorEventLoop.__init__xs���� �������)�8�+=�+=�+F�+F�G�!���!���$(��!�!������$�������#�#�%��)>�)>�)@�@�� � ����!3�!3�!5�6�Ar>Nc�"�t||||||�SrO)r�)r7rr9r:r;r<s r�_make_socket_transportz,BaseProactorEventLoop._make_socket_transport�s��'��d�H�f�(-�v�7� 7r>F)�server_side�server_hostnamer;r<�ssl_handshake_timeout�ssl_shutdown_timeoutc �t�tj||||||| | ��}t|||||��|jS)N)rr�r;r<)r �SSLProtocolr��_app_transport)r7�rawsockr9� sslcontextr:rrr;r<rr�ssl_protocols r�_make_ssl_transportz)BaseProactorEventLoop._make_ssl_transport�sI�� �+�+��h� �F��_�&;�%9� ;�� !��w��',�V� =��*�*�*r>c�"�t||||||�SrO)r�)r7rr9r�r:r;s r�_make_datagram_transportz.BaseProactorEventLoop._make_datagram_transport�s��)�$��h��*0�%�9� 9r>c� �t|||||�SrO)r��r7rr9r:r;s r�_make_duplex_pipe_transportz1BaseProactorEventLoop._make_duplex_pipe_transport�s��+�D�,0�(�F�E�K� Kr>c� �t|||||�SrO)r�rs r�_make_read_pipe_transportz/BaseProactorEventLoop._make_read_pipe_transport�s��)�$��h���N�Nr>c� �t|||||�SrO)r�rs r�_make_write_pipe_transportz0BaseProactorEventLoop._make_write_pipe_transport�s��+�4�+/��6�5�J� Jr>c���|j�rtd��|j�rytj�tj �urt jd�|j�|j�|jj�d|_ d|_t�|�-�y)Nz!Cannot close a running event looprp)� is_runningr�� is_closedrrr r r�_stop_accept_futures�_close_self_piper�rYrr#)r7r=s �rrYzBaseProactorEventLoop.close�s�����?�?���B�C�C��>�>����#�#�%��)>�)>�)@�@�� � ��$� �!�!�#����������������� �� �r>c��VK�|jj||��d{���S7��wrO)r�r�)r7r�ns r� sock_recvzBaseProactorEventLoop.sock_recv�s#�����^�^�(�(��q�1�1�1�1��� )�'�)c��VK�|jj||��d{���S7��wrO)r�r�)r7r�bufs r�sock_recv_intoz$BaseProactorEventLoop.sock_recv_into�s#�����^�^�-�-�d�C�8�8�8�8�r-c��VK�|jj||��d{���S7��wrO)r�r�)r7r�bufsizes r� sock_recvfromz#BaseProactorEventLoop.sock_recvfrom�s#�����^�^�,�,�T�7�;�;�;�;�r-c��rK�|st|�}|jj|||��d{���S7��wrO)rFr�� recvfrom_into)r7rr/�nbytess r�sock_recvfrom_intoz(BaseProactorEventLoop.sock_recvfrom_into�s1�������X�F��^�^�1�1�$��V�D�D�D�D�s�.7�5�7c��VK�|jj||��d{���S7��wrO)r�r�)r7rr�s r�sock_sendallz"BaseProactorEventLoop.sock_sendall�s#�����^�^�(�(��t�4�4�4�4�r-c��ZK�|jj||d|��d{���S7��w)Nr)r�r�)r7rr�r�s r�sock_sendtoz!BaseProactorEventLoop.sock_sendto�s'�����^�^�*�*�4��q�'�B�B�B�B�s�"+�)�+c��K�|jr|j�dk7rtd��|jj ||��d{���S7��w)Nrzthe socket must be non-blocking)�_debug� gettimeoutr�r��connect)r7rr�s r�sock_connectz"BaseProactorEventLoop.sock_connect�sD�����;�;�4�?�?�,��1��>�?�?��^�^�+�+�D�'�:�:�:�:�s�A A�A� Ac��TK�|jj|��d{���S7��wrO)r��acceptrMs r�sock_acceptz!BaseProactorEventLoop.sock_accept�s!�����^�^�*�*�4�0�0�0�0�s�(�&�(c��K� |j�} t j|�j}|r|n|}|syt|d�}|rt||z|�n|} t||�}d} t| |z |�}|dkr| | dkDr|j|�SS|jj||||��d{���||z }| |z } �^#ttjf$r}t j d��d}~wwxYw#t$rt j d��wxYw7�g#| dkDr|j|�wwxYw�w)Nznot a regular filerl��)rE�AttributeError�io�UnsupportedOperationr�SendfileNotAvailableError�os�fstat�st_sizerc�min�seekr��sendfile)r7r�file�offset�countrE�err�fsize� blocksize�end_pos� total_sents r�_sock_sendfile_nativez+BaseProactorEventLoop._sock_sendfile_native�s_���� M��[�[�]�F� M��H�H�V�$�,�,�E�#�E�� ���� �;�/� �05�#�f�u�n�e�,�5���V�U�#��� � "����&� 0�)�<� ���>�%� �A�~�� � �&�!�� �n�n�-�-�d�D�&�)�L�L�L��)�#���i�'� � ���� 7� 7�8� M��6�6�7K�L�L�� M��� M��6�6�7K�L�L� M��M���A�~�� � �&�!��sh�E�C �D�6E�+D$�E�!D$�:D"�;D$� C=�#C8�8C=�=E�D�E�"D$�$D=�=Ec��jK�|j�}|j�|j��d{��� |j|j|||d���d{���|j�|r|j �SS7�P7�)#|j�|r|j �wwxYw�w)NF)�fallback)r�r�r�� sock_sendfiler&r�r�)r7�transprOrPrQr�s r�_sendfile_nativez&BaseProactorEventLoop._sendfile_native�s������*�*�,�������'�'�)�)�)� (��+�+�F�L�L�$���5:�,�<�<� �&�&�(���%�%�'�� *��<�� �&�&�(���%�%�'��s8�4B3�B�B3�#B�B � B�#%B3� B�%B0�0B3c��|j�!|jj�d|_|jj�d|_|jj�d|_|xj dzc_y)Nr)rrX�_ssockrYr� _internal_fdsrRs rr)z&BaseProactorEventLoop._close_self_pipesg���$�$�0��%�%�,�,�.�(,�D�%����������������������a��r>c���tj�\|_|_|jj d�|jj d�|xj dz c_y)NFr)r� socketpairr^r�setblockingr_rRs rrz%BaseProactorEventLoop._make_self_pipesN��#)�#4�#4�#6� ���T�[�������&�������&����a��r>c�t� |�|j�|j|ury|jj|jd�}||_|j|j�y#tj$rYyttf$r�t$r}|jd||d��Yd}~yd}~wwxYw)Niz.Error on reading from the event loop self pipe)r`rar8) r�rr�r�r^r��_loop_self_readingrr�r�r�r�re)r7r�rgs rrdz(BaseProactorEventLoop._loop_self_readings��� 9��}���� ��(�(��1�����#�#�D�K�K��6�A�)*�D�%� ���� 7� 7�8���(�(� ���-�.� ��� ��'�'�K� ��)� � �� �s"� A,�&A,�,B7�B7�B2�2B7c��|j}|�y |jd�y#t$r(|jrt j dd��YyYywxYw)N�z3Fail to write a null byte into the self-pipe socketTr)rr�rcr=r rd)r7�csocks r�_write_to_selfz$BaseProactorEventLoop._write_to_self4sU�������=�� ,��J�J�u���� ,��{�{����0�&*�,�� ,�s�#�,A�Ac �P���������d��������fd� ��j��y)Nc ��� |�s|j�\}}�jrtjd�||���}���j ||�dd|i�� ���n�j||d|i����j �ry�jj� �}|�j� j�<|j��y#t$r�}� j�dk7r9�jd|tj� �d��� j!�n.�jrtjd � d� �Yd}~yYd}~yYd}~yd}~wt"j$$r� j!�YywxYw)Nz#%r got a new connection from %r: %rTr)rr;r<rrrrpzAccept failed on a socket)r`rarzAccept failed on socket %rr)r�r=r rdrrr'r�rBrrEr�rcrerrrYrr�) r��connr�r9rgr8�protocol_factoryr7r<rrrrs ��������rr8z2BaseProactorEventLoop._start_serving.<locals>.loopKsw���# *��=�!"����J�D�$��{�{����%J�%+�T�4�9�/�1�H�!�-��0�0� �(�J�D�#-�t�"4�V�2G�1E� 1�G��3�3� �(�#-�t�"4�V�4�E��>�>�#���N�N�)�)�$�/��78��$�$�T�[�[�]�3��#�#�D�)��� 6��;�;�=�B�&��/�/�#>�%(�"(�"8�"8��">�1�� �J�J�L��[�[��L�L�!=�!%��6�6�!�!���,�,� �� � �� �s%�BC� C� F�A0E�&F�FrO)r2) r7rlrrr<�backlogrrr8s ````` ``@r�_start_servingz$BaseProactorEventLoop._start_servingFs��� $ *�$ *�L ���t�r>c��yrOr�)r7� event_lists r�_process_eventsz%BaseProactorEventLoop._process_eventsss��r>c��|jj�D]}|j��|jj�yrO)r�valuesrX�clear)r7�futures rr(z*BaseProactorEventLoop._stop_accept_futuresws6���*�*�1�1�3�F��M�M�O�4����"�"�$r>c���|jj|j�d�}|r|j�|jj|�|j �yrO)r�poprErXr�� _stop_servingrY)r7rrus rrxz#BaseProactorEventLoop._stop_serving|sG���%�%�)�)�$�+�+�-��>����M�M�O����$�$�T�*�� � �r>rxrOr�)r)NN�dNN)rCryrzr$rrrr r"r$rYr,r0r3r7r9r;r@rCrWr\r)rrdrhrnrqr(rxr~rs@rrrvs����7�=A�26�7�9=� +� �$��t�"&�!%� +� CG�9� BF�*.�K� @D�(,�O�AE�)-�J��(2�9�<�E�5�C�;� 1�"�: (� � �9�8,�&>A�-1�,0�+�Z �%� r>r)$r{�__all__rFrIrr|r rr��rrrrr r rr�logr r�_FlowControlMixin� BaseTransportr!� ReadTransportr��WriteTransportr�r��DatagramTransportr�� Transportr�r�� BaseEventLooprr�r>r�<module>r�s���#�� � � �� ������������0�$D��!=�!=�!+�!9�!9�D�NP2�!;�!+�!9�!9�P2�fk"�&@�&0�&?�&?�k"�\�"A��,A=�!;�!+�!=�!=�A=�H "�#=�#B�#-�#7�#7� "�0�9�>�)�3�3�0�4K�K�5�5�Kr>__pycache__/protocols.cpython-312.opt-1.pyc000064400000021120151706172560014450 0ustar00� T��h-��~�dZdZGd�d�ZGd�de�ZGd�de�ZGd�d e�ZGd �de�Zd�Zy )zAbstract Protocol base classes.)�BaseProtocol�Protocol�DatagramProtocol�SubprocessProtocol�BufferedProtocolc�,�eZdZdZdZd�Zd�Zd�Zd�Zy)raCommon base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe �c��y)z�Called when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. Nr)�self� transports �*/usr/lib64/python3.12/asyncio/protocols.py�connection_madezBaseProtocol.connection_made���c��y)z�Called when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). Nr�r �excs r�connection_lostzBaseProtocol.connection_lostrrc��y)aCalled when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). Nr�r s r� pause_writingzBaseProtocol.pause_writing%rrc��y)zvCalled when the transport's buffer drains below the low-water mark. See pause_writing() for details. Nrrs r�resume_writingzBaseProtocol.resume_writing;rrN) �__name__� __module__�__qualname__�__doc__� __slots__r rrrrrrrr s"����I����,rrc� �eZdZdZdZd�Zd�Zy)ranInterface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() rc��y)zTCalled when some data is received. The argument is a bytes object. Nr)r �datas r� data_receivedzProtocol.data_received^rrc��y�z�Called when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Nrrs r�eof_receivedzProtocol.eof_receiveddrrN)rrrrrr!r$rrrrrBs���2�I��rrc�&�eZdZdZdZd�Zd�Zd�Zy)ra:Interface for stream protocol with manual buffer control. Event methods, such as `create_server` and `create_connection`, accept factories that return protocols that implement this interface. The idea of BufferedProtocol is that it allows to manually allocate and control the receive buffer. Event loops can then use the buffer provided by the protocol to avoid unnecessary data copies. This can result in noticeable performance improvement for protocols that receive big amounts of data. Sophisticated protocols can allocate the buffer only once at creation time. State machine of calls: start -> CM [-> GB [-> BU?]]* [-> ER?] -> CL -> end * CM: connection_made() * GB: get_buffer() * BU: buffer_updated() * ER: eof_received() * CL: connection_lost() rc��y)aPCalled to allocate a new receive buffer. *sizehint* is a recommended minimal size for the returned buffer. When set to -1, the buffer size can be arbitrary. Must return an object that implements the :ref:`buffer protocol <bufferobjects>`. It is an error to return a zero-sized buffer. Nr)r �sizehints r� get_bufferzBufferedProtocol.get_buffer�rrc��y)z�Called when the buffer was updated with the received data. *nbytes* is the total number of bytes that were written to the buffer. Nr)r �nbytess r�buffer_updatedzBufferedProtocol.buffer_updated�rrc��yr#rrs rr$zBufferedProtocol.eof_received�rrN)rrrrrr(r+r$rrrrrms���.�I� ��rrc� �eZdZdZdZd�Zd�Zy)rz Interface for datagram protocol.rc��y)z&Called when some datagram is received.Nr)r r �addrs r�datagram_receivedz"DatagramProtocol.datagram_received�rrc��y)z~Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) Nrrs r�error_receivedzDatagramProtocol.error_received�rrN)rrrrrr0r2rrrrr�s��*��I�5�rrc�&�eZdZdZdZd�Zd�Zd�Zy)rz,Interface for protocol for subprocess calls.rc��y)z�Called when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. Nr)r �fdr s r�pipe_data_receivedz%SubprocessProtocol.pipe_data_received�rrc��y)z�Called when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. Nr)r r5rs r�pipe_connection_lostz'SubprocessProtocol.pipe_connection_lost�rrc��y)z"Called when subprocess has exited.Nrrs r�process_exitedz!SubprocessProtocol.process_exited�rrN)rrrrrr6r8r:rrrrr�s��6��I���1rrc��t|�}|rr|j|�}t|�}|std��||k\r||d||j|�y|d||d||j|�||d}t|�}|r�qyy)Nz%get_buffer() returned an empty buffer)�lenr(�RuntimeErrorr+)�protor �data_len�buf�buf_lens r�_feed_data_to_buffered_protorB�s����4�y�H� ����x�(���c�(����F�G�G��h��!�C� ��N�� � ��*�� ��'�N�C���M�� � ��)����>�D��4�y�H�rN)r�__all__rrrrrrBrrr�<module>rDsQ��%���6�6�r(�|�(�V2�|�2�j�|��1��1�.!r__pycache__/protocols.cpython-312.opt-2.pyc000064400000007273151706172560014466 0ustar00� T��h-��|� dZGd�d�ZGd�de�ZGd�de�ZGd�de�ZGd �d e�Zd�Zy) )�BaseProtocol�Protocol�DatagramProtocol�SubprocessProtocol�BufferedProtocolc�*�eZdZ dZd�Zd�Zd�Zd�Zy)r�c��y�Nr)�self� transports �*/usr/lib64/python3.12/asyncio/protocols.py�connection_madezBaseProtocol.connection_made��� �c��yr r�r�excs r �connection_lostzBaseProtocol.connection_lostrrc��yr r�rs r � pause_writingzBaseProtocol.pause_writing%s�� rc��yr rrs r �resume_writingzBaseProtocol.resume_writing;��� rN)�__name__� __module__�__qualname__� __slots__rrrrrrr rr s"����I����,rrc��eZdZ dZd�Zd�Zy)rrc��yr r)r�datas r � data_receivedzProtocol.data_received^rrc��yr rrs r �eof_receivedzProtocol.eof_receiveddrrN)rrrrr"r$rrr rrBs���2�I��rrc�$�eZdZ dZd�Zd�Zd�Zy)rrc��yr r)r�sizehints r � get_bufferzBufferedProtocol.get_buffer�s�� rc��yr r)r�nbytess r �buffer_updatedzBufferedProtocol.buffer_updated���� rc��yr rrs r r$zBufferedProtocol.eof_received�rrN)rrrrr(r+r$rrr rrms���.�I� ��rrc��eZdZ dZd�Zd�Zy)rrc��yr r)rr!�addrs r �datagram_receivedz"DatagramProtocol.datagram_received�s��4rc��yr rrs r �error_receivedzDatagramProtocol.error_received�rrN)rrrrr1r3rrr rr�s��*��I�5�rrc�$�eZdZ dZd�Zd�Zd�Zy)rrc��yr r)r�fdr!s r �pipe_data_receivedz%SubprocessProtocol.pipe_data_received�r,rc��yr r)rr6rs r �pipe_connection_lostz'SubprocessProtocol.pipe_connection_lost�r,rc��yr rrs r �process_exitedz!SubprocessProtocol.process_exited�s��0rN)rrrrr7r9r;rrr rr�s��6��I���1rrc��t|�}|rr|j|�}t|�}|std��||k\r||d||j|�y|d||d||j|�||d}t|�}|r�qyy)Nz%get_buffer() returned an empty buffer)�lenr(�RuntimeErrorr+)�protor!�data_len�buf�buf_lens r �_feed_data_to_buffered_protorC�s����4�y�H� ����x�(���c�(����F�G�G��h��!�C� ��N�� � ��*�� ��'�N�C���M�� � ��)����>�D��4�y�H�rN)�__all__rrrrrrCrrr �<module>rEsQ��%���6�6�r(�|�(�V2�|�2�j�|��1��1�.!r__pycache__/protocols.cpython-312.pyc000064400000021120151706172560013511 0ustar00� T��h-��~�dZdZGd�d�ZGd�de�ZGd�de�ZGd�d e�ZGd �de�Zd�Zy )zAbstract Protocol base classes.)�BaseProtocol�Protocol�DatagramProtocol�SubprocessProtocol�BufferedProtocolc�,�eZdZdZdZd�Zd�Zd�Zd�Zy)raCommon base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe �c��y)z�Called when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. Nr)�self� transports �*/usr/lib64/python3.12/asyncio/protocols.py�connection_madezBaseProtocol.connection_made���c��y)z�Called when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). Nr�r �excs r�connection_lostzBaseProtocol.connection_lostrrc��y)aCalled when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). Nr�r s r� pause_writingzBaseProtocol.pause_writing%rrc��y)zvCalled when the transport's buffer drains below the low-water mark. See pause_writing() for details. Nrrs r�resume_writingzBaseProtocol.resume_writing;rrN) �__name__� __module__�__qualname__�__doc__� __slots__r rrrrrrrr s"����I����,rrc� �eZdZdZdZd�Zd�Zy)ranInterface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() rc��y)zTCalled when some data is received. The argument is a bytes object. Nr)r �datas r� data_receivedzProtocol.data_received^rrc��y�z�Called when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Nrrs r�eof_receivedzProtocol.eof_receiveddrrN)rrrrrr!r$rrrrrBs���2�I��rrc�&�eZdZdZdZd�Zd�Zd�Zy)ra:Interface for stream protocol with manual buffer control. Event methods, such as `create_server` and `create_connection`, accept factories that return protocols that implement this interface. The idea of BufferedProtocol is that it allows to manually allocate and control the receive buffer. Event loops can then use the buffer provided by the protocol to avoid unnecessary data copies. This can result in noticeable performance improvement for protocols that receive big amounts of data. Sophisticated protocols can allocate the buffer only once at creation time. State machine of calls: start -> CM [-> GB [-> BU?]]* [-> ER?] -> CL -> end * CM: connection_made() * GB: get_buffer() * BU: buffer_updated() * ER: eof_received() * CL: connection_lost() rc��y)aPCalled to allocate a new receive buffer. *sizehint* is a recommended minimal size for the returned buffer. When set to -1, the buffer size can be arbitrary. Must return an object that implements the :ref:`buffer protocol <bufferobjects>`. It is an error to return a zero-sized buffer. Nr)r �sizehints r� get_bufferzBufferedProtocol.get_buffer�rrc��y)z�Called when the buffer was updated with the received data. *nbytes* is the total number of bytes that were written to the buffer. Nr)r �nbytess r�buffer_updatedzBufferedProtocol.buffer_updated�rrc��yr#rrs rr$zBufferedProtocol.eof_received�rrN)rrrrrr(r+r$rrrrrms���.�I� ��rrc� �eZdZdZdZd�Zd�Zy)rz Interface for datagram protocol.rc��y)z&Called when some datagram is received.Nr)r r �addrs r�datagram_receivedz"DatagramProtocol.datagram_received�rrc��y)z~Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) Nrrs r�error_receivedzDatagramProtocol.error_received�rrN)rrrrrr0r2rrrrr�s��*��I�5�rrc�&�eZdZdZdZd�Zd�Zd�Zy)rz,Interface for protocol for subprocess calls.rc��y)z�Called when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. Nr)r �fdr s r�pipe_data_receivedz%SubprocessProtocol.pipe_data_received�rrc��y)z�Called when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. Nr)r r5rs r�pipe_connection_lostz'SubprocessProtocol.pipe_connection_lost�rrc��y)z"Called when subprocess has exited.Nrrs r�process_exitedz!SubprocessProtocol.process_exited�rrN)rrrrrr6r8r:rrrrr�s��6��I���1rrc��t|�}|rr|j|�}t|�}|std��||k\r||d||j|�y|d||d||j|�||d}t|�}|r�qyy)Nz%get_buffer() returned an empty buffer)�lenr(�RuntimeErrorr+)�protor �data_len�buf�buf_lens r�_feed_data_to_buffered_protorB�s����4�y�H� ����x�(���c�(����F�G�G��h��!�C� ��N�� � ��*�� ��'�N�C���M�� � ��)����>�D��4�y�H�rN)r�__all__rrrrrrBrrr�<module>rDsQ��%���6�6�r(�|�(�V2�|�2�j�|��1��1�.!r__pycache__/queues.cpython-312.pyc000064400000027247151706172560013014 0ustar00� T��h&���dZddlZddlZddlmZddlmZddlmZGd�de�Z Gd �d e�Z Gd�dej�ZGd �de�Z Gd�de�Zy))�Queue� PriorityQueue� LifoQueue� QueueFull� QueueEmpty�N)�GenericAlias�)�locks)�mixinsc��eZdZdZy)rz;Raised when Queue.get_nowait() is called on an empty Queue.N��__name__� __module__�__qualname__�__doc__���'/usr/lib64/python3.12/asyncio/queues.pyrrs��E�rrc��eZdZdZy)rzDRaised when the Queue.put_nowait() method is called on a full Queue.Nr rrrrrs��N�rrc��eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z d�Z ee�Z d �Zd �Zed��Zd�Zd �Zd�Zd�Zd�Zd�Zd�Zd�Zy)raA queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "await put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. c��||_tj�|_tj�|_d|_t j�|_|jj�|j|�y)Nr)�_maxsize�collections�deque�_getters�_putters�_unfinished_tasksr �Event� _finished�set�_init��self�maxsizes r�__init__zQueue.__init__!s\���� �$�)�)�+�� �#�)�)�+�� �!"���������������� � �7�rc�6�tj�|_y�N)rr�_queuer"s rr!zQueue._init/s��!�'�'�)��rc�6�|jj�Sr')r(�popleft�r#s r�_getz Queue._get2s���{�{�"�"�$�$rc�:�|jj|�yr'�r(�append�r#�items r�_putz Queue._put5��������4� rc�t�|r6|j�}|j�s|jd�y|r�5yyr')r*�done� set_result)r#�waiters�waiters r�_wakeup_nextzQueue._wakeup_next:s0����_�_�&�F��;�;�=��!�!�$�'�� rc�p�dt|�j�dt|�d�d|j��d�S)N�<z at z#x� �>)�typer�id�_formatr+s r�__repr__zQueue.__repr__Bs5���4��:�&�&�'�t�B�t�H�R�=��$�,�,�.�9I��K�Krc�V�dt|�j�d|j��d�S)Nr;r<r=)r>rr@r+s r�__str__z Queue.__str__Es)���4��:�&�&�'�q�����(8��:�:rc�P�d|j��}t|dd�r|dt|j���z }|jr|dt|j��d�z }|jr|dt|j��d�z }|jr|d|j��z }|S)Nzmaxsize=r(z _queue=z _getters[�]z _putters[z tasks=)r�getattr�listr(r�lenrr)r#�results rr@z Queue._formatJs����D�M�M�,�-���4��4�(����d�k�k�!2� 5�6�6�F��=�=�� �3�t�}�}�#5�"6�a�8�8�F��=�=�� �3�t�}�}�#5�"6�a�8�8�F��!�!���� 6� 6�7�8�8�F�� rc�,�t|j�S)zNumber of items in the queue.)rHr(r+s r�qsizezQueue.qsizeVs���4�;�;��rc��|jS)z%Number of items allowed in the queue.)rr+s rr$z Queue.maxsizeZs���}�}�rc��|jS)z3Return True if the queue is empty, False otherwise.�r(r+s r�emptyzQueue.empty_s���;�;��rc�\�|jdkry|j�|jk\S)z�Return True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. rF)rrKr+s r�fullz Queue.fullcs(���=�=�A����:�:�<�4�=�=�0�0rc���K�|j�rU|j�j�}|jj |� |�d{���|j�r�U|j|�S7�&#|j� |jj |�n#t$rYnwxYw|j�s+|j�s|j|j��xYw�w)z�Put an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. N)rQ� _get_loop� create_futurerr/�cancel�remove� ValueError� cancelledr9� put_nowait)r#r1�putters r�putz Queue.putns������i�i�k��^�^�%�3�3�5�F��M�M� � ��(� ���� �i�i�k�&���t�$�$��� �� � ����M�M�(�(��0��!������y�y�{�6�+;�+;�+=��%�%�d�m�m�4��sZ�A C8� A;�A9�A;�C8�(C8�9A;�;C5�B*�)C5�* B6�3C5�5B6�6?C5�5C8c���|j�rt�|j|�|xjdz c_|jj�|j |j�y)zyPut an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. r N)rQrr2rr�clearr9rr0s rrYzQueue.put_nowait�sP�� �9�9�;��O�� � �$�����!�#�����������$�-�-�(rc���K�|j�rU|j�j�}|jj |� |�d{���|j�r�U|j�S7�%#|j� |jj |�n#t$rYnwxYw|j�s+|j�s|j|j��xYw�w)zoRemove and return an item from the queue. If queue is empty, wait until an item is available. N)rOrSrTrr/rUrVrWrXr9� get_nowait)r#�getters r�getz Queue.get�s����� �j�j�l��^�^�%�3�3�5�F��M�M� � ��(� ���� �j�j�l�&��� � ��� �� � ����M�M�(�(��0��!������z�z�|�F�,<�,<�,>��%�%�d�m�m�4��sZ�A C7� A:�A8�A:�C7�(C7�8A:�:C4� B)�(C4�) B5�2C4�4B5�5?C4�4C7c��|j�rt�|j�}|j|j�|S)z�Remove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. )rOrr,r9rr0s rr_zQueue.get_nowait�s5�� �:�:�<����y�y�{�����$�-�-�(��rc��|jdkrtd��|xjdzc_|jdk(r|jj�yy)a$Indicate that a formerly enqueued task is complete. Used by queue consumers. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue). Raises ValueError if called more times than there were items placed in the queue. rz!task_done() called too many timesr N)rrWrr r+s r� task_donezQueue.task_done�sR���!�!�Q�&��@�A�A����!�#���!�!�Q�&��N�N��� �'rc��tK�|jdkDr#|jj��d{���yy7��w)aBlock until all items in the queue have been gotten and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer calls task_done() to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks. rN)rr�waitr+s r�joinz Queue.join�s4�����!�!�A�%��.�.�%�%�'�'�'�&�'�s�-8�6�8N)r)rrrrr%r!r,r2r9rArC�classmethodr�__class_getitem__r@rK�propertyr$rOrQr[rYrar_rdrgrrrrrs~�� � �*�%�!� �L�;�$�L�1�� � ������ 1�%�6 )�!�4 �!�( (rrc�R�eZdZdZd�Zejfd�Zejfd�Z y)rz�A subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). c��g|_yr'rNr"s rr!zPriorityQueue._init�� ����rc�*�||j|�yr'rN)r#r1�heappushs rr2zPriorityQueue._put�s������d�#rc�&�||j�Sr'rN)r#�heappops rr,zPriorityQueue._get�s���t�{�{�#�#rN) rrrrr!�heapqror2rqr,rrrrr�s(��� �#(�.�.�$�!�=�=�$rrc�"�eZdZdZd�Zd�Zd�Zy)rzEA subclass of Queue that retrieves most recently added entries first.c��g|_yr'rNr"s rr!zLifoQueue._init�rmrc�:�|jj|�yr'r.r0s rr2zLifoQueue._put�r3rc�6�|jj�Sr')r(�popr+s rr,zLifoQueue._get�s���{�{��� � rN)rrrrr!r2r,rrrrr�s��O��!�!rr)�__all__rrr�typesr�r r� Exceptionrr�_LoopBoundMixinrrrrrr�<module>r}s^�� L������� �� � � � � B(�F�"�"�B(�J $�E� $� !�� !r__pycache__/runners.cpython-312.pyc000064400000023410151706172560013165 0ustar00� T��h>���dZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlmZGd �d ej�Z Gd�d�Zddd �d�Zd�Zy))�Runner�run�N�)� coroutines)�events)� exceptions)�tasks)� constantsc��eZdZdZdZdZy)�_State�created�initialized�closedN)�__name__� __module__�__qualname__�CREATED�INITIALIZED�CLOSED���(/usr/lib64/python3.12/asyncio/runners.pyrrs���G��K� �Frrc�N�eZdZdZddd�d�Zd�Zd�Zd�Zd�Zdd �d �Z d�Z d�Zy) ra5A context manager that controls event loop life cycle. The context manager always creates a new event loop, allows to run async functions inside it, and properly finalizes the loop at the context manager exit. If debug is True, the event loop will be run in debug mode. If loop_factory is passed, it is used for new event loop creation. asyncio.run(main(), debug=True) is a shortcut for with asyncio.Runner(debug=True) as runner: runner.run(main()) The run() method can be called multiple times within the runner's context. This can be useful for interactive console (e.g. IPython), unittest runners, console tools, -- everywhere when async code is called from existing sync framework and where the preferred single asyncio.run() call doesn't work. N��debug�loop_factoryc��tj|_||_||_d|_d|_d|_d|_y)NrF) rr�_state�_debug� _loop_factory�_loop�_context�_interrupt_count�_set_event_loop)�selfrrs r�__init__zRunner.__init__0s:���n�n������)����� ��� � !���$��rc�&�|j�|S�N)� _lazy_init�r%s r� __enter__zRunner.__enter__9s�������rc�$�|j�yr()�close)r%�exc_type�exc_val�exc_tbs r�__exit__zRunner.__exit__=s��� � �rc�F�|jtjury |j}t |�|j|j ��|j|jtj��|jrtjd�|j�d|_tj|_y#|jrtjd�j�d|_tj|_wxYw)zShutdown and close event loop.N)rrrr!�_cancel_all_tasks�run_until_complete�shutdown_asyncgens�shutdown_default_executorr �THREAD_JOIN_TIMEOUTr$r�set_event_loopr-r)r%�loops rr-zRunner.close@s����;�;�f�0�0�0�� (��:�:�D��d�#��#�#�D�$;�$;�$=�>��#�#��.�.�y�/L�/L�M� O��#�#��%�%�d�+��J�J�L��D�J� �-�-�D�K�� �#�#��%�%�d�+��J�J�L��D�J� �-�-�D�K�s �A$C�AD c�:�|j�|jS)zReturn embedded event loop.)r)r!r*s r�get_loopzRunner.get_loopQs�������z�z�r��contextc���tj|�stdj|���t j ��t d��|j�|�|j}|jj||��}tj�tj�urztjtj �tj"urGt%j&|j(|��} tjtj |�nd}d|_ |jj-|�|�Ytjtj �|ur3tjtj tj"�SSS#t$rd}Y��wxYw#t.j0$r4|j*dkDr#t3|dd�}|�|�dk(r t5���wxYw#|�Ytjtj �|ur3tjtj tj"�wwwxYw)z/Run a coroutine inside the embedded event loop.z"a coroutine was expected, got {!r}Nz7Runner.run() cannot be called from a running event loopr<)� main_taskr�uncancel)r�iscoroutine� ValueError�formatr�_get_running_loop�RuntimeErrorr)r"r!�create_task� threading�current_thread�main_thread�signal� getsignal�SIGINT�default_int_handler� functools�partial� _on_sigintr#r4r�CancelledError�getattr�KeyboardInterrupt)r%�coror=�task�sigint_handlerr@s rrz Runner.runVs����%�%�d�+��A�H�H��N�O�O��#�#�%�1��I�K� K� �����?��m�m�G��z�z�%�%�d�G�%�<���$�$�&�)�*?�*?�*A�A�� � ����/�6�3M�3M�M�&�.�.�t���$�O�N� &�� � �f�m�m�^�<�"�N� !��� I��:�:�0�0��6��*��$�$�V�]�]�3�~�E�� � �f�m�m�V�-G�-G�H�F�+��%� &�"&�� &���(�(� ��$�$�q�(�"�4��T�:���'�H�J�!�O�+�-�-�� ���*��$�$�V�]�]�3�~�E�� � �f�m�m�V�-G�-G�H�F�+�s,�$F,�6F=�,F:�9F:�=AH�H�AI$c�$�|jtjurtd��|jtjury|j �Lt j�|_|js<t j|j�d|_ n|j�|_|j�%|jj|j�tj�|_tj|_y)NzRunner is closedT)rrrrErr r�new_event_loopr!r$r8r� set_debug�contextvars�copy_contextr"r*s rr)zRunner._lazy_init�s����;�;�&�-�-�'��1�2�2��;�;�&�,�,�,�����%��.�.�0�D�J��'�'��%�%�d�j�j�1�'+��$��+�+�-�D�J��;�;�"��J�J� � ����-�#�0�0�2�� ��(�(��rc���|xjdz c_|jdk(r=|j�s-|j�|jj d��yt��)Nrc��yr(rrrr�<lambda>z#Runner._on_sigint.<locals>.<lambda>�s��Dr)r#�done�cancelr!�call_soon_threadsaferS)r%�signum�framer?s rrPzRunner._on_sigint�sT������"��� � �A�%�i�n�n�.>������J�J�+�+�L�9���!�!r)rrr�__doc__r&r+r1r-r;rr)rPrrrrrs=���6!%�4�%���(�"� $(�+I�Z)�&"rrrc��tj��td��t||��5}|j |�cddd�S#1swYyxYw)a�Execute the coroutine and return the result. This function runs the passed coroutine, taking care of managing the asyncio event loop, finalizing asynchronous generators and closing the default executor. This function cannot be called when another asyncio event loop is running in the same thread. If debug is True, the event loop will be run in debug mode. If loop_factory is passed, it is used for new event loop creation. This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once. The executor is given a timeout duration of 5 minutes to shutdown. If the executor hasn't finished within that duration, a warning is emitted and the executor is closed. Example: async def main(): await asyncio.sleep(1) print('hello') asyncio.run(main()) Nz8asyncio.run() cannot be called from a running event loopr)rrDrErr)�mainrr�runners rrr�sK��:���!�-��F�H� H� �e�,� 7�6��z�z�$�� 8� 7� 7�s�A�Ac�B�tj|�}|sy|D]}|j��|jtj|ddi��|D]G}|j�r�|j ���%|jd|j �|d���Iy)N�return_exceptionsTz1unhandled exception during asyncio.run() shutdown)�message� exceptionrU)r � all_tasksr`r4�gather� cancelledrk�call_exception_handler)r9� to_cancelrUs rr3r3�s�������%�I�������� �� ���E�L�L�)�L�t�L�M����>�>����>�>��'��'�'�N�!�^�^�-��)� � r)�__all__rZ�enumrNrGrJ�rrrr r �Enumrrrr3rrr�<module>rusW�� ������ �������T�Y�Y��I"�I"�X�$�# �Lr__pycache__/selector_events.cpython-312.opt-1.pyc000064400000173316151706172560015647 0ustar00� T��h̼���dZdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlZddl mZddl mZddl mZddl mZdd l mZdd l mZddl mZddl mZdd lmZeejd�Zer ej4d�Zd�ZGd�dej<�ZGd�dej@ejB�Z"Gd�de"�Z#Gd�de"ejH�Z%y#e$rdZY��wxYw#e$rdZY�pwxYw)z�Event loop using a selector and related classes. A selector is a "notify-when-ready" multiplexer. For a subclass which also includes support for signal handling, see the unix_events sub-module. )�BaseSelectorEventLoop�N�)�base_events)� constants)�events)�futures)� protocols)�sslproto)� transports)�trsock)�logger�sendmsg� SC_IOV_MAXFc�t� |j|�}t|j|z�S#t$rYywxYw�NF)�get_key�boolr�KeyError)�selector�fd�event�keys �0/usr/lib64/python3.12/asyncio/selector_events.py�_test_selector_eventr*sA��(����r�"���C�J�J��&�'�'������s�+� 7�7c���eZdZdZd3�fd� Zd3ddd�d�Z d3ddddejejd�d�Z d4d �Z �fd �Zd�Zd�Z d �Zd�Zd�Zdddejejfd�Zdddejejfd�Zddejejfd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd3d�Zd�Zd �Z d!�Z!d"�Z"d#�Z#d5d$�Z$d%�Z%d&�Z&d'�Z'd(�Z(d)�Z)d*�Z*d+�Z+d3d,�Z,d-�Z-d.�Z.d/�Z/d0�Z0d1�Z1d2�Z2�xZ3S)6rzJSelector event loop. See events.EventLoop for API specification. Nc���t�|��|�tj�}t j d|jj�||_|j�tj�|_y)NzUsing selector: %s) �super�__init__� selectors�DefaultSelectorr �debug� __class__�__name__� _selector�_make_self_pipe�weakref�WeakValueDictionary�_transports)�selfrr"s �rrzBaseSelectorEventLoop.__init__;sa��� ������ �0�0�2�H����)�8�+=�+=�+F�+F�G�!�������"�6�6�8�����extra�serverc�D�|j|�t||||||�S�N)�_ensure_fd_no_transport�_SelectorSocketTransport)r)�sock�protocol�waiterr,r-s r�_make_socket_transportz,BaseSelectorEventLoop._make_socket_transportEs*���$�$�T�*�'��d�H�f�(-�v�7� 7r*F)�server_side�server_hostnamer,r-�ssl_handshake_timeout�ssl_shutdown_timeoutc ��|j|�tj||||||| | ��}t|||||��|jS)N)r8r9r+)r0r �SSLProtocolr1�_app_transport)r)�rawsockr3� sslcontextr4r6r7r,r-r8r9�ssl_protocols r�_make_ssl_transportz)BaseSelectorEventLoop._make_ssl_transportKsW�� �$�$�W�-��+�+��(�J����"7�!5� �� !��w��',�V� =��*�*�*r*c�D�|j|�t||||||�Sr/)r0�_SelectorDatagramTransport)r)r2r3�addressr4r,s r�_make_datagram_transportz.BaseSelectorEventLoop._make_datagram_transport]s,���$�$�T�*�)�$��h�*1�6�5�B� Br*c���|j�rtd��|j�ry|j�t�|��|j�"|jj�d|_yy)Nz!Cannot close a running event loop)� is_running�RuntimeError� is_closed�_close_self_piper�closer$�r)r"s �rrJzBaseSelectorEventLoop.closecsa����?�?���B�C�C��>�>������� �� ���>�>�%��N�N� � �"�!�D�N�&r*c��|j|jj��|jj�d|_|jj�d|_|xj dzc_y)Nr)�_remove_reader�_ssock�filenorJ�_csock� _internal_fds�r)s rrIz&BaseSelectorEventLoop._close_self_pipens\�����D�K�K�.�.�0�1����������������������a��r*c�D�tj�\|_|_|jj d�|jj d�|xj dz c_|j |jj�|j�y)NFr) �socket� socketpairrNrP�setblockingrQ�_add_readerrO�_read_from_selfrRs rr%z%BaseSelectorEventLoop._make_self_pipevsq��#)�#4�#4�#6� ���T�[�������&�������&����a���������+�+�-�t�/C�/C�Dr*c��yr/��r)�datas r�_process_self_dataz(BaseSelectorEventLoop._process_self_data~s��r*c�� |jjd�}|sy|j|��1#t$rY�=t$rYywxYw)Ni)rN�recvr]�InterruptedError�BlockingIOErrorr[s rrXz%BaseSelectorEventLoop._read_from_self�sV��� ��{�{�'�'��-�����'�'��-���$� ��"� �� �s�3�3� A �A �A c��|j}|�y |jd�y#t$r(|jrt j dd��YyYywxYw)N�z3Fail to write a null byte into the self-pipe socketT��exc_info)rP�send�OSError�_debugr r!)r)�csocks r�_write_to_selfz$BaseSelectorEventLoop._write_to_self�sU�������=�� ,��J�J�u���� ,��{�{����0�&*�,�� ,�s�#�,A�A�dc�f�|j|j�|j|||||||� yr/)rWrO�_accept_connection)r)�protocol_factoryr2r>r-�backlogr8r9s r�_start_servingz$BaseSelectorEventLoop._start_serving�s4�� ��������(?�(?�)�4��V�W�.�0D� Fr*c ���t|�D]w} |j�\} } |jrtjd|| | �| jd�d| i}|j || |||||�}|j|��yy#tttf$rYyt$r�} | jtjtjtjtj fvry|j#d| t%j&|�d��|j)|j+��|j-t.j0|j2|||||||� n�Yd} ~ ��dd} ~ wwxYw)Nz#%r got a new connection from %r: %rF�peernamez&socket.accept() out of system resource)�message� exceptionrT)�range�acceptrhr r!rV�_accept_connection2�create_taskrar`�ConnectionAbortedErrorrg�errno�EMFILE�ENFILE�ENOBUFS�ENOMEM�call_exception_handlerr�TransportSocketrMrO� call_laterr�ACCEPT_RETRY_DELAYrp)r)rnr2r>r-ror8r9�_�conn�addrr,rv�excs rrmz(BaseSelectorEventLoop._accept_connection�sX���w��A�" )�!�[�[�]� ��d��;�;��L�L�!F�!'��t�5�� � ��'�2$�T�*���1�1�$�d�E�:�v�)�+?�A��� � ��(�G ��$�%5�7M�N� ��� ��9�9����u�|�|�!&������!>�>� �/�/�#K�%(�"(�"8�"8��">�1�� �'�'���� �6��O�O�I�$@�$@�$(�$7�$7�$4�d�J��$+�-B�$8� :�� :�� �s�AB�E5�E5�&CE0�0E5c��K�d}d} |�}|j�} |r|j|||| d||||�� } n|j||| ||��} | �d{���y7�#t$r| j �d} �wxYw#t tf$r�t$r?}|jr)d|d�}|�||d<| �| |d<|j|�Yd}~yYd}~yd}~wwxYw�w)NT)r4r6r,r-r8r9)r4r,r-z3Error on transport creation for incoming connection)rsrtr3� transport) � create_futurer@r5� BaseExceptionrJ� SystemExit�KeyboardInterruptrhr) r)rnr�r,r>r-r8r9r3r�r4r��contexts rrwz)BaseSelectorEventLoop._accept_connection2�s���� ��� �& 5�'�)�H��'�'�)�F�� �4�4��(�J�v� $�E�&�*?�)=� 5�?� �!�7�7��(�6��!�8�#� � ����� � ����!���� ���-�.� ��� 5��{�{�N�!$��� �'�*2�G�J�'��(�+4�G�K�(��+�+�G�4�4��� 5�sS�C�A B�A �A�A �C�A � A=�=B�C�0C� C�C�Cc�*�|}t|t�s t|j��} |j|}|j�std|�d|����y#ttt f$rtd|���d�wxYw#t$rYywxYw)NzInvalid file object: zFile descriptor z is used by transport ) � isinstance�intrO�AttributeError� TypeError� ValueErrorr(� is_closingrGr)r)rrOr�s rr0z-BaseSelectorEventLoop._ensure_fd_no_transports������&�#�&� K��V�]�]�_�-�� &��(�(��0�I��'�'�)�"�&�r�f�,B� �m�%�&�&�*��#�I�z�:� K� �#8���!?�@�d�J� K�� � �� �s�A�B�$B� B�Bc���|j�tj|||d�} |jj |�}|j|j c}\}}|jj ||tjz||f�|�|j�|S#t$r1|jj|tj|df�Y|SwxYwr/)� _check_closedr�Handler$rr\�modifyr� EVENT_READ�cancelr�register� r)r�callback�args�handler�mask�reader�writers rrWz!BaseSelectorEventLoop._add_readers����������x��t�T�:�� ��.�.�(�(��,�C� &)�Z�Z����"�D�"�6�6��N�N�!�!�"�d�Y�-A�-A�&A�#)�6�"2� 4��!�� � ��� ��� 4��N�N�#�#�B� �(<�(<�%+�T�N� 4�� � 4���B%�%6C�Cc�|�|j�ry |jj|�}|j|jc}\}}|t jz}|s|jj|�n|jj||d|f�|�|j�yy#t$rYywxYw)NFT)rHr$rrr\rr�� unregisterr�r�r�r)rrr�r�r�s rrMz$BaseSelectorEventLoop._remove_reader&s����>�>��� ��.�.�(�(��,�C�&)�Z�Z����"�D�"�6�6��Y�)�)�)�)�D�����)�)�"�-����%�%�b�$��v��?��!�� � ������ �� ���B/�/ B;�:B;c���|j�tj|||d�} |jj |�}|j|j c}\}}|jj ||tjz||f�|�|j�|S#t$r1|jj|tjd|f�Y|SwxYwr/)r�rr�r$rr\r�r�EVENT_WRITEr�rr�r�s r�_add_writerz!BaseSelectorEventLoop._add_writer;s����������x��t�T�:�� ��.�.�(�(��,�C� &)�Z�Z����"�D�"�6�6��N�N�!�!�"�d�Y�-B�-B�&B�#)�6�"2� 4��!�� � ��� ��� 4��N�N�#�#�B� �(=�(=�%)�6�N� 4�� � 4�r�c�|�|j�ry |jj|�}|j|jc}\}}|t jz}|s|jj|�n|jj|||df�|�|j�yy#t$rYywxYw)�Remove a writer callback.FNT)rHr$rrr\rr�r�r�r�rr�s r�_remove_writerz$BaseSelectorEventLoop._remove_writerKs����>�>��� ��.�.�(�(��,�C�&)�Z�Z����"�D�"�6�6��Y�*�*�*�*�D�����)�)�"�-����%�%�b�$����?��!�� � ������ �� �r�c�N�|j|�|j||g|���y)zAdd a reader callback.N)r0rW�r)rr�r�s r� add_readerz BaseSelectorEventLoop.add_readerb�'���$�$�R�(������X�-��-r*c�F�|j|�|j|�S)zRemove a reader callback.)r0rM�r)rs r� remove_readerz#BaseSelectorEventLoop.remove_readerg�!���$�$�R�(��"�"�2�&�&r*c�N�|j|�|j||g|���y)zAdd a writer callback..N)r0r�r�s r� add_writerz BaseSelectorEventLoop.add_writerlr�r*c�F�|j|�|j|�S)r�)r0r�r�s r� remove_writerz#BaseSelectorEventLoop.remove_writerqr�r*c���K�tj|�|jr|j�dk7rt d�� |j|�S#ttf$rYnwxYw|j�}|j�}|j|�|j||j|||�}|jtj|j ||���|�d{���7S�w)z�Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by nbytes. r�the socket must be non-blocking�r�N)r�_check_ssl_socketrh� gettimeoutr�r_rar`r�rOr0rW� _sock_recv�add_done_callback� functools�partial�_sock_read_done)r)r2�n�futrr�s r� sock_recvzBaseSelectorEventLoop.sock_recvvs����� �%�%�d�+��;�;�4�?�?�,��1��>�?�?� ��9�9�Q�<����!1�2� �� ��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�o�o�s�D�!�D��������d�2�2�B�v�F� H��y�y���7�AC5�A�C5�A&�#C5�%A&�&B C5�/C2�0C5c�L�|�|j�s|j|�yyr/)� cancelledr��r)rr�r�s rr�z%BaseSelectorEventLoop._sock_read_done��%���>��!1�!1�!3����r�"�"4r*c��|j�ry |j|�}|j|�y#ttf$rYyt tf$r�t$r}|j|�Yd}~yd}~wwxYwr/) �doner_� set_resultrar`r�r�r�� set_exception)r)r�r2r�r\r�s rr�z BaseSelectorEventLoop._sock_recv�su���8�8�:�� !��9�9�Q�<�D� �N�N�4� �� �!1�2� ���-�.� ��� #����c�"�"�� #���6�A9�A9�A4�4A9c���K�tj|�|jr|j�dk7rt d�� |j|�S#ttf$rYnwxYw|j�}|j�}|j|�|j||j|||�}|jtj|j ||���|�d{���7S�w)z�Receive data from the socket. The received data is written into *buf* (a writable buffer). The return value is the number of bytes written. rr�r�N)rr�rhr�r�� recv_intorar`r�rOr0rW�_sock_recv_intor�r�r�r�)r)r2�bufr�rr�s r�sock_recv_intoz$BaseSelectorEventLoop.sock_recv_into�s����� �%�%�d�+��;�;�4�?�?�,��1��>�?�?� ��>�>�#�&�&���!1�2� �� ��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�&:�&:�C��s�K��������d�2�2�B�v�F� H��y�y��r�c��|j�ry |j|�}|j|�y#ttf$rYyt tf$r�t$r}|j|�Yd}~yd}~wwxYwr/) r�r�r�rar`r�r�r�r�)r)r�r2r��nbytesr�s rr�z%BaseSelectorEventLoop._sock_recv_into�sv���8�8�:�� #��^�^�C�(�F� �N�N�6�"�� �!1�2� ���-�.� ��� #����c�"�"�� #�r�c���K�tj|�|jr|j�dk7rt d�� |j|�S#ttf$rYnwxYw|j�}|j�}|j|�|j||j|||�}|jtj|j ||���|�d{���7S�w)aReceive a datagram from a datagram socket. The return value is a tuple of (bytes, address) representing the datagram received and the address it came from. The maximum amount of data to be received at once is specified by nbytes. rr�r�N)rr�rhr�r��recvfromrar`r�rOr0rW�_sock_recvfromr�r�r�r�)r)r2�bufsizer�rr�s r� sock_recvfromz#BaseSelectorEventLoop.sock_recvfrom�s����� �%�%�d�+��;�;�4�?�?�,��1��>�?�?� ��=�=��)�)���!1�2� �� ��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�&9�&9�3��g�N��������d�2�2�B�v�F� H��y�y��r�c��|j�ry |j|�}|j|�y#ttf$rYyt tf$r�t$r}|j|�Yd}~yd}~wwxYwr/) r�r�r�rar`r�r�r�r�)r)r�r2r��resultr�s rr�z$BaseSelectorEventLoop._sock_recvfrom�sv���8�8�:�� #��]�]�7�+�F� �N�N�6�"�� �!1�2� ���-�.� ��� #����c�"�"�� #�r�c��K�tj|�|jr|j�dk7rt d��|st|�} |j ||�S#ttf$rYnwxYw|j�}|j�}|j|�|j||j||||�}|jtj |j"||���|�d{���7S�w)z�Receive data from the socket. The received data is written into *buf* (a writable buffer). The return value is a tuple of (number of bytes written, address). rr�r�N)rr�rhr�r��len� recvfrom_intorar`r�rOr0rW�_sock_recvfrom_intor�r�r�r�)r)r2r�r�r�rr�s r�sock_recvfrom_intoz(BaseSelectorEventLoop.sock_recvfrom_into�s����� �%�%�d�+��;�;�4�?�?�,��1��>�?�?����X�F� ��%�%�c�6�2�2���!1�2� �� ��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�&>�&>��T�3�"(�*��������d�2�2�B�v�F� H��y�y��s7�A D�A"�!D�"A4�1D�3A4�4B D�>D�?Dc��|j�ry |j||�}|j|�y#ttf$rYyt tf$r�t$r}|j|�Yd}~yd}~wwxYwr/) r�r�r�rar`r�r�r�r�)r)r�r2r�r�r�r�s rr�z)BaseSelectorEventLoop._sock_recvfrom_intosz���8�8�:�� #��'�'��W�5�F� �N�N�6�"�� �!1�2� ���-�.� ��� #����c�"�"�� #�s�7�A:�A:�A5�5A:c ��(K�tj|�|jr|j�dk7rt d�� |j|�}|t|�k(ry|j�}|j�}|j|�|j||j||t|�|g�}|jt!j"|j$||���|�d{���S#ttf$rd}Y��wxYw7��w)�Send data to the socket. The socket must be connected to a remote socket. This method continues to send data from data until either all data has been sent or an error occurs. None is returned on success. On error, an exception is raised, and there is no way to determine how much data, if any, was successfully processed by the receiving end of the connection. rr�Nr�)rr�rhr�r�rfrar`r�r�rOr0r�� _sock_sendall� memoryviewr�r�r��_sock_write_done)r)r2r\r�r�rr�s r�sock_sendallz"BaseSelectorEventLoop.sock_sendalls����� �%�%�d�+��;�;�4�?�?�,��1��>�?�?� �� � �$��A� ��D� �>��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�&8�&8�#�t�",�T�"2�Q�C�9��������d�3�3�R��G� I��y��� �!1�2� ��A� ���s7�AD�C9�B D�4D�5D�9D � D�D � Dc�:�|j�ry|d} |j||d�}||z }|t|�k(r|jd�y||d<y#ttf$rYytt f$r�t$r}|j|�Yd}~yd}~wwxYw�Nr) r�rfrar`r�r�r�r�r�r�)r)r�r2�view�pos�startr�r�s rr�z#BaseSelectorEventLoop._sock_sendall7s����8�8�:���A��� �� � �$�u�v�,�'�A� �� ���C��I���N�N�4� ��C��F�� �!1�2� ���-�.� ��� ����c�"��� �s�A�B�(B�?B�Bc���K�tj|�|jr|j�dk7rt d�� |j||�S#ttf$rYnwxYw|j�}|j�}|j|�|j||j||||�}|jtj|j ||���|�d{���7S�w)r�rr�r�N)rr�rhr�r��sendtorar`r�rOr0r��_sock_sendtor�r�r�r�)r)r2r\rCr�rr�s r�sock_sendtoz!BaseSelectorEventLoop.sock_sendtoMs����� �%�%�d�+��;�;�4�?�?�,��1��>�?�?� ��;�;�t�W�-�-���!1�2� �� ��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�&7�&7��d�D�")�+��������d�3�3�R��G� I��y�y��s7�AC7�A�C7�A'�$C7�&A'�'B C7�1C4�2C7c��|j�ry |j|d|�}|j|�y#ttf$rYyt tf$r�t$r}|j|�Yd}~yd}~wwxYwr�) r�r�r�rar`r�r�r�r�)r)r�r2r\rCr�r�s rr�z"BaseSelectorEventLoop._sock_sendtohsx���8�8�:�� ����D�!�W�-�A� �N�N�1��� �!1�2� ���-�.� ��� #����c�"�"�� #�s�8�A;� A;� A6�6A;c�� K�tj|�|jr|j�dk7rt d��|j tjk(s-tjrd|j tjk(rG|j||j |j|j|���d{���}|d\}}}}}|j�}|j|||� |�d{���d}S7�?7�#d}wxYw�w)zTConnect to a remote socket at address. This method is a coroutine. rr�)�family�type�proto�loopN)rr�rhr�r�r�rT�AF_INET� _HAS_IPv6�AF_INET6�_ensure_resolvedr�r�r�� _sock_connect)r)r2rC�resolvedr�r�s r�sock_connectz"BaseSelectorEventLoop.sock_connectws����� �%�%�d�+��;�;�4�?�?�,��1��>�?�?��;�;�&�.�.�(��%�%�$�+�+����*H�!�2�2�����$�)�)�4�:�:��3���H�#+�1�+��A�q�!�Q��� � �"�����3��g�.� ��9��C������C�s<�CD�D�2D�7D�<D�=D�D�D�D�Dc���|j�} |j|�|jd�d}y#ttf$rf|j|�|j ||j|||�}|jtj|j||���Yd}yttf$r�t$r}|j|�Yd}~d}yd}~wwxYw#d}wxYw)Nr�)rO�connectr�rar`r0r��_sock_connect_cbr�r�r�r�r�r�r�r�)r)r�r2rCrr�r�s rr�z#BaseSelectorEventLoop._sock_connect�s��� �[�[�]�� ��L�L��!� �N�N�4� ��C��# �!1�2� M� �(�(��,��%�%��D�)�)�3��g�?�F��!�!��!�!�$�"7�"7��F�K� M��C��-�.� ��� #����c�"�"��C�� #�� �C�s9�7�C"�A0C�'C"�+C�C�C"�C�C"�"C&c�L�|�|j�s|j|�yyr/)r�r�r�s rr�z&BaseSelectorEventLoop._sock_write_done�r�r*c�v�|j�ry |jtjtj�}|dk7rt|d|���� |j d�d}y#ttf$rYd}yttf$r�t$r}|j|�Yd}~d}yd}~wwxYw#d}wxYw)NrzConnect call failed ) r�� getsockoptrT� SOL_SOCKET�SO_ERRORrgr�rar`r�r�r�r�)r)r�r2rC�errr�s rrz&BaseSelectorEventLoop._sock_connect_cb�s����8�8�:�� ��/�/�&�"3�"3�V�_�_�E�C��a�x��c�%9�'��#C�D�D�� �N�N�4� ��C�� �!1�2� ���C��-�.� ��� #����c�"�"��C�� #�� �C�s<�AA*�B4�*B1�9B4�=B1�B,�%B4�,B1�1B4�4B8c���K�tj|�|jr|j�dk7rt d��|j�}|j ||�|�d{���S7��w)aWAccept a connection. The socket must be bound to an address and listening for connections. The return value is a pair (conn, address) where conn is a new socket object usable to send and receive data on the connection, and address is the address bound to the socket on the other end of the connection. rr�N)rr�rhr�r�r��_sock_accept)r)r2r�s r�sock_acceptz!BaseSelectorEventLoop.sock_accept�s_���� �%�%�d�+��;�;�4�?�?�,��1��>�?�?�� � �"�����#�t�$��y��y�s�A'A0�)A.�*A0c���|j�} |j�\}}|jd�|j||f�y#tt f$rc|j |�|j||j||�}|jtj|j||���Yyttf$r�t$r}|j!|�Yd}~yd}~wwxYw)NFr�)rOrvrVr�rar`r0rWrr�r�r�r�r�r�r�r�)r)r�r2rr�rCr�r�s rrz"BaseSelectorEventLoop._sock_accept�s��� �[�[�]�� ,� �K�K�M�M�D�'����U�#� �N�N�D�'�?�+�� �!1�2� L��(�(��,��%�%�b�$�*;�*;�S�$�G�F��!�!��!�!�$�"6�"6��6�J� L��-�.� ��� #����c�"�"�� #�s�$A � A/C-�;C-�C(�(C-c��K�|j|j=|j�}|j�|j ��d{��� |j|j|||d���d{���|j�|r|j�||j|j<S7�h7�A#|j�|r|j�||j|j<wxYw�w)NF)�fallback) r(�_sock_fd� is_reading� pause_reading�_make_empty_waiter� sock_sendfile�_sock�_reset_empty_waiter�resume_reading)r)�transp�file�offset�countrs r�_sendfile_nativez&BaseSelectorEventLoop._sendfile_native�s��������V�_�_�-��*�*�,�������'�'�)�)�)� 7��+�+�F�L�L�$���5:�,�<�<� �&�&�(���%�%�'�06�D���V�_�_�-� *��<�� �&�&�(���%�%�'�06�D���V�_�_�-�s<�AC:� B6�C:�#B:�6B8�7B:�:=C:�8B:�:=C7�7C:c�d�|D]�\}}|j|jc}\}}|tjzr1|�/|jr|j|�n|j |�|tjzs�z|��}|jr|j|���|j |���yr/) �fileobjr\rr�� _cancelledrM� _add_callbackr�r�)r)� event_listrr�rr�r�s r�_process_eventsz%BaseSelectorEventLoop._process_events�s���#�I�C��(+���S�X�X�%�G�%�f�f��i�*�*�*�v�/A��$�$��'�'��0��&�&�v�.��i�+�+�+��0B��$�$��'�'��0��&�&�v�.�$r*c�b�|j|j��|j�yr/)rMrOrJ)r)r2s r� _stop_servingz#BaseSelectorEventLoop._stop_serving�s�����D�K�K�M�*�� � �r*r/�NNN)r)4r#� __module__�__qualname__�__doc__rr5r�SSL_HANDSHAKE_TIMEOUT�SSL_SHUTDOWN_TIMEOUTr@rDrJrIr%r]rXrjrprmrwr0rWrMr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�rrrrr"r$� __classcell__�r"s@rrr5so���� 9�7�%)�$�7�9=�+� �$��t�"+�"A�"A�!*�!?�!?�+�&CG�B� "� �E� � �,�&#'�t�S�-6�-L�-L�,5�,J�,J�F��D�#�"+�"A�"A�!*�!?�!?� ,)�`�D�"+�"A�"A�!*�!?�!?� -5�^&�$� �*� �..� '� .� '� �,#�!� �*#�"�.#�"�2#�"�>�,�6 ��2�.#��* �,�"7�/�r*rc���eZdZdZdZd�fd� Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zd�Z d�Zej fd �Zdd�Zd�Zd�Zd�Zd�Z�xZS)�_SelectorTransportiNc����t�|�||�tj|�|jd< |j�|jd<d|jvr |j�|jd<||_ |j�|_d|_ |j|�||_t!j"�|_d|_d|_d|_|j�|jj-�||j.|j<y#t$rd|jd<Y��wxYw#tj$rd|jd<Y��wxYw)NrT�socknamerrFr)rrrr��_extra�getsocknamerg�getpeernamerT�errorrrOr�_protocol_connected�set_protocol�_server�collections�deque�_buffer� _conn_lost�_closing�_paused�_attachr()r)r�r2r3r,r-r"s �rrz_SelectorTransport.__init__s8��� �����%� &� 6� 6�t� <����H�� +�&*�&6�&6�&8�D�K�K� �#��T�[�[�(� /�*.�*:�*:�*<����J�'��� ���� �� �#(�� ����(�#����"�(�(�*�������� �����<�<�#��L�L� � �"�*.�������'��+� +�&*�D�K�K� �#� +�� �<�<� /�*.����J�'� /�s#�D'�!E�'E�E�"E*�)E*c��|jjg}|j�|jd�n|jr|jd�|jd|j ���|j��|jj�s�t|jj|j tj�}|r|jd�n|jd�t|jj|j tj�}|rd}nd}|j�}|jd|�d |�d ��djdj|��S) N�closed�closingzfd=zread=pollingz read=idle�polling�idlezwrite=<z , bufsize=�>z<{}>� )r"r#r�appendr<r�_looprHrr$rr�r��get_write_buffer_size�format�join)r)�inforB�stater�s r�__repr__z_SelectorTransport.__repr__'s$�����'�'�(���:�:���K�K��!� �]�]��K�K� �"����c�$�-�-��)�*��:�:�!�$�*�*�*>�*>�*@�*�4�:�:�+?�+?�+/�=�=�)�:N�:N�P�G�����N�+����K�(�*�4�:�:�+?�+?�+/�=�=�+4�+@�+@�B�G��!�����0�0�2�G��K�K�'�%�� �7�)�1�=�>��}�}�S�X�X�d�^�,�,r*c�&�|jd�yr/)�_force_closerRs r�abortz_SelectorTransport.abortCs�����$�r*c� �||_d|_y�NT)� _protocolr5)r)r3s rr6z_SelectorTransport.set_protocolFs��!���#'�� r*c��|jSr/)rSrRs r�get_protocolz_SelectorTransport.get_protocolJs���~�~�r*c��|jSr/)r<rRs rr�z_SelectorTransport.is_closingMs���}�}�r*c�B�|j�xr |jSr/)r�r=rRs rrz_SelectorTransport.is_readingPs���?�?�$�$�9�T�\�\�)9�9r*c���|j�syd|_|jj|j�|jj�rt jd|�yy)NTz%r pauses reading)rr=rGrMr� get_debugr r!rRs rrz _SelectorTransport.pause_readingSsP����� ������ � �!�!�$�-�-�0��:�:���!��L�L�,�d�3�"r*c���|js|jsyd|_|j|j|j�|j j �rtjd|�yy)NFz%r resumes reading) r<r=rWr�_read_readyrGrYr r!rRs rrz!_SelectorTransport.resume_reading[sW���=�=���������������(8�(8�9��:�:���!��L�L�-�t�4�"r*c�P�|jryd|_|jj|j�|jsa|xj dz c_|jj |j�|jj|jd�yy�NTr) r<rGrMrr:r;r�� call_soon�_call_connection_lostrRs rrJz_SelectorTransport.closecss���=�=���� �� � �!�!�$�-�-�0��|�|��O�O�q� �O��J�J�%�%�d�m�m�4��J�J� � ��!;�!;�T�B�r*c�v�|j�-|d|��t|��|jj�yy)Nzunclosed transport )�source)r�ResourceWarningrJ)r)�_warns r�__del__z_SelectorTransport.__del__ms5���:�:�!��'��x�0�/�$�O��J�J����"r*c��t|t�r4|jj�rDt j d||d��n*|jj ||||jd��|j|�y)Nz%r: %sTrd)rsrtr�r3) r�rgrGrYr r!rrSrO)r)r�rss r�_fatal_errorz_SelectorTransport._fatal_errorrse���c�7�#��z�z�#�#�%����X�t�W�t�D��J�J�-�-�"� �!� �N�N� /� � ���#�r*c��|jry|jr?|jj�|jj |j �|js,d|_|jj|j �|xjdz c_|jj|j|�yr]) r;r:�clearrGr�rr<rMr^r_)r)r�s rrOz_SelectorTransport._force_close�s����?�?���<�<��L�L��� ��J�J�%�%�d�m�m�4��}�}� �D�M��J�J�%�%�d�m�m�4����1���� � ���T�7�7��=r*c�� |jr|jj|�|jj �d|_d|_d|_|j}|�|j�d|_yy#|jj �d|_d|_d|_|j}|�|j�d|_wwxYwr/)r5rS�connection_lostrrJrGr7�_detach)r)r�r-s rr_z(_SelectorTransport._call_connection_lost�s��� $��'�'����.�.�s�3��J�J�����D�J�!�D�N��D�J��\�\�F��!���� �#���"�� �J�J�����D�J�!�D�N��D�J��\�\�F��!���� �#���"�s�'A?�?ACc�H�ttt|j��Sr/)�sum�mapr�r:rRs rrHz(_SelectorTransport.get_write_buffer_size�s���3�s�D�L�L�)�*�*r*c�b�|j�sy|jj||g|���yr/)rrGrWr�s rrWz_SelectorTransport._add_reader�s*����� ���� � ���r�8�3�d�3r*)NN)zFatal error on transport)r#r&r'�max_sizerrrMrPr6rUr�rrrrJ�warnings�warnrdrfrOr_rHrWr+r,s@rr.r.sk����H� �E�/�8-�8 �(���:�4�5�C�%�M�M�� � >�$�+�4r*r.c����eZdZdZej jZ d�fd� Z�fd�Z d�Z d�Zd�Zd�Z d �Zd �Zd�Zded dfd�Zd�Zd�Zd�Zd�Z�fd�Zd�Zd�Z�fd�Z�xZS)r1TNc���d|_t�|� |||||�d|_d|_t r|j|_n|j|_tj|j�|jj|jj|�|jj|j |j"|j$�|�,|jjt&j(|d�yyr)�_read_ready_cbrr�_eof� _empty_waiter�_HAS_SENDMSG�_write_sendmsg�_write_ready�_write_sendr�_set_nodelayrrGr^rS�connection_maderWrr[r�_set_result_unless_cancelled)r)r�r2r3r4r,r-r"s �rrz!_SelectorSocketTransport.__init__�s����#��� ����t�X�u�f�=��� �!���� $� 3� 3�D�� $� 0� 0�D�� � � ����,�� � ���T�^�^�;�;�T�B�� � ���T�-�-�!�]�]�D�,<�,<� >����J�J� � ��!E�!E�!'�� /�r*c���t|tj�r|j|_n|j |_t�|�|�yr/)r�r �BufferedProtocol�_read_ready__get_bufferru�_read_ready__data_receivedrr6)r)r3r"s �rr6z%_SelectorSocketTransport.set_protocol�s<����h� � :� :�;�"&�">�">�D��"&�"A�"A�D�� ���X�&r*c�$�|j�yr/)rurRs rr[z$_SelectorSocketTransport._read_ready�s�����r*c��|jry |jjd�}t|�st d�� |jj|�}|s|j�y |jj|�y#t tf$r�t$r}|j|d�Yd}~yd}~wwxYw#ttf$rYyt tf$r�t$r}|j|d�Yd}~yd}~wwxYw#t tf$r�t$r}|j|d�Yd}~yd}~wwxYw)N���z%get_buffer() returned an empty bufferz/Fatal error: protocol.get_buffer() call failed.�$Fatal read error on socket transportz3Fatal error: protocol.buffer_updated() call failed.)r;rS� get_bufferr�rGr�r�r�rfrr�rar`�_read_ready__on_eof�buffer_updated)r)r�r�r�s rr�z0_SelectorSocketTransport._read_ready__get_buffer�sC���?�?�� ��.�.�+�+�B�/�C��s�8�"�#J�K�K�� ��Z�Z�)�)�#�.�F���$�$�&�� L��N�N�)�)�&�1��-�-�.� ��� �����F� H��� �� �!1�2� ���-�.� ��� ����c�#I�J��� ���-�.� ��� L�����J� L� L�� L�sM�1B �C�1D� C�%B<�<C�D�D�,D�D�D?�#D:�:D?c���|jry |jj|j�}|s|j�y |jj|�y#tt f$rYyttf$r�t$r}|j|d�Yd}~yd}~wwxYw#ttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nr�z2Fatal error: protocol.data_received() call failed.) r;rr_rprar`r�r�r�rfr�rS� data_received)r)r\r�s rr�z3_SelectorSocketTransport._read_ready__data_received�s����?�?�� ��:�:�?�?�4�=�=�1�D���$�$�&�� K��N�N�(�(��.�� �!1�2� ���-�.� ��� ����c�#I�J��� ���-�.� ��� K�����I� K� K�� K�s5�%A$�B+�$B(�5B(�B#�#B(�+C�C�Cc�x�|jj�rtjd|� |jj�}|r&|jj|j�y|j�y#ttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rGrYr r!rS�eof_receivedr�r�r�rfrMrrJ)r)� keep_openr�s rr�z,_SelectorSocketTransport._read_ready__on_eof s����:�:���!��L�L�*�D�1� ����3�3�5�I�� �J�J�%�%�d�m�m�4��J�J�L���-�.� ��� �����H� J��� �s�B�B9�B4�4B9c�<�t|tttf�s!t dt|�j����|jrtd��|j�td��|sy|jrH|jtjk\rtjd�|xjdz c_ y|js] |j j#|�}t|�|d}|sy|j0j3|j4|j6�|jj9|�|j;�y#t$t&f$rY�mt(t*f$r�t,$r}|j/|d�Yd}~yd}~wwxYw)N�/data argument must be a bytes-like object, not z%Cannot call write() after write_eof()z(unable to write; sendfile is in progress�socket.send() raised exception.r�%Fatal write error on socket transport)r��bytes� bytearrayr�r�r�r#rvrGrwr;r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr �warningr:rrfrar`r�r�r�rfrGr�rrzrF�_maybe_pause_protocol)r)r\r�r�s r�writez_SelectorSocketTransport.writes_���$�� �:� >�?��#�#'��:�#6�#6�"9�;�<� <��9�9��F�G�G����)��I�J�J����?�?����)�"M�"M�M����@�A��O�O�q� �O���|�|� ��J�J�O�O�D�)��"�$�'���+�����J�J�"�"�4�=�=�$�2C�2C�D� �����D�!��"�"�$��!$�%5�6� ��� 1�2� �� � ��!�!�#�'N�O��� �s�E�F�(F�?F�Fc�J�tj|jt�Sr/)� itertools�islicer:rrRs r�_get_sendmsg_bufferz,_SelectorSocketTransport._get_sendmsg_bufferFs��������j�9�9r*c�r�|jry |jj|j��}|j |�|j�|js�|jj|j�|j�|jjd�|jr|jd�y|jr*|jjt j"�yyy#t$t&f$rYyt(t*f$r�t,$r�}|jj|j�|jj/�|j1|d�|j� |jj3|�Yd}~yYd}~yd}~wwxYw�Nr�)r;rrr��_adjust_leftover_buffer�_maybe_resume_protocolr:rGr�rrwr�r<r_rv�shutdownrT�SHUT_WRrar`r�r�r�rhrfr�)r)r�r�s rryz'_SelectorSocketTransport._write_sendmsgIsV���?�?�� 8��Z�Z�'�'��(@�(@�(B�C�F��(�(��0� �'�'�)��<�<�� � �)�)�$�-�-�8��%�%�1��&�&�1�1�$�7��=�=��.�.�t�4��Y�Y��J�J�'�'����7�� �� �!1�2� ���-�.� ��� 6��J�J�%�%�d�m�m�4��L�L��� ����c�#J�K��!�!�-��"�"�0�0��5�5�.�� 6�s�:D�F6�F6�/A8F1�1F6r��returnc��|j}|r?|j�}t|�}||kr||z}n|j||d�y|r�>yyr/)r:�popleftr�� appendleft)r)r��buffer�b�b_lens rr�z0_SelectorSocketTransport._adjust_leftover_bufferesO���������� �A���F�E�����%����!�!�!�F�G�*�-��r*c��|jry |jj�}|jj |�}|t|�k7r|jj ||d�|j�|js�|jj|j�|j�|jjd�|jr|jd�y|jr*|jj!t"j$�yyy#t&t(f$rYyt*t,f$r�t.$r�}|jj|j�|jj1�|j3|d�|j� |jj5|�Yd}~yYd}~yd}~wwxYwr�)r;r:r�rrfr�r�r�rGr�rrwr�r<r_rvr�rTr�rar`r�r�r�rhrfr�)r)r�r�r�s rr{z$_SelectorSocketTransport._write_sendpss���?�?�� 8��\�\�)�)�+�F�� � ����'�A��C��K�����'�'��q�r� �3� �'�'�)��<�<�� � �)�)�$�-�-�8��%�%�1��&�&�1�1�$�7��=�=��.�.�t�4��Y�Y��J�J�'�'����7�� �� �!1�2� ���-�.� ��� 6��J�J�%�%�d�m�m�4��L�L��� ����c�#J�K��!�!�-��"�"�0�0��5�5�.�� 6�s�A!D.�.G�?G�A8G�Gc��|js|jryd|_|js*|jj t j�yyrR)r<rvr:rr�rTr�rRs r� write_eofz"_SelectorSocketTransport.write_eof�s;���=�=�D�I�I���� ��|�|��J�J������/�r*c��|jrtd��|j�td��|sy|jj |D�cgc] }t|���c}�|j �|jrA|jj|j|j�|j�yycc}w)Nz*Cannot call writelines() after write_eof()z-unable to writelines; sendfile is in progress)rvrGrwr:�extendr�rzrGr�rr�)r)�list_of_datar\s r� writelinesz#_SelectorSocketTransport.writelines�s����9�9��K�L�L����)��N�O�O��������,�G�,�$�Z��-�,�G�H������<�<��J�J�"�"�4�=�=�$�2C�2C�D��&�&�(���Hs�Cc��yrRrZrRs r� can_write_eofz&_SelectorSocketTransport.can_write_eof�s��r*c��� t�|�|�d|_|j�%|jj td��yy#d|_|j�%|jj td��wwxYw)NzConnection is closed by peer)rr_rzrwr��ConnectionError)r)r�r"s �rr_z._SelectorSocketTransport._call_connection_lost�s���� E��G�)�#�.� $�D���!�!�-��"�"�0�0�#�$B�C�E�.��!%�D���!�!�-��"�"�0�0�#�$B�C�E�.�s�A�:Bc���|j�td��|jj�|_|js|jjd�|jS)NzEmpty waiter is already set)rwrGrGr�r:r�rRs rrz+_SelectorSocketTransport._make_empty_waiter�sV�����)��<�=�=�!�Z�Z�5�5�7����|�|����)�)�$�/��!�!�!r*c��d|_yr/)rwrRs rrz,_SelectorSocketTransport._reset_empty_waiter�s ��!��r*c�0��d|_t�|� �yr/)rurrJrKs �rrJz_SelectorSocketTransport.close�s���"��� �� �r*r%)r#r&r'�_start_tls_compatibler� _SendfileMode� TRY_NATIVE�_sendfile_compatiblerr6r[r�r�r�r�r�ryr�r�r{r�r�r�r_rrrJr+r,s@rr1r1�s���� ��$�2�2�=�=��48�$(�/�2'��#L�JK�2�*%%�N:�8�8 �c� �d� �8�>0�)��E�"�"��r*r1c�V��eZdZejZ d�fd� Zd�Zd�Zdd�Z d�Z �xZS)rBc�x��t�|�||||�||_d|_|jj|jj|�|jj|j|j|j�|�,|jjtj|d�yyr�) rr�_address�_buffer_sizerGr^rSr}rWrr[rr~)r)r�r2r3rCr4r,r"s �rrz#_SelectorDatagramTransport.__init__�s���� ����t�X�u�5��� ����� � ���T�^�^�;�;�T�B�� � ���T�-�-�!�]�]�D�,<�,<� >����J�J� � ��!E�!E�!'�� /�r*c��|jSr/)r�rRs rrHz0_SelectorDatagramTransport.get_write_buffer_size�s��� � � r*c��|jry |jj|j�\}}|jj||�y#ttf$rYyt$r%}|jj|�Yd}~yd}~wttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nz&Fatal read error on datagram transport)r;rr�rprS�datagram_receivedrar`rg�error_receivedr�r�r�rf�r)r\r�r�s rr[z&_SelectorDatagramTransport._read_ready�s����?�?�� 9����,�,�T�]�]�;�J�D�$� �N�N�,�,�T�4�8�� �!1�2� ��� /��N�N�)�)�#�.�.���-�.� ��� M����c�#K�L�L�� M�s)�(A�C�%C�-B � C�(B?�?Cc�Z�t|tttf�s!t dt|�j����|sy|jr4|d|jfvrtd|j����|j}|jrT|jrH|jtjk\rtjd�|xjdz c_ y|jsI |jdr|j j#|�y|j j%||�y|jjAt|�|f�|xjBtE|�z c_!|jG�y#t&t(f$r3|j*j-|j.|j0�Y��t2$r%}|j4j7|�Yd}~yd}~wt8t:f$r�t<$r}|j?|d�Yd}~yd}~wwxYw)Nr�z!Invalid address: must be None or r�rrr�'Fatal write error on datagram transport)$r�r�r�r�r�r�r#r�r�r;rr�r r�r:r1rrfr�rar`rGr�r� _sendto_readyrgrSr�r�r�r�rfrFr�r�r�r�s rr�z!_SelectorDatagramTransport.sendto�s����$�� �:� >�?��#�#'��:�#6�#6�"9�;�<� <����=�=��D�$�-�-�0�0� �7�� � ��G�I�I��=�=�D��?�?�t�}�}����)�"M�"M�M����@�A��O�O�q� �O���|�|� ��;�;�z�*��J�J�O�O�D�)���J�J�%�%�d�D�1�� �����U�4�[�$�/�0����S��Y�&���"�"�$��$�%5�6� J�� � �&�&�t�}�}�d�6H�6H�I�� ����-�-�c�2���� 1�2� �� � ��!�!��B�D��� �s0�-*F �F � ?H*�H*�G3�3H*�H%�%H*c�X�|jr�|jj�\}}|xjt|�zc_ |jdr|j j |�n|j j||�|jr��|j%�|jsD|j&j)|j*�|j,r|j/d�yyy#ttf$r>|jj||f�|xjt|�z c_Y��t$r%}|jj|�Yd}~yd}~wttf$r�t $r}|j#|d�Yd}~yd}~wwxYw)Nrrr�)r:r�r�r�r1rrfr�rar`r�rgrSr�r�r�r�rfr�rGr�rr<r_r�s rr�z(_SelectorDatagramTransport._sendto_readysQ���l�l����-�-�/�J�D�$�����T��*�� ��;�;�z�*��J�J�O�O�D�)��J�J�%�%�d�D�1��l�l�, �#�#�%��|�|��J�J�%�%�d�m�m�4��}�}��*�*�4�0����$�%5�6� ����'�'��t��5��!�!�S��Y�.�!��� ����-�-�c�2���� 1�2� �� � ��!�!��B�D��� �s,� AC>�>A F)� F)�E2�2F)� F$�$F)r%r/)r#r&r'r8r9�_buffer_factoryrrHr[r�r�r+r,s@rrBrB�s.���!�'�'�O�59�$(�/�!�9� *%�X1r*rB)&r(�__all__r8rzr�r��osrrTrqr&�ssl�ImportError�rrrrr r rr�logr �hasattrrx�sysconfrrgr� BaseEventLoopr�_FlowControlMixin� Transportr.r1�DatagramTransportrBrZr*r�<module>r�s���#������ �� ���������������v�}�}�i�0�����R�Z�Z��-� � (�I�K�5�5�I�X_4��5�5�#�-�-�_4�DZ�1�Z�zl1�!3�Z�5Q�5Q�l1��Y%�� �C���$�����s#�C&�:C3�&C0�/C0�3C=�<C=__pycache__/selector_events.cpython-312.opt-2.pyc000064400000167365151706172560015657 0ustar00� T��h̼��� dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlm Z ddlmZddlmZddlmZddlmZdd lmZdd lmZddlmZddlmZeejd �Zer ej2d�Zd�ZGd�de j:�ZGd�dej>ej@�Z!Gd�de!�Z"Gd�de!ejF�Z$y#e$rdZ Y��wxYw#e$rdZY�pwxYw))�BaseSelectorEventLoop�N�)�base_events)� constants)�events)�futures)� protocols)�sslproto)� transports)�trsock)�logger�sendmsg� SC_IOV_MAXFc�t� |j|�}t|j|z�S#t$rYywxYw�NF)�get_key�boolr�KeyError)�selector�fd�event�keys �0/usr/lib64/python3.12/asyncio/selector_events.py�_test_selector_eventr*sA��(����r�"���C�J�J��&�'�'������s�+� 7�7c���eZdZ d2�fd� Zd2ddd�d�Z d2ddddejejd�d�Z d3d�Z �fd �Z d �Zd�Zd�Z d �Zd�Zdddejejfd�Zdddejejfd�Zddejejfd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd2d�Zd�Zd�Zd �Z d!�Z!d"�Z"d4d#�Z#d$�Z$d%�Z%d&�Z&d'�Z'd(�Z(d)�Z)d*�Z*d2d+�Z+d,�Z,d-�Z-d.�Z.d/�Z/d0�Z0d1�Z1�xZ2S)5rNc���t�|��|�tj�}t j d|jj�||_|j�tj�|_y)NzUsing selector: %s) �super�__init__� selectors�DefaultSelectorr �debug� __class__�__name__� _selector�_make_self_pipe�weakref�WeakValueDictionary�_transports)�selfrr"s �rrzBaseSelectorEventLoop.__init__;sa��� ������ �0�0�2�H����)�8�+=�+=�+F�+F�G�!�������"�6�6�8�����extra�serverc�D�|j|�t||||||�S�N)�_ensure_fd_no_transport�_SelectorSocketTransport)r)�sock�protocol�waiterr,r-s r�_make_socket_transportz,BaseSelectorEventLoop._make_socket_transportEs*���$�$�T�*�'��d�H�f�(-�v�7� 7r*F)�server_side�server_hostnamer,r-�ssl_handshake_timeout�ssl_shutdown_timeoutc ��|j|�tj||||||| | ��}t|||||��|jS)N)r8r9r+)r0r �SSLProtocolr1�_app_transport)r)�rawsockr3� sslcontextr4r6r7r,r-r8r9�ssl_protocols r�_make_ssl_transportz)BaseSelectorEventLoop._make_ssl_transportKsW�� �$�$�W�-��+�+��(�J����"7�!5� �� !��w��',�V� =��*�*�*r*c�D�|j|�t||||||�Sr/)r0�_SelectorDatagramTransport)r)r2r3�addressr4r,s r�_make_datagram_transportz.BaseSelectorEventLoop._make_datagram_transport]s,���$�$�T�*�)�$��h�*1�6�5�B� Br*c���|j�rtd��|j�ry|j�t�|��|j�"|jj�d|_yy)Nz!Cannot close a running event loop)� is_running�RuntimeError� is_closed�_close_self_piper�closer$�r)r"s �rrJzBaseSelectorEventLoop.closecsa����?�?���B�C�C��>�>������� �� ���>�>�%��N�N� � �"�!�D�N�&r*c��|j|jj��|jj�d|_|jj�d|_|xj dzc_y)Nr)�_remove_reader�_ssock�filenorJ�_csock� _internal_fds�r)s rrIz&BaseSelectorEventLoop._close_self_pipens\�����D�K�K�.�.�0�1����������������������a��r*c�D�tj�\|_|_|jj d�|jj d�|xj dz c_|j |jj�|j�y)NFr) �socket� socketpairrNrP�setblockingrQ�_add_readerrO�_read_from_selfrRs rr%z%BaseSelectorEventLoop._make_self_pipevsq��#)�#4�#4�#6� ���T�[�������&�������&����a���������+�+�-�t�/C�/C�Dr*c��yr/��r)�datas r�_process_self_dataz(BaseSelectorEventLoop._process_self_data~s��r*c�� |jjd�}|sy|j|��1#t$rY�=t$rYywxYw)Ni)rN�recvr]�InterruptedError�BlockingIOErrorr[s rrXz%BaseSelectorEventLoop._read_from_self�sV��� ��{�{�'�'��-�����'�'��-���$� ��"� �� �s�3�3� A �A �A c��|j}|�y |jd�y#t$r(|jrt j dd��YyYywxYw)N�z3Fail to write a null byte into the self-pipe socketT��exc_info)rP�send�OSError�_debugr r!)r)�csocks r�_write_to_selfz$BaseSelectorEventLoop._write_to_self�sU�������=�� ,��J�J�u���� ,��{�{����0�&*�,�� ,�s�#�,A�A�dc�f�|j|j�|j|||||||� yr/)rWrO�_accept_connection)r)�protocol_factoryr2r>r-�backlogr8r9s r�_start_servingz$BaseSelectorEventLoop._start_serving�s4�� ��������(?�(?�)�4��V�W�.�0D� Fr*c ���t|�D]w} |j�\} } |jrtjd|| | �| jd�d| i}|j || |||||�}|j|��yy#tttf$rYyt$r�} | jtjtjtjtj fvry|j#d| t%j&|�d��|j)|j+��|j-t.j0|j2|||||||� n�Yd} ~ ��dd} ~ wwxYw)Nz#%r got a new connection from %r: %rF�peernamez&socket.accept() out of system resource)�message� exceptionrT)�range�acceptrhr r!rV�_accept_connection2�create_taskrar`�ConnectionAbortedErrorrg�errno�EMFILE�ENFILE�ENOBUFS�ENOMEM�call_exception_handlerr�TransportSocketrMrO� call_laterr�ACCEPT_RETRY_DELAYrp)r)rnr2r>r-ror8r9�_�conn�addrr,rv�excs rrmz(BaseSelectorEventLoop._accept_connection�sX���w��A�" )�!�[�[�]� ��d��;�;��L�L�!F�!'��t�5�� � ��'�2$�T�*���1�1�$�d�E�:�v�)�+?�A��� � ��(�G ��$�%5�7M�N� ��� ��9�9����u�|�|�!&������!>�>� �/�/�#K�%(�"(�"8�"8��">�1�� �'�'���� �6��O�O�I�$@�$@�$(�$7�$7�$4�d�J��$+�-B�$8� :�� :�� �s�AB�E5�E5�&CE0�0E5c��K�d}d} |�}|j�} |r|j|||| d||||�� } n|j||| ||��} | �d{���y7�#t$r| j �d} �wxYw#t tf$r�t$r?}|jr)d|d�}|�||d<| �| |d<|j|�Yd}~yYd}~yd}~wwxYw�w)NT)r4r6r,r-r8r9)r4r,r-z3Error on transport creation for incoming connection)rsrtr3� transport) � create_futurer@r5� BaseExceptionrJ� SystemExit�KeyboardInterruptrhr) r)rnr�r,r>r-r8r9r3r�r4r��contexts rrwz)BaseSelectorEventLoop._accept_connection2�s���� ��� �& 5�'�)�H��'�'�)�F�� �4�4��(�J�v� $�E�&�*?�)=� 5�?� �!�7�7��(�6��!�8�#� � ����� � ����!���� ���-�.� ��� 5��{�{�N�!$��� �'�*2�G�J�'��(�+4�G�K�(��+�+�G�4�4��� 5�sS�C�A B�A �A�A �C�A � A=�=B�C�0C� C�C�Cc�*�|}t|t�s t|j��} |j|}|j�std|�d|����y#ttt f$rtd|���d�wxYw#t$rYywxYw)NzInvalid file object: zFile descriptor z is used by transport ) � isinstance�intrO�AttributeError� TypeError� ValueErrorr(� is_closingrGr)r)rrOr�s rr0z-BaseSelectorEventLoop._ensure_fd_no_transports������&�#�&� K��V�]�]�_�-�� &��(�(��0�I��'�'�)�"�&�r�f�,B� �m�%�&�&�*��#�I�z�:� K� �#8���!?�@�d�J� K�� � �� �s�A�B�$B� B�Bc���|j�tj|||d�} |jj |�}|j|j c}\}}|jj ||tjz||f�|�|j�|S#t$r1|jj|tj|df�Y|SwxYwr/)� _check_closedr�Handler$rr\�modifyr� EVENT_READ�cancelr�register� r)r�callback�args�handler�mask�reader�writers rrWz!BaseSelectorEventLoop._add_readers����������x��t�T�:�� ��.�.�(�(��,�C� &)�Z�Z����"�D�"�6�6��N�N�!�!�"�d�Y�-A�-A�&A�#)�6�"2� 4��!�� � ��� ��� 4��N�N�#�#�B� �(<�(<�%+�T�N� 4�� � 4���B%�%6C�Cc�|�|j�ry |jj|�}|j|jc}\}}|t jz}|s|jj|�n|jj||d|f�|�|j�yy#t$rYywxYw�NFT)rHr$rrr\rr�� unregisterr�r�r�r)rrr�r�r�s rrMz$BaseSelectorEventLoop._remove_reader&s����>�>��� ��.�.�(�(��,�C�&)�Z�Z����"�D�"�6�6��Y�)�)�)�)�D�����)�)�"�-����%�%�b�$��v��?��!�� � ������ �� �s�B/�/ B;�:B;c���|j�tj|||d�} |jj |�}|j|j c}\}}|jj ||tjz||f�|�|j�|S#t$r1|jj|tjd|f�Y|SwxYwr/)r�rr�r$rr\r�r�EVENT_WRITEr�rr�r�s r�_add_writerz!BaseSelectorEventLoop._add_writer;s����������x��t�T�:�� ��.�.�(�(��,�C� &)�Z�Z����"�D�"�6�6��N�N�!�!�"�d�Y�-B�-B�&B�#)�6�"2� 4��!�� � ��� ��� 4��N�N�#�#�B� �(=�(=�%)�6�N� 4�� � 4�r�c�~� |j�ry |jj|�}|j|jc}\}}|t jz}|s|jj|�n|jj|||df�|�|j�yy#t$rYywxYwr�)rHr$rrr\rr�r�r�r�rr�s r�_remove_writerz$BaseSelectorEventLoop._remove_writerKs���'��>�>��� ��.�.�(�(��,�C�&)�Z�Z����"�D�"�6�6��Y�*�*�*�*�D�����)�)�"�-����%�%�b�$����?��!�� � ������ �� �s�B0�0 B<�;B<c�P� |j|�|j||g|���yr/)r0rW�r)rr�r�s r� add_readerz BaseSelectorEventLoop.add_readerbs*��$��$�$�R�(������X�-��-r*c�H� |j|�|j|�Sr/)r0rM�r)rs r� remove_readerz#BaseSelectorEventLoop.remove_readerg�$��'��$�$�R�(��"�"�2�&�&r*c�P� |j|�|j||g|���yr/)r0r�r�s r� add_writerz BaseSelectorEventLoop.add_writerls*��%��$�$�R�(������X�-��-r*c�H� |j|�|j|�Sr/)r0r�r�s r� remove_writerz#BaseSelectorEventLoop.remove_writerqr�r*c���K� tj|�|jr|j�dk7rt d�� |j|�S#ttf$rYnwxYw|j�}|j�}|j|�|j||j|||�}|jtj|j ||���|�d{���7S�w�Nr�the socket must be non-blocking�r�)r�_check_ssl_socketrh� gettimeoutr�r_rar`r�rOr0rW� _sock_recv�add_done_callback� functools�partial�_sock_read_done)r)r2�n�futrr�s r� sock_recvzBaseSelectorEventLoop.sock_recvvs����� � �%�%�d�+��;�;�4�?�?�,��1��>�?�?� ��9�9�Q�<����!1�2� �� ��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�o�o�s�D�!�D��������d�2�2�B�v�F� H��y�y���7�AC6�A�C6�A'�$C6�&A'�'B C6�0C3�1C6c�L�|�|j�s|j|�yyr/)� cancelledr��r)rr�r�s rr�z%BaseSelectorEventLoop._sock_read_done��%���>��!1�!1�!3����r�"�"4r*c��|j�ry |j|�}|j|�y#ttf$rYyt tf$r�t$r}|j|�Yd}~yd}~wwxYwr/) �doner_� set_resultrar`r�r�r�� set_exception)r)r�r2r�r\r�s rr�z BaseSelectorEventLoop._sock_recv�su���8�8�:�� !��9�9�Q�<�D� �N�N�4� �� �!1�2� ���-�.� ��� #����c�"�"�� #���6�A9�A9�A4�4A9c���K� tj|�|jr|j�dk7rt d�� |j|�S#ttf$rYnwxYw|j�}|j�}|j|�|j||j|||�}|jtj|j ||���|�d{���7S�wr�)rr�rhr�r�� recv_intorar`r�rOr0rW�_sock_recv_intor�r�r�r�)r)r2�bufr�rr�s r�sock_recv_intoz$BaseSelectorEventLoop.sock_recv_into�s����� � �%�%�d�+��;�;�4�?�?�,��1��>�?�?� ��>�>�#�&�&���!1�2� �� ��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�&:�&:�C��s�K��������d�2�2�B�v�F� H��y�y��r�c��|j�ry |j|�}|j|�y#ttf$rYyt tf$r�t$r}|j|�Yd}~yd}~wwxYwr/) r�r�r�rar`r�r�r�r�)r)r�r2r��nbytesr�s rr�z%BaseSelectorEventLoop._sock_recv_into�sv���8�8�:�� #��^�^�C�(�F� �N�N�6�"�� �!1�2� ���-�.� ��� #����c�"�"�� #�r�c���K� tj|�|jr|j�dk7rt d�� |j|�S#ttf$rYnwxYw|j�}|j�}|j|�|j||j|||�}|jtj|j ||���|�d{���7S�wr�)rr�rhr�r��recvfromrar`r�rOr0rW�_sock_recvfromr�r�r�r�)r)r2�bufsizer�rr�s r� sock_recvfromz#BaseSelectorEventLoop.sock_recvfrom�s����� � �%�%�d�+��;�;�4�?�?�,��1��>�?�?� ��=�=��)�)���!1�2� �� ��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�&9�&9�3��g�N��������d�2�2�B�v�F� H��y�y��r�c��|j�ry |j|�}|j|�y#ttf$rYyt tf$r�t$r}|j|�Yd}~yd}~wwxYwr/) r�r�r�rar`r�r�r�r�)r)r�r2r��resultr�s rr�z$BaseSelectorEventLoop._sock_recvfrom�sv���8�8�:�� #��]�]�7�+�F� �N�N�6�"�� �!1�2� ���-�.� ��� #����c�"�"�� #�r�c��K� tj|�|jr|j�dk7rt d��|st|�} |j ||�S#ttf$rYnwxYw|j�}|j�}|j|�|j||j||||�}|jtj |j"||���|�d{���7S�wr�)rr�rhr�r��len� recvfrom_intorar`r�rOr0rW�_sock_recvfrom_intor�r�r�r�)r)r2r�r�r�rr�s r�sock_recvfrom_intoz(BaseSelectorEventLoop.sock_recvfrom_into�s����� � �%�%�d�+��;�;�4�?�?�,��1��>�?�?����X�F� ��%�%�c�6�2�2���!1�2� �� ��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�&>�&>��T�3�"(�*��������d�2�2�B�v�F� H��y�y��s7�AD�A#�"D�#A5�2D�4A5�5B D�?D�Dc��|j�ry |j||�}|j|�y#ttf$rYyt tf$r�t$r}|j|�Yd}~yd}~wwxYwr/) r�r�r�rar`r�r�r�r�)r)r�r2r�r�r�r�s rr�z)BaseSelectorEventLoop._sock_recvfrom_intosz���8�8�:�� #��'�'��W�5�F� �N�N�6�"�� �!1�2� ���-�.� ��� #����c�"�"�� #�s�7�A:�A:�A5�5A:c ��*K� tj|�|jr|j�dk7rt d�� |j|�}|t|�k(ry|j�}|j�}|j|�|j||j||t|�|g�}|jt!j"|j$||���|�d{���S#ttf$rd}Y��wxYw7��wr�)rr�rhr�r�rfrar`r�r�rOr0r�� _sock_sendall� memoryviewr�r�r��_sock_write_done)r)r2r\r�r�rr�s r�sock_sendallz"BaseSelectorEventLoop.sock_sendalls����� � �%�%�d�+��;�;�4�?�?�,��1��>�?�?� �� � �$��A� ��D� �>��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�&8�&8�#�t�",�T�"2�Q�C�9��������d�3�3�R��G� I��y��� �!1�2� ��A� ���s7�AD�C:�B D�5D�6D�:D�D� D�Dc�:�|j�ry|d} |j||d�}||z }|t|�k(r|jd�y||d<y#ttf$rYytt f$r�t$r}|j|�Yd}~yd}~wwxYw�Nr) r�rfrar`r�r�r�r�r�r�)r)r�r2�view�pos�startr�r�s rr�z#BaseSelectorEventLoop._sock_sendall7s����8�8�:���A��� �� � �$�u�v�,�'�A� �� ���C��I���N�N�4� ��C��F�� �!1�2� ���-�.� ��� ����c�"��� �s�A�B�(B�?B�Bc���K� tj|�|jr|j�dk7rt d�� |j||�S#ttf$rYnwxYw|j�}|j�}|j|�|j||j||||�}|jtj|j ||���|�d{���7S�wr�)rr�rhr�r��sendtorar`r�rOr0r��_sock_sendtor�r�r�r�)r)r2r\rCr�rr�s r�sock_sendtoz!BaseSelectorEventLoop.sock_sendtoMs����� � �%�%�d�+��;�;�4�?�?�,��1��>�?�?� ��;�;�t�W�-�-���!1�2� �� ��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�&7�&7��d�D�")�+��������d�3�3�R��G� I��y�y��s7�AC8�A�C8�A(�%C8�'A(�(B C8�2C5�3C8c��|j�ry |j|d|�}|j|�y#ttf$rYyt tf$r�t$r}|j|�Yd}~yd}~wwxYwr�) r�r�r�rar`r�r�r�r�)r)r�r2r\rCr�r�s rr�z"BaseSelectorEventLoop._sock_sendtohsx���8�8�:�� ����D�!�W�-�A� �N�N�1��� �!1�2� ���-�.� ��� #����c�"�"�� #�s�8�A;� A;� A6�6A;c��"K� tj|�|jr|j�dk7rt d��|j tjk(s-tjrd|j tjk(rG|j||j |j|j|���d{���}|d\}}}}}|j�}|j|||� |�d{���d}S7�?7�#d}wxYw�w)Nrr�)�family�type�proto�loop)rr�rhr�r�r�rT�AF_INET� _HAS_IPv6�AF_INET6�_ensure_resolvedr�r�r�� _sock_connect)r)r2rC�resolvedr�r�s r�sock_connectz"BaseSelectorEventLoop.sock_connectws����� � �%�%�d�+��;�;�4�?�?�,��1��>�?�?��;�;�&�.�.�(��%�%�$�+�+����*H�!�2�2�����$�)�)�4�:�:��3���H�#+�1�+��A�q�!�Q��� � �"�����3��g�.� ��9��C������C�s<�CD�D�2D�8D�=D�>D�D�D�D�Dc���|j�} |j|�|jd�d}y#ttf$rf|j|�|j ||j|||�}|jtj|j||���Yd}yttf$r�t$r}|j|�Yd}~d}yd}~wwxYw#d}wxYw)Nr�)rO�connectr�rar`r0r��_sock_connect_cbr�r�r�r�r�r�r�r�)r)r�r2rCrr�r�s rr�z#BaseSelectorEventLoop._sock_connect�s��� �[�[�]�� ��L�L��!� �N�N�4� ��C��# �!1�2� M� �(�(��,��%�%��D�)�)�3��g�?�F��!�!��!�!�$�"7�"7��F�K� M��C��-�.� ��� #����c�"�"��C�� #�� �C�s9�7�C"�A0C�'C"�+C�C�C"�C�C"�"C&c�L�|�|j�s|j|�yyr/)r�r�r�s rr�z&BaseSelectorEventLoop._sock_write_done�r�r*c�v�|j�ry |jtjtj�}|dk7rt|d|���� |j d�d}y#ttf$rYd}yttf$r�t$r}|j|�Yd}~d}yd}~wwxYw#d}wxYw)NrzConnect call failed ) r�� getsockoptrT� SOL_SOCKET�SO_ERRORrgr�rar`r�r�r�r�)r)r�r2rC�errr�s rrz&BaseSelectorEventLoop._sock_connect_cb�s����8�8�:�� ��/�/�&�"3�"3�V�_�_�E�C��a�x��c�%9�'��#C�D�D�� �N�N�4� ��C�� �!1�2� ���C��-�.� ��� #����c�"�"��C�� #�� �C�s<�AA*�B4�*B1�9B4�=B1�B,�%B4�,B1�1B4�4B8c���K� tj|�|jr|j�dk7rt d��|j�}|j ||�|�d{���S7��w)Nrr�)rr�rhr�r�r��_sock_accept)r)r2r�s r�sock_acceptz!BaseSelectorEventLoop.sock_accept�sd���� � �%�%�d�+��;�;�4�?�?�,��1��>�?�?�� � �"�����#�t�$��y��y�s�A(A1�*A/�+A1c���|j�} |j�\}}|jd�|j||f�y#tt f$rc|j |�|j||j||�}|jtj|j||���Yyttf$r�t$r}|j!|�Yd}~yd}~wwxYw)NFr�)rOrvrVr�rar`r0rWr r�r�r�r�r�r�r�r�)r)r�r2rr�rCr�r�s rr z"BaseSelectorEventLoop._sock_accept�s��� �[�[�]�� ,� �K�K�M�M�D�'����U�#� �N�N�D�'�?�+�� �!1�2� L��(�(��,��%�%�b�$�*;�*;�S�$�G�F��!�!��!�!�$�"6�"6��6�J� L��-�.� ��� #����c�"�"�� #�s�$A � A/C-�;C-�C(�(C-c��K�|j|j=|j�}|j�|j ��d{��� |j|j|||d���d{���|j�|r|j�||j|j<S7�h7�A#|j�|r|j�||j|j<wxYw�w)NF)�fallback) r(�_sock_fd� is_reading� pause_reading�_make_empty_waiter� sock_sendfile�_sock�_reset_empty_waiter�resume_reading)r)�transp�file�offset�countrs r�_sendfile_nativez&BaseSelectorEventLoop._sendfile_native�s��������V�_�_�-��*�*�,�������'�'�)�)�)� 7��+�+�F�L�L�$���5:�,�<�<� �&�&�(���%�%�'�06�D���V�_�_�-� *��<�� �&�&�(���%�%�'�06�D���V�_�_�-�s<�AC:� B6�C:�#B:�6B8�7B:�:=C:�8B:�:=C7�7C:c�d�|D]�\}}|j|jc}\}}|tjzr1|�/|jr|j|�n|j |�|tjzs�z|��}|jr|j|���|j |���yr/) �fileobjr\rr�� _cancelledrM� _add_callbackr�r�)r)� event_listrr�rr�r�s r�_process_eventsz%BaseSelectorEventLoop._process_events�s���#�I�C��(+���S�X�X�%�G�%�f�f��i�*�*�*�v�/A��$�$��'�'��0��&�&�v�.��i�+�+�+��0B��$�$��'�'��0��&�&�v�.�$r*c�b�|j|j��|j�yr/)rMrOrJ)r)r2s r� _stop_servingz#BaseSelectorEventLoop._stop_serving�s�����D�K�K�M�*�� � �r*r/�NNN)r)3r#� __module__�__qualname__rr5r�SSL_HANDSHAKE_TIMEOUT�SSL_SHUTDOWN_TIMEOUTr@rDrJrIr%r]rXrjrprmrwr0rWrMr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr r rr r"� __classcell__�r"s@rrr5so���� 9�7�%)�$�7�9=�+� �$��t�"+�"A�"A�!*�!?�!?�+�&CG�B� "� �E� � �,�&#'�t�S�-6�-L�-L�,5�,J�,J�F��D�#�"+�"A�"A�!*�!?�!?� ,)�`�D�"+�"A�"A�!*�!?�!?� -5�^&�$� �*� �..� '� .� '� �,#�!� �*#�"�.#�"�2#�"�>�,�6 ��2�.#��* �,�"7�/�r*rc���eZdZdZdZd�fd� Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zd�Z d�Zej fd �Zdd�Zd�Zd�Zd�Zd�Z�xZS)�_SelectorTransportiNc����t�|�||�tj|�|jd< |j�|jd<d|jvr |j�|jd<||_ |j�|_d|_ |j|�||_t!j"�|_d|_d|_d|_|j�|jj-�||j.|j<y#t$rd|jd<Y��wxYw#tj$rd|jd<Y��wxYw)NrT�socknamerrFr)rrrr��_extra�getsocknamerg�getpeernamerT�errorrrOr�_protocol_connected�set_protocol�_server�collections�deque�_buffer� _conn_lost�_closing�_paused�_attachr()r)r�r2r3r,r-r"s �rrz_SelectorTransport.__init__s8��� �����%� &� 6� 6�t� <����H�� +�&*�&6�&6�&8�D�K�K� �#��T�[�[�(� /�*.�*:�*:�*<����J�'��� ���� �� �#(�� ����(�#����"�(�(�*�������� �����<�<�#��L�L� � �"�*.�������'��+� +�&*�D�K�K� �#� +�� �<�<� /�*.����J�'� /�s#�D'�!E�'E�E�"E*�)E*c��|jjg}|j�|jd�n|jr|jd�|jd|j ���|j��|jj�s�t|jj|j tj�}|r|jd�n|jd�t|jj|j tj�}|rd}nd}|j�}|jd|�d |�d ��djdj|��S) N�closed�closingzfd=zread=pollingz read=idle�polling�idlezwrite=<z , bufsize=�>z<{}>� )r"r#r�appendr9r�_looprHrr$rr�r��get_write_buffer_size�format�join)r)�infor?�stater�s r�__repr__z_SelectorTransport.__repr__'s$�����'�'�(���:�:���K�K��!� �]�]��K�K� �"����c�$�-�-��)�*��:�:�!�$�*�*�*>�*>�*@�*�4�:�:�+?�+?�+/�=�=�)�:N�:N�P�G�����N�+����K�(�*�4�:�:�+?�+?�+/�=�=�+4�+@�+@�B�G��!�����0�0�2�G��K�K�'�%�� �7�)�1�=�>��}�}�S�X�X�d�^�,�,r*c�&�|jd�yr/)�_force_closerRs r�abortz_SelectorTransport.abortCs�����$�r*c� �||_d|_y�NT)� _protocolr2)r)r3s rr3z_SelectorTransport.set_protocolFs��!���#'�� r*c��|jSr/)rPrRs r�get_protocolz_SelectorTransport.get_protocolJs���~�~�r*c��|jSr/)r9rRs rr�z_SelectorTransport.is_closingMs���}�}�r*c�B�|j�xr |jSr/)r�r:rRs rrz_SelectorTransport.is_readingPs���?�?�$�$�9�T�\�\�)9�9r*c���|j�syd|_|jj|j�|jj�rt jd|�yy)NTz%r pauses reading)rr:rDrMr� get_debugr r!rRs rrz _SelectorTransport.pause_readingSsP����� ������ � �!�!�$�-�-�0��:�:���!��L�L�,�d�3�"r*c���|js|jsyd|_|j|j|j�|j j �rtjd|�yy)NFz%r resumes reading) r9r:rWr�_read_readyrDrVr r!rRs rrz!_SelectorTransport.resume_reading[sW���=�=���������������(8�(8�9��:�:���!��L�L�-�t�4�"r*c�P�|jryd|_|jj|j�|jsa|xj dz c_|jj |j�|jj|jd�yy�NTr) r9rDrMrr7r8r�� call_soon�_call_connection_lostrRs rrJz_SelectorTransport.closecss���=�=���� �� � �!�!�$�-�-�0��|�|��O�O�q� �O��J�J�%�%�d�m�m�4��J�J� � ��!;�!;�T�B�r*c�v�|j�-|d|��t|��|jj�yy)Nzunclosed transport )�source)r�ResourceWarningrJ)r)�_warns r�__del__z_SelectorTransport.__del__ms5���:�:�!��'��x�0�/�$�O��J�J����"r*c��t|t�r4|jj�rDt j d||d��n*|jj ||||jd��|j|�y)Nz%r: %sTrd)rsrtr�r3) r�rgrDrVr r!rrPrL)r)r�rss r�_fatal_errorz_SelectorTransport._fatal_errorrse���c�7�#��z�z�#�#�%����X�t�W�t�D��J�J�-�-�"� �!� �N�N� /� � ���#�r*c��|jry|jr?|jj�|jj |j �|js,d|_|jj|j �|xjdz c_|jj|j|�yrZ) r8r7�clearrDr�rr9rMr[r\)r)r�s rrLz_SelectorTransport._force_close�s����?�?���<�<��L�L��� ��J�J�%�%�d�m�m�4��}�}� �D�M��J�J�%�%�d�m�m�4����1���� � ���T�7�7��=r*c�� |jr|jj|�|jj �d|_d|_d|_|j}|�|j�d|_yy#|jj �d|_d|_d|_|j}|�|j�d|_wwxYwr/)r2rP�connection_lostrrJrDr4�_detach)r)r�r-s rr\z(_SelectorTransport._call_connection_lost�s��� $��'�'����.�.�s�3��J�J�����D�J�!�D�N��D�J��\�\�F��!���� �#���"�� �J�J�����D�J�!�D�N��D�J��\�\�F��!���� �#���"�s�'A?�?ACc�H�ttt|j��Sr/)�sum�mapr�r7rRs rrEz(_SelectorTransport.get_write_buffer_size�s���3�s�D�L�L�)�*�*r*c�b�|j�sy|jj||g|���yr/)rrDrWr�s rrWz_SelectorTransport._add_reader�s*����� ���� � ���r�8�3�d�3r*)NN)zFatal error on transport)r#r$r%�max_sizerrrJrMr3rRr�rrrrJ�warnings�warnrarcrLr\rErWr(r)s@rr+r+sk����H� �E�/�8-�8 �(���:�4�5�C�%�M�M�� � >�$�+�4r*r+c����eZdZdZej jZ d�fd� Z�fd�Z d�Z d�Zd�Zd�Z d �Zd �Zd�Zded dfd�Zd�Zd�Zd�Zd�Z�fd�Zd�Zd�Z�fd�Z�xZS)r1TNc���d|_t�|� |||||�d|_d|_t r|j|_n|j|_tj|j�|jj|jj|�|jj|j |j"|j$�|�,|jjt&j(|d�yyr)�_read_ready_cbrr�_eof� _empty_waiter�_HAS_SENDMSG�_write_sendmsg�_write_ready�_write_sendr�_set_nodelayrrDr[rP�connection_maderWrrXr�_set_result_unless_cancelled)r)r�r2r3r4r,r-r"s �rrz!_SelectorSocketTransport.__init__�s����#��� ����t�X�u�f�=��� �!���� $� 3� 3�D�� $� 0� 0�D�� � � ����,�� � ���T�^�^�;�;�T�B�� � ���T�-�-�!�]�]�D�,<�,<� >����J�J� � ��!E�!E�!'�� /�r*c���t|tj�r|j|_n|j |_t�|�|�yr/)r�r �BufferedProtocol�_read_ready__get_bufferrr�_read_ready__data_receivedrr3)r)r3r"s �rr3z%_SelectorSocketTransport.set_protocol�s<����h� � :� :�;�"&�">�">�D��"&�"A�"A�D�� ���X�&r*c�$�|j�yr/)rrrRs rrXz$_SelectorSocketTransport._read_ready�s�����r*c��|jry |jjd�}t|�st d�� |jj|�}|s|j�y |jj|�y#t tf$r�t$r}|j|d�Yd}~yd}~wwxYw#ttf$rYyt tf$r�t$r}|j|d�Yd}~yd}~wwxYw#t tf$r�t$r}|j|d�Yd}~yd}~wwxYw)N���z%get_buffer() returned an empty bufferz/Fatal error: protocol.get_buffer() call failed.�$Fatal read error on socket transportz3Fatal error: protocol.buffer_updated() call failed.)r8rP� get_bufferr�rGr�r�r�rcrr�rar`�_read_ready__on_eof�buffer_updated)r)r�r�r�s rr~z0_SelectorSocketTransport._read_ready__get_buffer�sC���?�?�� ��.�.�+�+�B�/�C��s�8�"�#J�K�K�� ��Z�Z�)�)�#�.�F���$�$�&�� L��N�N�)�)�&�1��-�-�.� ��� �����F� H��� �� �!1�2� ���-�.� ��� ����c�#I�J��� ���-�.� ��� L�����J� L� L�� L�sM�1B �C�1D� C�%B<�<C�D�D�,D�D�D?�#D:�:D?c���|jry |jj|j�}|s|j�y |jj|�y#tt f$rYyttf$r�t$r}|j|d�Yd}~yd}~wwxYw#ttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nr�z2Fatal error: protocol.data_received() call failed.) r8rr_rmrar`r�r�r�rcr�rP� data_received)r)r\r�s rrz3_SelectorSocketTransport._read_ready__data_received�s����?�?�� ��:�:�?�?�4�=�=�1�D���$�$�&�� K��N�N�(�(��.�� �!1�2� ���-�.� ��� ����c�#I�J��� ���-�.� ��� K�����I� K� K�� K�s5�%A$�B+�$B(�5B(�B#�#B(�+C�C�Cc�x�|jj�rtjd|� |jj�}|r&|jj|j�y|j�y#ttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rDrVr r!rP�eof_receivedr�r�r�rcrMrrJ)r)� keep_openr�s rr�z,_SelectorSocketTransport._read_ready__on_eof s����:�:���!��L�L�*�D�1� ����3�3�5�I�� �J�J�%�%�d�m�m�4��J�J�L���-�.� ��� �����H� J��� �s�B�B9�B4�4B9c�<�t|tttf�s!t dt|�j����|jrtd��|j�td��|sy|jrH|jtjk\rtjd�|xjdz c_ y|js] |j j#|�}t|�|d}|sy|j0j3|j4|j6�|jj9|�|j;�y#t$t&f$rY�mt(t*f$r�t,$r}|j/|d�Yd}~yd}~wwxYw)N�/data argument must be a bytes-like object, not z%Cannot call write() after write_eof()z(unable to write; sendfile is in progress�socket.send() raised exception.r�%Fatal write error on socket transport)r��bytes� bytearrayr�r�r�r#rsrGrtr8r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr �warningr7rrfrar`r�r�r�rcrDr�rrwrC�_maybe_pause_protocol)r)r\r�r�s r�writez_SelectorSocketTransport.writes_���$�� �:� >�?��#�#'��:�#6�#6�"9�;�<� <��9�9��F�G�G����)��I�J�J����?�?����)�"M�"M�M����@�A��O�O�q� �O���|�|� ��J�J�O�O�D�)��"�$�'���+�����J�J�"�"�4�=�=�$�2C�2C�D� �����D�!��"�"�$��!$�%5�6� ��� 1�2� �� � ��!�!�#�'N�O��� �s�E�F�(F�?F�Fc�J�tj|jt�Sr/)� itertools�islicer7rrRs r�_get_sendmsg_bufferz,_SelectorSocketTransport._get_sendmsg_bufferFs��������j�9�9r*c�r�|jry |jj|j��}|j |�|j�|js�|jj|j�|j�|jjd�|jr|jd�y|jr*|jjt j"�yyy#t$t&f$rYyt(t*f$r�t,$r�}|jj|j�|jj/�|j1|d�|j� |jj3|�Yd}~yYd}~yd}~wwxYw�Nr�)r8rrr��_adjust_leftover_buffer�_maybe_resume_protocolr7rDr�rrtr�r9r\rs�shutdownrT�SHUT_WRrar`r�r�r�rercr�)r)r�r�s rrvz'_SelectorSocketTransport._write_sendmsgIsV���?�?�� 8��Z�Z�'�'��(@�(@�(B�C�F��(�(��0� �'�'�)��<�<�� � �)�)�$�-�-�8��%�%�1��&�&�1�1�$�7��=�=��.�.�t�4��Y�Y��J�J�'�'����7�� �� �!1�2� ���-�.� ��� 6��J�J�%�%�d�m�m�4��L�L��� ����c�#J�K��!�!�-��"�"�0�0��5�5�.�� 6�s�:D�F6�F6�/A8F1�1F6r��returnc��|j}|r?|j�}t|�}||kr||z}n|j||d�y|r�>yyr/)r7�popleftr�� appendleft)r)r��buffer�b�b_lens rr�z0_SelectorSocketTransport._adjust_leftover_bufferesO���������� �A���F�E�����%����!�!�!�F�G�*�-��r*c��|jry |jj�}|jj |�}|t|�k7r|jj ||d�|j�|js�|jj|j�|j�|jjd�|jr|jd�y|jr*|jj!t"j$�yyy#t&t(f$rYyt*t,f$r�t.$r�}|jj|j�|jj1�|j3|d�|j� |jj5|�Yd}~yYd}~yd}~wwxYwr�)r8r7r�rrfr�r�r�rDr�rrtr�r9r\rsr�rTr�rar`r�r�r�rercr�)r)r�r�r�s rrxz$_SelectorSocketTransport._write_sendpss���?�?�� 8��\�\�)�)�+�F�� � ����'�A��C��K�����'�'��q�r� �3� �'�'�)��<�<�� � �)�)�$�-�-�8��%�%�1��&�&�1�1�$�7��=�=��.�.�t�4��Y�Y��J�J�'�'����7�� �� �!1�2� ���-�.� ��� 6��J�J�%�%�d�m�m�4��L�L��� ����c�#J�K��!�!�-��"�"�0�0��5�5�.�� 6�s�A!D.�.G�?G�A8G�Gc��|js|jryd|_|js*|jj t j�yyrO)r9rsr7rr�rTr�rRs r� write_eofz"_SelectorSocketTransport.write_eof�s;���=�=�D�I�I���� ��|�|��J�J������/�r*c��|jrtd��|j�td��|sy|jj |D�cgc] }t|���c}�|j �|jrA|jj|j|j�|j�yycc}w)Nz*Cannot call writelines() after write_eof()z-unable to writelines; sendfile is in progress)rsrGrtr7�extendr�rwrDr�rr�)r)�list_of_datar\s r� writelinesz#_SelectorSocketTransport.writelines�s����9�9��K�L�L����)��N�O�O��������,�G�,�$�Z��-�,�G�H������<�<��J�J�"�"�4�=�=�$�2C�2C�D��&�&�(���Hs�Cc��yrOrZrRs r� can_write_eofz&_SelectorSocketTransport.can_write_eof�s��r*c��� t�|�|�d|_|j�%|jj td��yy#d|_|j�%|jj td��wwxYw)NzConnection is closed by peer)rr\rwrtr��ConnectionError)r)r�r"s �rr\z._SelectorSocketTransport._call_connection_lost�s���� E��G�)�#�.� $�D���!�!�-��"�"�0�0�#�$B�C�E�.��!%�D���!�!�-��"�"�0�0�#�$B�C�E�.�s�A�:Bc���|j�td��|jj�|_|js|jjd�|jS)NzEmpty waiter is already set)rtrGrDr�r7r�rRs rrz+_SelectorSocketTransport._make_empty_waiter�sV�����)��<�=�=�!�Z�Z�5�5�7����|�|����)�)�$�/��!�!�!r*c��d|_yr/)rtrRs rrz,_SelectorSocketTransport._reset_empty_waiter�s ��!��r*c�0��d|_t�|� �yr/)rrrrJrKs �rrJz_SelectorSocketTransport.close�s���"��� �� �r*r#)r#r$r%�_start_tls_compatibler� _SendfileMode� TRY_NATIVE�_sendfile_compatiblerr3rXr~rr�r�r�rvr�r�rxr�r�r�r\rrrJr(r)s@rr1r1�s���� ��$�2�2�=�=��48�$(�/�2'��#L�JK�2�*%%�N:�8�8 �c� �d� �8�>0�)��E�"�"��r*r1c�V��eZdZejZ d�fd� Zd�Zd�Zdd�Z d�Z �xZS)rBc�x��t�|�||||�||_d|_|jj|jj|�|jj|j|j|j�|�,|jjtj|d�yyr�) rr�_address�_buffer_sizerDr[rPrzrWrrXrr{)r)r�r2r3rCr4r,r"s �rrz#_SelectorDatagramTransport.__init__�s���� ����t�X�u�5��� ����� � ���T�^�^�;�;�T�B�� � ���T�-�-�!�]�]�D�,<�,<� >����J�J� � ��!E�!E�!'�� /�r*c��|jSr/)r�rRs rrEz0_SelectorDatagramTransport.get_write_buffer_size�s��� � � r*c��|jry |jj|j�\}}|jj||�y#ttf$rYyt$r%}|jj|�Yd}~yd}~wttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nz&Fatal read error on datagram transport)r8rr�rmrP�datagram_receivedrar`rg�error_receivedr�r�r�rc�r)r\r�r�s rrXz&_SelectorDatagramTransport._read_ready�s����?�?�� 9����,�,�T�]�]�;�J�D�$� �N�N�,�,�T�4�8�� �!1�2� ��� /��N�N�)�)�#�.�.���-�.� ��� M����c�#K�L�L�� M�s)�(A�C�%C�-B � C�(B?�?Cc�Z�t|tttf�s!t dt|�j����|sy|jr4|d|jfvrtd|j����|j}|jrT|jrH|jtjk\rtjd�|xjdz c_ y|jsI |jdr|j j#|�y|j j%||�y|jjAt|�|f�|xjBtE|�z c_!|jG�y#t&t(f$r3|j*j-|j.|j0�Y��t2$r%}|j4j7|�Yd}~yd}~wt8t:f$r�t<$r}|j?|d�Yd}~yd}~wwxYw)Nr�z!Invalid address: must be None or r�rrr�'Fatal write error on datagram transport)$r�r�r�r�r�r�r#r�r�r8rr�r r�r7r.rrfr�rar`rDr�r� _sendto_readyrgrPr�r�r�r�rcrCr�r�r�r�s rr�z!_SelectorDatagramTransport.sendto�s����$�� �:� >�?��#�#'��:�#6�#6�"9�;�<� <����=�=��D�$�-�-�0�0� �7�� � ��G�I�I��=�=�D��?�?�t�}�}����)�"M�"M�M����@�A��O�O�q� �O���|�|� ��;�;�z�*��J�J�O�O�D�)���J�J�%�%�d�D�1�� �����U�4�[�$�/�0����S��Y�&���"�"�$��$�%5�6� J�� � �&�&�t�}�}�d�6H�6H�I�� ����-�-�c�2���� 1�2� �� � ��!�!��B�D��� �s0�-*F �F � ?H*�H*�G3�3H*�H%�%H*c�X�|jr�|jj�\}}|xjt|�zc_ |jdr|j j |�n|j j||�|jr��|j%�|jsD|j&j)|j*�|j,r|j/d�yyy#ttf$r>|jj||f�|xjt|�z c_Y��t$r%}|jj|�Yd}~yd}~wttf$r�t $r}|j#|d�Yd}~yd}~wwxYw)Nrrr�)r7r�r�r�r.rrfr�rar`r�rgrPr�r�r�r�rcr�rDr�rr9r\r�s rr�z(_SelectorDatagramTransport._sendto_readysQ���l�l����-�-�/�J�D�$�����T��*�� ��;�;�z�*��J�J�O�O�D�)��J�J�%�%�d�D�1��l�l�, �#�#�%��|�|��J�J�%�%�d�m�m�4��}�}��*�*�4�0����$�%5�6� ����'�'��t��5��!�!�S��Y�.�!��� ����-�-�c�2���� 1�2� �� � ��!�!��B�D��� �s,� AC>�>A F)� F)�E2�2F)� F$�$F)r#r/)r#r$r%r5r6�_buffer_factoryrrErXr�r�r(r)s@rrBrB�s.���!�'�'�O�59�$(�/�!�9� *%�X1r*rB)%�__all__r5rzr�r��osrrTrnr&�ssl�ImportError�rrrrr r rr�logr �hasattrru�sysconfrrgr� BaseEventLoopr�_FlowControlMixin� Transportr+r1�DatagramTransportrBrZr*r�<module>r�s���#������ �� ���������������v�}�}�i�0�����R�Z�Z��-� � (�I�K�5�5�I�X_4��5�5�#�-�-�_4�DZ�1�Z�zl1�!3�Z�5Q�5Q�l1��Y%�� �C���$�����s#�C%�9C2�%C/�.C/�2C<�;C<__pycache__/selector_events.cpython-312.pyc000064400000173530151706172560014706 0ustar00� T��h̼���dZdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlZddl mZddl mZddl mZddl mZdd l mZdd l mZddl mZddl mZdd lmZeejd�Zer ej4d�Zd�ZGd�dej<�ZGd�dej@ejB�Z"Gd�de"�Z#Gd�de"ejH�Z%y#e$rdZY��wxYw#e$rdZY�pwxYw)z�Event loop using a selector and related classes. A selector is a "notify-when-ready" multiplexer. For a subclass which also includes support for signal handling, see the unix_events sub-module. )�BaseSelectorEventLoop�N�)�base_events)� constants)�events)�futures)� protocols)�sslproto)� transports)�trsock)�logger�sendmsg� SC_IOV_MAXFc�t� |j|�}t|j|z�S#t$rYywxYw�NF)�get_key�boolr�KeyError)�selector�fd�event�keys �0/usr/lib64/python3.12/asyncio/selector_events.py�_test_selector_eventr*sA��(����r�"���C�J�J��&�'�'������s�+� 7�7c���eZdZdZd3�fd� Zd3ddd�d�Z d3ddddejejd�d�Z d4d �Z �fd �Zd�Zd�Z d �Zd�Zd�Zdddejejfd�Zdddejejfd�Zddejejfd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd3d�Zd�Zd �Z d!�Z!d"�Z"d#�Z#d5d$�Z$d%�Z%d&�Z&d'�Z'd(�Z(d)�Z)d*�Z*d+�Z+d3d,�Z,d-�Z-d.�Z.d/�Z/d0�Z0d1�Z1d2�Z2�xZ3S)6rzJSelector event loop. See events.EventLoop for API specification. Nc���t�|��|�tj�}t j d|jj�||_|j�tj�|_y)NzUsing selector: %s) �super�__init__� selectors�DefaultSelectorr �debug� __class__�__name__� _selector�_make_self_pipe�weakref�WeakValueDictionary�_transports)�selfrr"s �rrzBaseSelectorEventLoop.__init__;sa��� ������ �0�0�2�H����)�8�+=�+=�+F�+F�G�!�������"�6�6�8�����extra�serverc�D�|j|�t||||||�S�N)�_ensure_fd_no_transport�_SelectorSocketTransport)r)�sock�protocol�waiterr,r-s r�_make_socket_transportz,BaseSelectorEventLoop._make_socket_transportEs*���$�$�T�*�'��d�H�f�(-�v�7� 7r*F)�server_side�server_hostnamer,r-�ssl_handshake_timeout�ssl_shutdown_timeoutc ��|j|�tj||||||| | ��}t|||||��|jS)N)r8r9r+)r0r �SSLProtocolr1�_app_transport)r)�rawsockr3� sslcontextr4r6r7r,r-r8r9�ssl_protocols r�_make_ssl_transportz)BaseSelectorEventLoop._make_ssl_transportKsW�� �$�$�W�-��+�+��(�J����"7�!5� �� !��w��',�V� =��*�*�*r*c�D�|j|�t||||||�Sr/)r0�_SelectorDatagramTransport)r)r2r3�addressr4r,s r�_make_datagram_transportz.BaseSelectorEventLoop._make_datagram_transport]s,���$�$�T�*�)�$��h�*1�6�5�B� Br*c���|j�rtd��|j�ry|j�t�|��|j�"|jj�d|_yy)Nz!Cannot close a running event loop)� is_running�RuntimeError� is_closed�_close_self_piper�closer$�r)r"s �rrJzBaseSelectorEventLoop.closecsa����?�?���B�C�C��>�>������� �� ���>�>�%��N�N� � �"�!�D�N�&r*c��|j|jj��|jj�d|_|jj�d|_|xj dzc_y)Nr)�_remove_reader�_ssock�filenorJ�_csock� _internal_fds�r)s rrIz&BaseSelectorEventLoop._close_self_pipens\�����D�K�K�.�.�0�1����������������������a��r*c�D�tj�\|_|_|jj d�|jj d�|xj dz c_|j |jj�|j�y)NFr) �socket� socketpairrNrP�setblockingrQ�_add_readerrO�_read_from_selfrRs rr%z%BaseSelectorEventLoop._make_self_pipevsq��#)�#4�#4�#6� ���T�[�������&�������&����a���������+�+�-�t�/C�/C�Dr*c��yr/��r)�datas r�_process_self_dataz(BaseSelectorEventLoop._process_self_data~s��r*c�� |jjd�}|sy|j|��1#t$rY�=t$rYywxYw)Ni)rN�recvr]�InterruptedError�BlockingIOErrorr[s rrXz%BaseSelectorEventLoop._read_from_self�sV��� ��{�{�'�'��-�����'�'��-���$� ��"� �� �s�3�3� A �A �A c��|j}|�y |jd�y#t$r(|jrt j dd��YyYywxYw)N�z3Fail to write a null byte into the self-pipe socketT��exc_info)rP�send�OSError�_debugr r!)r)�csocks r�_write_to_selfz$BaseSelectorEventLoop._write_to_self�sU�������=�� ,��J�J�u���� ,��{�{����0�&*�,�� ,�s�#�,A�A�dc�f�|j|j�|j|||||||� yr/)rWrO�_accept_connection)r)�protocol_factoryr2r>r-�backlogr8r9s r�_start_servingz$BaseSelectorEventLoop._start_serving�s4�� ��������(?�(?�)�4��V�W�.�0D� Fr*c ���t|�D]w} |j�\} } |jrtjd|| | �| jd�d| i}|j || |||||�}|j|��yy#tttf$rYyt$r�} | jtjtjtjtj fvry|j#d| t%j&|�d��|j)|j+��|j-t.j0|j2|||||||� n�Yd} ~ ��dd} ~ wwxYw)Nz#%r got a new connection from %r: %rF�peernamez&socket.accept() out of system resource)�message� exceptionrT)�range�acceptrhr r!rV�_accept_connection2�create_taskrar`�ConnectionAbortedErrorrg�errno�EMFILE�ENFILE�ENOBUFS�ENOMEM�call_exception_handlerr�TransportSocketrMrO� call_laterr�ACCEPT_RETRY_DELAYrp)r)rnr2r>r-ror8r9�_�conn�addrr,rv�excs rrmz(BaseSelectorEventLoop._accept_connection�sX���w��A�" )�!�[�[�]� ��d��;�;��L�L�!F�!'��t�5�� � ��'�2$�T�*���1�1�$�d�E�:�v�)�+?�A��� � ��(�G ��$�%5�7M�N� ��� ��9�9����u�|�|�!&������!>�>� �/�/�#K�%(�"(�"8�"8��">�1�� �'�'���� �6��O�O�I�$@�$@�$(�$7�$7�$4�d�J��$+�-B�$8� :�� :�� �s�AB�E5�E5�&CE0�0E5c��K�d}d} |�}|j�} |r|j|||| d||||�� } n|j||| ||��} | �d{���y7�#t$r| j �d} �wxYw#t tf$r�t$r?}|jr)d|d�}|�||d<| �| |d<|j|�Yd}~yYd}~yd}~wwxYw�w)NT)r4r6r,r-r8r9)r4r,r-z3Error on transport creation for incoming connection)rsrtr3� transport) � create_futurer@r5� BaseExceptionrJ� SystemExit�KeyboardInterruptrhr) r)rnr�r,r>r-r8r9r3r�r4r��contexts rrwz)BaseSelectorEventLoop._accept_connection2�s���� ��� �& 5�'�)�H��'�'�)�F�� �4�4��(�J�v� $�E�&�*?�)=� 5�?� �!�7�7��(�6��!�8�#� � ����� � ����!���� ���-�.� ��� 5��{�{�N�!$��� �'�*2�G�J�'��(�+4�G�K�(��+�+�G�4�4��� 5�sS�C�A B�A �A�A �C�A � A=�=B�C�0C� C�C�Cc�*�|}t|t�s t|j��} |j|}|j�std|�d|����y#ttt f$rtd|���d�wxYw#t$rYywxYw)NzInvalid file object: zFile descriptor z is used by transport ) � isinstance�intrO�AttributeError� TypeError� ValueErrorr(� is_closingrGr)r)rrOr�s rr0z-BaseSelectorEventLoop._ensure_fd_no_transports������&�#�&� K��V�]�]�_�-�� &��(�(��0�I��'�'�)�"�&�r�f�,B� �m�%�&�&�*��#�I�z�:� K� �#8���!?�@�d�J� K�� � �� �s�A�B�$B� B�Bc���|j�tj|||d�} |jj |�}|j|j c}\}}|jj ||tjz||f�|�|j�|S#t$r1|jj|tj|df�Y|SwxYwr/)� _check_closedr�Handler$rr\�modifyr� EVENT_READ�cancelr�register� r)r�callback�args�handler�mask�reader�writers rrWz!BaseSelectorEventLoop._add_readers����������x��t�T�:�� ��.�.�(�(��,�C� &)�Z�Z����"�D�"�6�6��N�N�!�!�"�d�Y�-A�-A�&A�#)�6�"2� 4��!�� � ��� ��� 4��N�N�#�#�B� �(<�(<�%+�T�N� 4�� � 4���B%�%6C�Cc�|�|j�ry |jj|�}|j|jc}\}}|t jz}|s|jj|�n|jj||d|f�|�|j�yy#t$rYywxYw)NFT)rHr$rrr\rr�� unregisterr�r�r�r)rrr�r�r�s rrMz$BaseSelectorEventLoop._remove_reader&s����>�>��� ��.�.�(�(��,�C�&)�Z�Z����"�D�"�6�6��Y�)�)�)�)�D�����)�)�"�-����%�%�b�$��v��?��!�� � ������ �� ���B/�/ B;�:B;c���|j�tj|||d�} |jj |�}|j|j c}\}}|jj ||tjz||f�|�|j�|S#t$r1|jj|tjd|f�Y|SwxYwr/)r�rr�r$rr\r�r�EVENT_WRITEr�rr�r�s r�_add_writerz!BaseSelectorEventLoop._add_writer;s����������x��t�T�:�� ��.�.�(�(��,�C� &)�Z�Z����"�D�"�6�6��N�N�!�!�"�d�Y�-B�-B�&B�#)�6�"2� 4��!�� � ��� ��� 4��N�N�#�#�B� �(=�(=�%)�6�N� 4�� � 4�r�c�|�|j�ry |jj|�}|j|jc}\}}|t jz}|s|jj|�n|jj|||df�|�|j�yy#t$rYywxYw)�Remove a writer callback.FNT)rHr$rrr\rr�r�r�r�rr�s r�_remove_writerz$BaseSelectorEventLoop._remove_writerKs����>�>��� ��.�.�(�(��,�C�&)�Z�Z����"�D�"�6�6��Y�*�*�*�*�D�����)�)�"�-����%�%�b�$����?��!�� � ������ �� �r�c�N�|j|�|j||g|���y)zAdd a reader callback.N)r0rW�r)rr�r�s r� add_readerz BaseSelectorEventLoop.add_readerb�'���$�$�R�(������X�-��-r*c�F�|j|�|j|�S)zRemove a reader callback.)r0rM�r)rs r� remove_readerz#BaseSelectorEventLoop.remove_readerg�!���$�$�R�(��"�"�2�&�&r*c�N�|j|�|j||g|���y)zAdd a writer callback..N)r0r�r�s r� add_writerz BaseSelectorEventLoop.add_writerlr�r*c�F�|j|�|j|�S)r�)r0r�r�s r� remove_writerz#BaseSelectorEventLoop.remove_writerqr�r*c���K�tj|�|jr|j�dk7rt d�� |j|�S#ttf$rYnwxYw|j�}|j�}|j|�|j||j|||�}|jtj|j ||���|�d{���7S�w)z�Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by nbytes. r�the socket must be non-blocking�r�N)r�_check_ssl_socketrh� gettimeoutr�r_rar`r�rOr0rW� _sock_recv�add_done_callback� functools�partial�_sock_read_done)r)r2�n�futrr�s r� sock_recvzBaseSelectorEventLoop.sock_recvvs����� �%�%�d�+��;�;�4�?�?�,��1��>�?�?� ��9�9�Q�<����!1�2� �� ��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�o�o�s�D�!�D��������d�2�2�B�v�F� H��y�y���7�AC5�A�C5�A&�#C5�%A&�&B C5�/C2�0C5c�L�|�|j�s|j|�yyr/)� cancelledr��r)rr�r�s rr�z%BaseSelectorEventLoop._sock_read_done��%���>��!1�!1�!3����r�"�"4r*c��|j�ry |j|�}|j|�y#ttf$rYyt tf$r�t$r}|j|�Yd}~yd}~wwxYwr/) �doner_� set_resultrar`r�r�r�� set_exception)r)r�r2r�r\r�s rr�z BaseSelectorEventLoop._sock_recv�su���8�8�:�� !��9�9�Q�<�D� �N�N�4� �� �!1�2� ���-�.� ��� #����c�"�"�� #���6�A9�A9�A4�4A9c���K�tj|�|jr|j�dk7rt d�� |j|�S#ttf$rYnwxYw|j�}|j�}|j|�|j||j|||�}|jtj|j ||���|�d{���7S�w)z�Receive data from the socket. The received data is written into *buf* (a writable buffer). The return value is the number of bytes written. rr�r�N)rr�rhr�r�� recv_intorar`r�rOr0rW�_sock_recv_intor�r�r�r�)r)r2�bufr�rr�s r�sock_recv_intoz$BaseSelectorEventLoop.sock_recv_into�s����� �%�%�d�+��;�;�4�?�?�,��1��>�?�?� ��>�>�#�&�&���!1�2� �� ��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�&:�&:�C��s�K��������d�2�2�B�v�F� H��y�y��r�c��|j�ry |j|�}|j|�y#ttf$rYyt tf$r�t$r}|j|�Yd}~yd}~wwxYwr/) r�r�r�rar`r�r�r�r�)r)r�r2r��nbytesr�s rr�z%BaseSelectorEventLoop._sock_recv_into�sv���8�8�:�� #��^�^�C�(�F� �N�N�6�"�� �!1�2� ���-�.� ��� #����c�"�"�� #�r�c���K�tj|�|jr|j�dk7rt d�� |j|�S#ttf$rYnwxYw|j�}|j�}|j|�|j||j|||�}|jtj|j ||���|�d{���7S�w)aReceive a datagram from a datagram socket. The return value is a tuple of (bytes, address) representing the datagram received and the address it came from. The maximum amount of data to be received at once is specified by nbytes. rr�r�N)rr�rhr�r��recvfromrar`r�rOr0rW�_sock_recvfromr�r�r�r�)r)r2�bufsizer�rr�s r� sock_recvfromz#BaseSelectorEventLoop.sock_recvfrom�s����� �%�%�d�+��;�;�4�?�?�,��1��>�?�?� ��=�=��)�)���!1�2� �� ��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�&9�&9�3��g�N��������d�2�2�B�v�F� H��y�y��r�c��|j�ry |j|�}|j|�y#ttf$rYyt tf$r�t$r}|j|�Yd}~yd}~wwxYwr/) r�r�r�rar`r�r�r�r�)r)r�r2r��resultr�s rr�z$BaseSelectorEventLoop._sock_recvfrom�sv���8�8�:�� #��]�]�7�+�F� �N�N�6�"�� �!1�2� ���-�.� ��� #����c�"�"�� #�r�c��K�tj|�|jr|j�dk7rt d��|st|�} |j ||�S#ttf$rYnwxYw|j�}|j�}|j|�|j||j||||�}|jtj |j"||���|�d{���7S�w)z�Receive data from the socket. The received data is written into *buf* (a writable buffer). The return value is a tuple of (number of bytes written, address). rr�r�N)rr�rhr�r��len� recvfrom_intorar`r�rOr0rW�_sock_recvfrom_intor�r�r�r�)r)r2r�r�r�rr�s r�sock_recvfrom_intoz(BaseSelectorEventLoop.sock_recvfrom_into�s����� �%�%�d�+��;�;�4�?�?�,��1��>�?�?����X�F� ��%�%�c�6�2�2���!1�2� �� ��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�&>�&>��T�3�"(�*��������d�2�2�B�v�F� H��y�y��s7�A D�A"�!D�"A4�1D�3A4�4B D�>D�?Dc��|j�ry |j||�}|j|�y#ttf$rYyt tf$r�t$r}|j|�Yd}~yd}~wwxYwr/) r�r�r�rar`r�r�r�r�)r)r�r2r�r�r�r�s rr�z)BaseSelectorEventLoop._sock_recvfrom_intosz���8�8�:�� #��'�'��W�5�F� �N�N�6�"�� �!1�2� ���-�.� ��� #����c�"�"�� #�s�7�A:�A:�A5�5A:c ��(K�tj|�|jr|j�dk7rt d�� |j|�}|t|�k(ry|j�}|j�}|j|�|j||j||t|�|g�}|jt!j"|j$||���|�d{���S#ttf$rd}Y��wxYw7��w)�Send data to the socket. The socket must be connected to a remote socket. This method continues to send data from data until either all data has been sent or an error occurs. None is returned on success. On error, an exception is raised, and there is no way to determine how much data, if any, was successfully processed by the receiving end of the connection. rr�Nr�)rr�rhr�r�rfrar`r�r�rOr0r�� _sock_sendall� memoryviewr�r�r��_sock_write_done)r)r2r\r�r�rr�s r�sock_sendallz"BaseSelectorEventLoop.sock_sendalls����� �%�%�d�+��;�;�4�?�?�,��1��>�?�?� �� � �$��A� ��D� �>��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�&8�&8�#�t�",�T�"2�Q�C�9��������d�3�3�R��G� I��y��� �!1�2� ��A� ���s7�AD�C9�B D�4D�5D�9D � D�D � Dc�:�|j�ry|d} |j||d�}||z }|t|�k(r|jd�y||d<y#ttf$rYytt f$r�t$r}|j|�Yd}~yd}~wwxYw�Nr) r�rfrar`r�r�r�r�r�r�)r)r�r2�view�pos�startr�r�s rr�z#BaseSelectorEventLoop._sock_sendall7s����8�8�:���A��� �� � �$�u�v�,�'�A� �� ���C��I���N�N�4� ��C��F�� �!1�2� ���-�.� ��� ����c�"��� �s�A�B�(B�?B�Bc���K�tj|�|jr|j�dk7rt d�� |j||�S#ttf$rYnwxYw|j�}|j�}|j|�|j||j||||�}|jtj|j ||���|�d{���7S�w)r�rr�r�N)rr�rhr�r��sendtorar`r�rOr0r��_sock_sendtor�r�r�r�)r)r2r\rCr�rr�s r�sock_sendtoz!BaseSelectorEventLoop.sock_sendtoMs����� �%�%�d�+��;�;�4�?�?�,��1��>�?�?� ��;�;�t�W�-�-���!1�2� �� ��� � �"�� �[�[�]���$�$�R�(��!�!�"�d�&7�&7��d�D�")�+��������d�3�3�R��G� I��y�y��s7�AC7�A�C7�A'�$C7�&A'�'B C7�1C4�2C7c��|j�ry |j|d|�}|j|�y#ttf$rYyt tf$r�t$r}|j|�Yd}~yd}~wwxYwr�) r�r�r�rar`r�r�r�r�)r)r�r2r\rCr�r�s rr�z"BaseSelectorEventLoop._sock_sendtohsx���8�8�:�� ����D�!�W�-�A� �N�N�1��� �!1�2� ���-�.� ��� #����c�"�"�� #�s�8�A;� A;� A6�6A;c�� K�tj|�|jr|j�dk7rt d��|j tjk(s-tjrd|j tjk(rG|j||j |j|j|���d{���}|d\}}}}}|j�}|j|||� |�d{���d}S7�?7�#d}wxYw�w)zTConnect to a remote socket at address. This method is a coroutine. rr�)�family�type�proto�loopN)rr�rhr�r�r�rT�AF_INET� _HAS_IPv6�AF_INET6�_ensure_resolvedr�r�r�� _sock_connect)r)r2rC�resolvedr�r�s r�sock_connectz"BaseSelectorEventLoop.sock_connectws����� �%�%�d�+��;�;�4�?�?�,��1��>�?�?��;�;�&�.�.�(��%�%�$�+�+����*H�!�2�2�����$�)�)�4�:�:��3���H�#+�1�+��A�q�!�Q��� � �"�����3��g�.� ��9��C������C�s<�CD�D�2D�7D�<D�=D�D�D�D�Dc���|j�} |j|�|jd�d}y#ttf$rf|j|�|j ||j|||�}|jtj|j||���Yd}yttf$r�t$r}|j|�Yd}~d}yd}~wwxYw#d}wxYw)Nr�)rO�connectr�rar`r0r��_sock_connect_cbr�r�r�r�r�r�r�r�)r)r�r2rCrr�r�s rr�z#BaseSelectorEventLoop._sock_connect�s��� �[�[�]�� ��L�L��!� �N�N�4� ��C��# �!1�2� M� �(�(��,��%�%��D�)�)�3��g�?�F��!�!��!�!�$�"7�"7��F�K� M��C��-�.� ��� #����c�"�"��C�� #�� �C�s9�7�C"�A0C�'C"�+C�C�C"�C�C"�"C&c�L�|�|j�s|j|�yyr/)r�r�r�s rr�z&BaseSelectorEventLoop._sock_write_done�r�r*c�v�|j�ry |jtjtj�}|dk7rt|d|���� |j d�d}y#ttf$rYd}yttf$r�t$r}|j|�Yd}~d}yd}~wwxYw#d}wxYw)NrzConnect call failed ) r�� getsockoptrT� SOL_SOCKET�SO_ERRORrgr�rar`r�r�r�r�)r)r�r2rC�errr�s rrz&BaseSelectorEventLoop._sock_connect_cb�s����8�8�:�� ��/�/�&�"3�"3�V�_�_�E�C��a�x��c�%9�'��#C�D�D�� �N�N�4� ��C�� �!1�2� ���C��-�.� ��� #����c�"�"��C�� #�� �C�s<�AA*�B4�*B1�9B4�=B1�B,�%B4�,B1�1B4�4B8c���K�tj|�|jr|j�dk7rt d��|j�}|j ||�|�d{���S7��w)aWAccept a connection. The socket must be bound to an address and listening for connections. The return value is a pair (conn, address) where conn is a new socket object usable to send and receive data on the connection, and address is the address bound to the socket on the other end of the connection. rr�N)rr�rhr�r�r��_sock_accept)r)r2r�s r�sock_acceptz!BaseSelectorEventLoop.sock_accept�s_���� �%�%�d�+��;�;�4�?�?�,��1��>�?�?�� � �"�����#�t�$��y��y�s�A'A0�)A.�*A0c���|j�} |j�\}}|jd�|j||f�y#tt f$rc|j |�|j||j||�}|jtj|j||���Yyttf$r�t$r}|j!|�Yd}~yd}~wwxYw)NFr�)rOrvrVr�rar`r0rWrr�r�r�r�r�r�r�r�)r)r�r2rr�rCr�r�s rrz"BaseSelectorEventLoop._sock_accept�s��� �[�[�]�� ,� �K�K�M�M�D�'����U�#� �N�N�D�'�?�+�� �!1�2� L��(�(��,��%�%�b�$�*;�*;�S�$�G�F��!�!��!�!�$�"6�"6��6�J� L��-�.� ��� #����c�"�"�� #�s�$A � A/C-�;C-�C(�(C-c��K�|j|j=|j�}|j�|j ��d{��� |j|j|||d���d{���|j�|r|j�||j|j<S7�h7�A#|j�|r|j�||j|j<wxYw�w)NF)�fallback) r(�_sock_fd� is_reading� pause_reading�_make_empty_waiter� sock_sendfile�_sock�_reset_empty_waiter�resume_reading)r)�transp�file�offset�countrs r�_sendfile_nativez&BaseSelectorEventLoop._sendfile_native�s��������V�_�_�-��*�*�,�������'�'�)�)�)� 7��+�+�F�L�L�$���5:�,�<�<� �&�&�(���%�%�'�06�D���V�_�_�-� *��<�� �&�&�(���%�%�'�06�D���V�_�_�-�s<�AC:� B6�C:�#B:�6B8�7B:�:=C:�8B:�:=C7�7C:c�d�|D]�\}}|j|jc}\}}|tjzr1|�/|jr|j|�n|j |�|tjzs�z|��}|jr|j|���|j |���yr/) �fileobjr\rr�� _cancelledrM� _add_callbackr�r�)r)� event_listrr�rr�r�s r�_process_eventsz%BaseSelectorEventLoop._process_events�s���#�I�C��(+���S�X�X�%�G�%�f�f��i�*�*�*�v�/A��$�$��'�'��0��&�&�v�.��i�+�+�+��0B��$�$��'�'��0��&�&�v�.�$r*c�b�|j|j��|j�yr/)rMrOrJ)r)r2s r� _stop_servingz#BaseSelectorEventLoop._stop_serving�s�����D�K�K�M�*�� � �r*r/�NNN)r)4r#� __module__�__qualname__�__doc__rr5r�SSL_HANDSHAKE_TIMEOUT�SSL_SHUTDOWN_TIMEOUTr@rDrJrIr%r]rXrjrprmrwr0rWrMr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�rrrrr"r$� __classcell__�r"s@rrr5so���� 9�7�%)�$�7�9=�+� �$��t�"+�"A�"A�!*�!?�!?�+�&CG�B� "� �E� � �,�&#'�t�S�-6�-L�-L�,5�,J�,J�F��D�#�"+�"A�"A�!*�!?�!?� ,)�`�D�"+�"A�"A�!*�!?�!?� -5�^&�$� �*� �..� '� .� '� �,#�!� �*#�"�.#�"�2#�"�>�,�6 ��2�.#��* �,�"7�/�r*rc���eZdZdZdZd�fd� Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zd�Z d�Zej fd �Zdd�Zd�Zd�Zd�Zd�Z�xZS)�_SelectorTransportiNc����t�|�||�tj|�|jd< |j�|jd<d|jvr |j�|jd<||_ |j�|_d|_ |j|�||_t!j"�|_d|_d|_d|_|j�|jj-�||j.|j<y#t$rd|jd<Y��wxYw#tj$rd|jd<Y��wxYw)NrT�socknamerrFr)rrrr��_extra�getsocknamerg�getpeernamerT�errorrrOr�_protocol_connected�set_protocol�_server�collections�deque�_buffer� _conn_lost�_closing�_paused�_attachr()r)r�r2r3r,r-r"s �rrz_SelectorTransport.__init__s8��� �����%� &� 6� 6�t� <����H�� +�&*�&6�&6�&8�D�K�K� �#��T�[�[�(� /�*.�*:�*:�*<����J�'��� ���� �� �#(�� ����(�#����"�(�(�*�������� �����<�<�#��L�L� � �"�*.�������'��+� +�&*�D�K�K� �#� +�� �<�<� /�*.����J�'� /�s#�D'�!E�'E�E�"E*�)E*c��|jjg}|j�|jd�n|jr|jd�|jd|j ���|j��|jj�s�t|jj|j tj�}|r|jd�n|jd�t|jj|j tj�}|rd}nd}|j�}|jd|�d |�d ��djdj|��S) N�closed�closingzfd=zread=pollingz read=idle�polling�idlezwrite=<z , bufsize=�>z<{}>� )r"r#r�appendr<r�_looprHrr$rr�r��get_write_buffer_size�format�join)r)�inforB�stater�s r�__repr__z_SelectorTransport.__repr__'s$�����'�'�(���:�:���K�K��!� �]�]��K�K� �"����c�$�-�-��)�*��:�:�!�$�*�*�*>�*>�*@�*�4�:�:�+?�+?�+/�=�=�)�:N�:N�P�G�����N�+����K�(�*�4�:�:�+?�+?�+/�=�=�+4�+@�+@�B�G��!�����0�0�2�G��K�K�'�%�� �7�)�1�=�>��}�}�S�X�X�d�^�,�,r*c�&�|jd�yr/)�_force_closerRs r�abortz_SelectorTransport.abortCs�����$�r*c� �||_d|_y�NT)� _protocolr5)r)r3s rr6z_SelectorTransport.set_protocolFs��!���#'�� r*c��|jSr/)rSrRs r�get_protocolz_SelectorTransport.get_protocolJs���~�~�r*c��|jSr/)r<rRs rr�z_SelectorTransport.is_closingMs���}�}�r*c�B�|j�xr |jSr/)r�r=rRs rrz_SelectorTransport.is_readingPs���?�?�$�$�9�T�\�\�)9�9r*c���|j�syd|_|jj|j�|jj�rt jd|�yy)NTz%r pauses reading)rr=rGrMr� get_debugr r!rRs rrz _SelectorTransport.pause_readingSsP����� ������ � �!�!�$�-�-�0��:�:���!��L�L�,�d�3�"r*c���|js|jsyd|_|j|j|j�|j j �rtjd|�yy)NFz%r resumes reading) r<r=rWr�_read_readyrGrYr r!rRs rrz!_SelectorTransport.resume_reading[sW���=�=���������������(8�(8�9��:�:���!��L�L�-�t�4�"r*c�P�|jryd|_|jj|j�|jsa|xj dz c_|jj |j�|jj|jd�yy�NTr) r<rGrMrr:r;r�� call_soon�_call_connection_lostrRs rrJz_SelectorTransport.closecss���=�=���� �� � �!�!�$�-�-�0��|�|��O�O�q� �O��J�J�%�%�d�m�m�4��J�J� � ��!;�!;�T�B�r*c�v�|j�-|d|��t|��|jj�yy)Nzunclosed transport )�source)r�ResourceWarningrJ)r)�_warns r�__del__z_SelectorTransport.__del__ms5���:�:�!��'��x�0�/�$�O��J�J����"r*c��t|t�r4|jj�rDt j d||d��n*|jj ||||jd��|j|�y)Nz%r: %sTrd)rsrtr�r3) r�rgrGrYr r!rrSrO)r)r�rss r�_fatal_errorz_SelectorTransport._fatal_errorrse���c�7�#��z�z�#�#�%����X�t�W�t�D��J�J�-�-�"� �!� �N�N� /� � ���#�r*c��|jry|jr?|jj�|jj |j �|js,d|_|jj|j �|xjdz c_|jj|j|�yr]) r;r:�clearrGr�rr<rMr^r_)r)r�s rrOz_SelectorTransport._force_close�s����?�?���<�<��L�L��� ��J�J�%�%�d�m�m�4��}�}� �D�M��J�J�%�%�d�m�m�4����1���� � ���T�7�7��=r*c�� |jr|jj|�|jj �d|_d|_d|_|j}|�|j�d|_yy#|jj �d|_d|_d|_|j}|�|j�d|_wwxYwr/)r5rS�connection_lostrrJrGr7�_detach)r)r�r-s rr_z(_SelectorTransport._call_connection_lost�s��� $��'�'����.�.�s�3��J�J�����D�J�!�D�N��D�J��\�\�F��!���� �#���"�� �J�J�����D�J�!�D�N��D�J��\�\�F��!���� �#���"�s�'A?�?ACc�H�ttt|j��Sr/)�sum�mapr�r:rRs rrHz(_SelectorTransport.get_write_buffer_size�s���3�s�D�L�L�)�*�*r*c�b�|j�sy|jj||g|���yr/)rrGrWr�s rrWz_SelectorTransport._add_reader�s*����� ���� � ���r�8�3�d�3r*)NN)zFatal error on transport)r#r&r'�max_sizerrrMrPr6rUr�rrrrJ�warnings�warnrdrfrOr_rHrWr+r,s@rr.r.sk����H� �E�/�8-�8 �(���:�4�5�C�%�M�M�� � >�$�+�4r*r.c����eZdZdZej jZ d�fd� Z�fd�Z d�Z d�Zd�Zd�Z d �Zd �Zd�Zded dfd�Zd�Zd�Zd�Zd�Z�fd�Zd�Zd�Z�fd�Z�xZS)r1TNc���d|_t�|� |||||�d|_d|_t r|j|_n|j|_tj|j�|jj|jj|�|jj|j |j"|j$�|�,|jjt&j(|d�yyr)�_read_ready_cbrr�_eof� _empty_waiter�_HAS_SENDMSG�_write_sendmsg�_write_ready�_write_sendr�_set_nodelayrrGr^rS�connection_maderWrr[r�_set_result_unless_cancelled)r)r�r2r3r4r,r-r"s �rrz!_SelectorSocketTransport.__init__�s����#��� ����t�X�u�f�=��� �!���� $� 3� 3�D�� $� 0� 0�D�� � � ����,�� � ���T�^�^�;�;�T�B�� � ���T�-�-�!�]�]�D�,<�,<� >����J�J� � ��!E�!E�!'�� /�r*c���t|tj�r|j|_n|j |_t�|�|�yr/)r�r �BufferedProtocol�_read_ready__get_bufferru�_read_ready__data_receivedrr6)r)r3r"s �rr6z%_SelectorSocketTransport.set_protocol�s<����h� � :� :�;�"&�">�">�D��"&�"A�"A�D�� ���X�&r*c�$�|j�yr/)rurRs rr[z$_SelectorSocketTransport._read_ready�s�����r*c��|jry |jjd�}t|�st d�� |jj|�}|s|j�y |jj|�y#t tf$r�t$r}|j|d�Yd}~yd}~wwxYw#ttf$rYyt tf$r�t$r}|j|d�Yd}~yd}~wwxYw#t tf$r�t$r}|j|d�Yd}~yd}~wwxYw)N���z%get_buffer() returned an empty bufferz/Fatal error: protocol.get_buffer() call failed.�$Fatal read error on socket transportz3Fatal error: protocol.buffer_updated() call failed.)r;rS� get_bufferr�rGr�r�r�rfrr�rar`�_read_ready__on_eof�buffer_updated)r)r�r�r�s rr�z0_SelectorSocketTransport._read_ready__get_buffer�sC���?�?�� ��.�.�+�+�B�/�C��s�8�"�#J�K�K�� ��Z�Z�)�)�#�.�F���$�$�&�� L��N�N�)�)�&�1��-�-�.� ��� �����F� H��� �� �!1�2� ���-�.� ��� ����c�#I�J��� ���-�.� ��� L�����J� L� L�� L�sM�1B �C�1D� C�%B<�<C�D�D�,D�D�D?�#D:�:D?c���|jry |jj|j�}|s|j�y |jj|�y#tt f$rYyttf$r�t$r}|j|d�Yd}~yd}~wwxYw#ttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nr�z2Fatal error: protocol.data_received() call failed.) r;rr_rprar`r�r�r�rfr�rS� data_received)r)r\r�s rr�z3_SelectorSocketTransport._read_ready__data_received�s����?�?�� ��:�:�?�?�4�=�=�1�D���$�$�&�� K��N�N�(�(��.�� �!1�2� ���-�.� ��� ����c�#I�J��� ���-�.� ��� K�����I� K� K�� K�s5�%A$�B+�$B(�5B(�B#�#B(�+C�C�Cc�x�|jj�rtjd|� |jj�}|r&|jj|j�y|j�y#ttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rGrYr r!rS�eof_receivedr�r�r�rfrMrrJ)r)� keep_openr�s rr�z,_SelectorSocketTransport._read_ready__on_eof s����:�:���!��L�L�*�D�1� ����3�3�5�I�� �J�J�%�%�d�m�m�4��J�J�L���-�.� ��� �����H� J��� �s�B�B9�B4�4B9c�<�t|tttf�s!t dt|�j����|jrtd��|j�td��|sy|jrH|jtjk\rtjd�|xjdz c_ y|js] |j j#|�}t|�|d}|sy|j0j3|j4|j6�|jj9|�|j;�y#t$t&f$rY�mt(t*f$r�t,$r}|j/|d�Yd}~yd}~wwxYw)N�/data argument must be a bytes-like object, not z%Cannot call write() after write_eof()z(unable to write; sendfile is in progress�socket.send() raised exception.r�%Fatal write error on socket transport)r��bytes� bytearrayr�r�r�r#rvrGrwr;r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr �warningr:rrfrar`r�r�r�rfrGr�rrzrF�_maybe_pause_protocol)r)r\r�r�s r�writez_SelectorSocketTransport.writes_���$�� �:� >�?��#�#'��:�#6�#6�"9�;�<� <��9�9��F�G�G����)��I�J�J����?�?����)�"M�"M�M����@�A��O�O�q� �O���|�|� ��J�J�O�O�D�)��"�$�'���+�����J�J�"�"�4�=�=�$�2C�2C�D� �����D�!��"�"�$��!$�%5�6� ��� 1�2� �� � ��!�!�#�'N�O��� �s�E�F�(F�?F�Fc�J�tj|jt�Sr/)� itertools�islicer:rrRs r�_get_sendmsg_bufferz,_SelectorSocketTransport._get_sendmsg_bufferFs��������j�9�9r*c��|jsJd��|jry |jj|j ��}|j|�|j �|js�|jj|j�|j�|jjd�|jr|jd�y|jr*|jjt j"�yyy#t$t&f$rYyt(t*f$r�t,$r�}|jj|j�|jj/�|j1|d�|j� |jj3|�Yd}~yYd}~yd}~wwxYw�NzData should not be emptyr�)r:r;rrr��_adjust_leftover_buffer�_maybe_resume_protocolrGr�rrwr�r<r_rv�shutdownrT�SHUT_WRrar`r�r�r�rhrfr�)r)r�r�s rryz'_SelectorSocketTransport._write_sendmsgIsh���|�|�7�7�7�|��?�?�� 8��Z�Z�'�'��(@�(@�(B�C�F��(�(��0� �'�'�)��<�<�� � �)�)�$�-�-�8��%�%�1��&�&�1�1�$�7��=�=��.�.�t�4��Y�Y��J�J�'�'����7�� �� �!1�2� ���-�.� ��� 6��J�J�%�%�d�m�m�4��L�L��� ����c�#J�K��!�!�-��"�"�0�0��5�5�.�� 6�s�:D�G �+G �A8G�G r��returnc��|j}|r?|j�}t|�}||kr||z}n|j||d�y|r�>yyr/)r:�popleftr�� appendleft)r)r��buffer�b�b_lens rr�z0_SelectorSocketTransport._adjust_leftover_bufferesO���������� �A���F�E�����%����!�!�!�F�G�*�-��r*c���|jsJd��|jry |jj�}|jj |�}|t|�k7r|jj ||d�|j�|js�|jj|j�|j�|jjd�|jr|jd�y|jr*|jj!t"j$�yyy#t&t(f$rYyt*t,f$r�t.$r�}|jj|j�|jj1�|j3|d�|j� |jj5|�Yd}~yYd}~yd}~wwxYwr�)r:r;r�rrfr�r�r�rGr�rrwr�r<r_rvr�rTr�rar`r�r�r�rhrfr�)r)r�r�r�s rr{z$_SelectorSocketTransport._write_sendps����|�|�7�7�7�|��?�?�� 8��\�\�)�)�+�F�� � ����'�A��C��K�����'�'��q�r� �3� �'�'�)��<�<�� � �)�)�$�-�-�8��%�%�1��&�&�1�1�$�7��=�=��.�.�t�4��Y�Y��J�J�'�'����7�� �� �!1�2� ���-�.� ��� 6��J�J�%�%�d�m�m�4��L�L��� ����c�#J�K��!�!�-��"�"�0�0��5�5�.�� 6�s�A!E�G0�G0�)A8G+�+G0c��|js|jryd|_|js*|jj t j�yyrR)r<rvr:rr�rTr�rRs r� write_eofz"_SelectorSocketTransport.write_eof�s;���=�=�D�I�I���� ��|�|��J�J������/�r*c��|jrtd��|j�td��|sy|jj |D�cgc] }t|���c}�|j �|jrA|jj|j|j�|j�yycc}w)Nz*Cannot call writelines() after write_eof()z-unable to writelines; sendfile is in progress)rvrGrwr:�extendr�rzrGr�rr�)r)�list_of_datar\s r� writelinesz#_SelectorSocketTransport.writelines�s����9�9��K�L�L����)��N�O�O��������,�G�,�$�Z��-�,�G�H������<�<��J�J�"�"�4�=�=�$�2C�2C�D��&�&�(���Hs�Cc��yrRrZrRs r� can_write_eofz&_SelectorSocketTransport.can_write_eof�s��r*c��� t�|�|�d|_|j�%|jj td��yy#d|_|j�%|jj td��wwxYw)NzConnection is closed by peer)rr_rzrwr��ConnectionError)r)r�r"s �rr_z._SelectorSocketTransport._call_connection_lost�s���� E��G�)�#�.� $�D���!�!�-��"�"�0�0�#�$B�C�E�.��!%�D���!�!�-��"�"�0�0�#�$B�C�E�.�s�A�:Bc���|j�td��|jj�|_|js|jjd�|jS)NzEmpty waiter is already set)rwrGrGr�r:r�rRs rrz+_SelectorSocketTransport._make_empty_waiter�sV�����)��<�=�=�!�Z�Z�5�5�7����|�|����)�)�$�/��!�!�!r*c��d|_yr/)rwrRs rrz,_SelectorSocketTransport._reset_empty_waiter�s ��!��r*c�0��d|_t�|� �yr/)rurrJrKs �rrJz_SelectorSocketTransport.close�s���"��� �� �r*r%)r#r&r'�_start_tls_compatibler� _SendfileMode� TRY_NATIVE�_sendfile_compatiblerr6r[r�r�r�r�r�ryr�r�r{r�r�r�r_rrrJr+r,s@rr1r1�s���� ��$�2�2�=�=��48�$(�/�2'��#L�JK�2�*%%�N:�8�8 �c� �d� �8�>0�)��E�"�"��r*r1c�V��eZdZejZ d�fd� Zd�Zd�Zdd�Z d�Z �xZS)rBc�x��t�|�||||�||_d|_|jj|jj|�|jj|j|j|j�|�,|jjtj|d�yyr�) rr�_address�_buffer_sizerGr^rSr}rWrr[rr~)r)r�r2r3rCr4r,r"s �rrz#_SelectorDatagramTransport.__init__�s���� ����t�X�u�5��� ����� � ���T�^�^�;�;�T�B�� � ���T�-�-�!�]�]�D�,<�,<� >����J�J� � ��!E�!E�!'�� /�r*c��|jSr/)r�rRs rrHz0_SelectorDatagramTransport.get_write_buffer_size�s��� � � r*c��|jry |jj|j�\}}|jj||�y#ttf$rYyt$r%}|jj|�Yd}~yd}~wttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nz&Fatal read error on datagram transport)r;rr�rprS�datagram_receivedrar`rg�error_receivedr�r�r�rf�r)r\r�r�s rr[z&_SelectorDatagramTransport._read_ready�s����?�?�� 9����,�,�T�]�]�;�J�D�$� �N�N�,�,�T�4�8�� �!1�2� ��� /��N�N�)�)�#�.�.���-�.� ��� M����c�#K�L�L�� M�s)�(A�C�%C�-B � C�(B?�?Cc�Z�t|tttf�s!t dt|�j����|sy|jr4|d|jfvrtd|j����|j}|jrT|jrH|jtjk\rtjd�|xjdz c_ y|jsI |jdr|j j#|�y|j j%||�y|jjAt|�|f�|xjBtE|�z c_!|jG�y#t&t(f$r3|j*j-|j.|j0�Y��t2$r%}|j4j7|�Yd}~yd}~wt8t:f$r�t<$r}|j?|d�Yd}~yd}~wwxYw)Nr�z!Invalid address: must be None or r�rrr�'Fatal write error on datagram transport)$r�r�r�r�r�r�r#r�r�r;rr�r r�r:r1rrfr�rar`rGr�r� _sendto_readyrgrSr�r�r�r�rfrFr�r�r�r�s rr�z!_SelectorDatagramTransport.sendto�s����$�� �:� >�?��#�#'��:�#6�#6�"9�;�<� <����=�=��D�$�-�-�0�0� �7�� � ��G�I�I��=�=�D��?�?�t�}�}����)�"M�"M�M����@�A��O�O�q� �O���|�|� ��;�;�z�*��J�J�O�O�D�)���J�J�%�%�d�D�1�� �����U�4�[�$�/�0����S��Y�&���"�"�$��$�%5�6� J�� � �&�&�t�}�}�d�6H�6H�I�� ����-�-�c�2���� 1�2� �� � ��!�!��B�D��� �s0�-*F �F � ?H*�H*�G3�3H*�H%�%H*c�X�|jr�|jj�\}}|xjt|�zc_ |jdr|j j |�n|j j||�|jr��|j%�|jsD|j&j)|j*�|j,r|j/d�yyy#ttf$r>|jj||f�|xjt|�z c_Y��t$r%}|jj|�Yd}~yd}~wttf$r�t $r}|j#|d�Yd}~yd}~wwxYw)Nrrr�)r:r�r�r�r1rrfr�rar`r�rgrSr�r�r�r�rfr�rGr�rr<r_r�s rr�z(_SelectorDatagramTransport._sendto_readysQ���l�l����-�-�/�J�D�$�����T��*�� ��;�;�z�*��J�J�O�O�D�)��J�J�%�%�d�D�1��l�l�, �#�#�%��|�|��J�J�%�%�d�m�m�4��}�}��*�*�4�0����$�%5�6� ����'�'��t��5��!�!�S��Y�.�!��� ����-�-�c�2���� 1�2� �� � ��!�!��B�D��� �s,� AC>�>A F)� F)�E2�2F)� F$�$F)r%r/)r#r&r'r8r9�_buffer_factoryrrHr[r�r�r+r,s@rrBrB�s.���!�'�'�O�59�$(�/�!�9� *%�X1r*rB)&r(�__all__r8rzr�r��osrrTrqr&�ssl�ImportError�rrrrr r rr�logr �hasattrrx�sysconfrrgr� BaseEventLoopr�_FlowControlMixin� Transportr.r1�DatagramTransportrBrZr*r�<module>r�s���#������ �� ���������������v�}�}�i�0�����R�Z�Z��-� � (�I�K�5�5�I�X_4��5�5�#�-�-�_4�DZ�1�Z�zl1�!3�Z�5Q�5Q�l1��Y%�� �C���$�����s#�C&�:C3�&C0�/C0�3C=�<C=__pycache__/sslproto.cpython-312.opt-1.pyc000064400000121520151706172560014316 0ustar00� T��h�|��z�ddlZddlZddlZ ddlZddlmZddlmZddlmZddlm Z ddl mZe�ejejfZGd�d ej�ZGd �dej�Zd�Zd �ZGd�de j(e j*�ZGd�dej.�Zy#e$rdZY��wxYw)�N�)� constants)� exceptions)� protocols)� transports)�loggerc� �eZdZdZdZdZdZdZy)�SSLProtocolState� UNWRAPPED�DO_HANDSHAKE�WRAPPED�FLUSHING�SHUTDOWNN)�__name__� __module__�__qualname__rrr rr���)/usr/lib64/python3.12/asyncio/sslproto.pyr r s���I�!�L��G��H��Hrr c��eZdZdZdZdZdZy)�AppProtocolState� STATE_INIT�STATE_CON_MADE� STATE_EOF�STATE_CON_LOSTN)rrrrrrrrrrrrs���J�%�N��I�%�Nrrc�Z�|rtd��tj�}|sd|_|S)Nz(Server side SSL needs a valid SSLContextF)� ValueError�ssl�create_default_context�check_hostname)�server_side�server_hostname� sslcontexts r�_create_transport_contextr$/s2����C�D�D��+�+�-�J��$)� �!��rc��|�|�|dz}n |}d|z}n|}|�|dz}n|}||cxk\rdk\sntd|�d|�d���||fS)Ni�rzhigh (z) must be >= low (z) must be >= 0)r)�high�low�kb�hi�los r�add_flowcontrol_defaultsr,=sh���|��;��d��B��B��R��B� �� �{� �1�W�� �� ��=�q�=���b�"�#� #��r�6�Mrc���eZdZdZej jZd�Zdd�Z d�Z d�Zd�Zd�Z efd �Zd �Zd�Zd�Zdd �Zd�Zd�Zdd�Zd�Zd�Zed��Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!y)�_SSLProtocolTransportTc�.�||_||_d|_y)NF)�_loop� _ssl_protocol�_closed)�self�loop�ssl_protocols r�__init__z_SSLProtocolTransport.__init__Xs���� �)�����rNc�:�|jj||�S)z#Get optional transport information.)r1�_get_extra_info�r3�name�defaults r�get_extra_infoz$_SSLProtocolTransport.get_extra_info]s���!�!�1�1�$��@�@rc�:�|jj|�y�N)r1�_set_app_protocol)r3�protocols r�set_protocolz"_SSLProtocolTransport.set_protocolas�����,�,�X�6rc�.�|jjSr>)r1� _app_protocol�r3s r�get_protocolz"_SSLProtocolTransport.get_protocolds���!�!�/�/�/rc�R�|jxs|jj�Sr>)r2r1�_is_transport_closingrDs r� is_closingz _SSLProtocolTransport.is_closinggs ���|�|�I�t�1�1�G�G�I�Irc�n�|js"d|_|jj�yd|_y)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. TN)r2r1�_start_shutdownrDs r�closez_SSLProtocolTransport.closejs,���|�|��D�L����.�.�0�!%�D�rc�X�|jsd|_|jdt�yy)NTz9unclosed transport <asyncio._SSLProtocolTransport object>)r2�warn�ResourceWarning)r3� _warningss r�__del__z_SSLProtocolTransport.__del__xs)���|�|��D�L��N�N��*� ,�rc�0�|jjSr>)r1�_app_reading_pausedrDs r� is_readingz _SSLProtocolTransport.is_readings���%�%�9�9�9�9rc�8�|jj�y)z�Pause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)r1�_pause_readingrDs r� pause_readingz#_SSLProtocolTransport.pause_reading�s�� ���)�)�+rc�8�|jj�y)z�Resume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)r1�_resume_readingrDs r�resume_readingz$_SSLProtocolTransport.resume_reading�s�� ���*�*�,rc�p�|jj||�|jj�y)a�Set the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)r1�_set_write_buffer_limits�_control_app_writing�r3r'r(s r�set_write_buffer_limitsz-_SSLProtocolTransport.set_write_buffer_limits�s,��& ���3�3�D�#�>����/�/�1rc�Z�|jj|jjfSr>)r1�_outgoing_low_water�_outgoing_high_waterrDs r�get_write_buffer_limitsz-_SSLProtocolTransport.get_write_buffer_limits��*���"�"�6�6��"�"�7�7�9� 9rc�6�|jj�S)z-Return the current size of the write buffers.)r1�_get_write_buffer_sizerDs r�get_write_buffer_sizez+_SSLProtocolTransport.get_write_buffer_size�s���!�!�8�8�:�:rc�p�|jj||�|jj�y)a�Set the high- and low-water limits for read flow control. These two values control when to call the upstream transport's pause_reading() and resume_reading() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_reading() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_reading() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)r1�_set_read_buffer_limits�_control_ssl_readingr]s r�set_read_buffer_limitsz,_SSLProtocolTransport.set_read_buffer_limits�s,��& ���2�2�4��=����/�/�1rc�Z�|jj|jjfSr>)r1�_incoming_low_water�_incoming_high_waterrDs r�get_read_buffer_limitsz,_SSLProtocolTransport.get_read_buffer_limits�rcrc�6�|jj�S)z+Return the current size of the read buffer.)r1�_get_read_buffer_sizerDs r�get_read_buffer_sizez*_SSLProtocolTransport.get_read_buffer_size�s���!�!�7�7�9�9rc�.�|jjSr>)r1�_app_writing_pausedrDs r�_protocol_pausedz&_SSLProtocolTransport._protocol_paused�s���!�!�5�5�5rc��t|tttf�s!t dt|�j����|sy|jj|f�y)z�Write some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. z+data: expecting a bytes-like instance, got N) � isinstance�bytes� bytearray� memoryview� TypeError�typerr1�_write_appdata�r3�datas r�writez_SSLProtocolTransport.write�sX���$�� �:� >�?��#�#'��:�#6�#6�"7�9�:� :������)�)�4�'�2rc�:�|jj|�y)z�Write a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. N)r1r|)r3�list_of_datas r� writelinesz _SSLProtocolTransport.writelines�s�� ���)�)�,�7rc��t�)zuClose the write end after flushing buffered data. This raises :exc:`NotImplementedError` right now. )�NotImplementedErrorrDs r� write_eofz_SSLProtocolTransport.write_eof�s �� "�!rc��y)zAReturn True if this transport supports write_eof(), False if not.FrrDs r� can_write_eofz#_SSLProtocolTransport.can_write_eof�s��rc�&�|jd�y)z�Close the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)�_force_closerDs r�abortz_SSLProtocolTransport.abort�s�� ���$�rc�b�d|_|j�|jj|�yy�NT)r2r1�_abort�r3�excs rr�z"_SSLProtocolTransport._force_close�s.��������)����%�%�c�*�*rc��|jjj|�|jxjt |�z c_yr>)r1�_write_backlog�append�_write_buffer_size�lenr}s r�_test__append_write_backlogz1_SSLProtocolTransport._test__append_write_backlogs7�����)�)�0�0��6����-�-��T��:�-rr>�NN)"rrr�_start_tls_compatibler� _SendfileMode�FALLBACK�_sendfile_compatibler6r<rArErHrK�warningsrPrSrVrYr^rbrfrjrnrq�propertyrtrr�r�r�r�r�r�rrrr.r.Rs���!��$�2�2�;�;��� A�7�0�J�&�!)�,�:�,�-�2�,9�;�2�,9�:��6��6�3�8�"�� �+� ;rr.c� �eZdZdZdZdZdZ d+d�Zd�Zd,d�Z d�Z d�Zd�Zd �Z d �Zd�Zd�Zd,d �Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d �Z$d!�Z%d-d"�Z&d#�Z'd$�Z(d%�Z)d-d&�Z*d'�Z+d(�Z,d)�Z-d.d*�Z.y)/�SSLProtocoliNc ���t�td��t|j�|_t|j�|_|�tj}n|dkrtd|����| �tj} n| dkrtd| ����|st||�}||_|r |s||_ nd|_ ||_t|��|_t#j$�|_d|_||_||_|j/|�d|_d|_d|_||_| |_tj:�|_tj:�|_t@jB|_"d|_#|rtHjJ|_&ntHjN|_&|jjQ|j<|j>|j|j��|_)d|_*d|_+d|_,d|_-d|_.|j_�d|_0d|_1d|_2d|_3|ji�|jk�y)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got z6ssl_shutdown_timeout should be a positive number, got )r#F)r!r")6r�RuntimeErrorrx�max_size�_ssl_bufferry�_ssl_buffer_viewr�SSL_HANDSHAKE_TIMEOUTr�SSL_SHUTDOWN_TIMEOUTr$�_server_side�_server_hostname�_sslcontext�dict�_extra�collections�dequer�r��_waiterr0r?�_app_transport�_app_transport_created� _transport�_ssl_handshake_timeout�_ssl_shutdown_timeout� MemoryBIO� _incoming� _outgoingr r�_state� _conn_lostrr� _app_stater�wrap_bio�_sslobj�_ssl_writing_pausedrR�_ssl_reading_pausedrmrlrh� _eof_receivedrsrar`r[�_get_app_transport) r3r4�app_protocolr#�waiterr!r"�call_connection_made�ssl_handshake_timeout�ssl_shutdown_timeouts rr6zSSLProtocol.__init__sE�� �;��@�A�A�$�T�]�]�3��� *�4�+;�+;� <��� �(�$-�$C�$C�!� "�a� '���,�-�/�0� 0� �'�#,�#A�#A� � !�Q� &���+�,�.�/� /��2��_�.�J�(����;�$3�D�!�$(�D�!�%����j�1���*�/�/�1���"#�������� ����|�,�"���&+��#����&;��#�%9��"�������������&�0�0�������.�9�9�D�O�.�=�=�D�O��'�'�0�0��N�N�D�N�N��)�)� �1�1�1�3���$)�� �#(�� �#(�� �$%��!�#$�� ��$�$�&�"���#(�� �$%��!�#$�� ��%�%�'����!rc��||_t|d�rDt|tj�r*|j |_|j|_d|_ yd|_ y)N� get_bufferTF) rC�hasattrrvr�BufferedProtocolr��_app_protocol_get_buffer�buffer_updated�_app_protocol_buffer_updated�_app_protocol_is_buffer)r3r�s rr?zSSLProtocol._set_app_protocolasP��)����L�,�/��<��)C�)C�D�,8�,C�,C�D�)�0<�0K�0K�D�-�+/�D�(�+0�D�(rc���|j�y|jj�s@|�#|jj|�d|_y|jjd�d|_yr>)r�� cancelled� set_exception� set_resultr�s r�_wakeup_waiterzSSLProtocol._wakeup_waiterlsZ���<�<����|�|�%�%�'������*�*�3�/�������'�'��-���rc��|j�9|jrtd��t|j|�|_d|_|jS)Nz$Creating _SSLProtocolTransport twiceT)r�r�r�r.r0rDs rr�zSSLProtocol._get_app_transportvsJ�����&��*�*�"�#I�J�J�"7�� � �D�"I�D��*.�D�'��"�"�"rc�V�|jduxr|jj�Sr>)r�rHrDs rrGz!SSLProtocol._is_transport_closing~s#�����d�*�K�t���/I�/I�/K�Krc�2�||_|j�y)zXCalled when the low-level connection is made. Start the SSL handshake. N)r��_start_handshake)r3� transports r�connection_madezSSLProtocol.connection_made�s�� $������rc�H�|jj�|jj�|xjdz c_|j �d|j _|jtjk7r|jtjk(s|jtjk(rEtj|_ |jj!|j"j$|�|j'tj(�d|_d|_d|_|j-|�|j.r!|j.j1�d|_|j2r"|j2j1�d|_yy)z�Called when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). rNT)r��clearr��readr�r�r2r�r rr�rrrrr0� call_soonrC�connection_lost� _set_staterr�r��_shutdown_timeout_handle�cancel�_handshake_timeout_handler�s rr�zSSLProtocol.connection_lost�s9�� ���!�!�#����������1������*�*.�D���'��;�;�*�7�7�7����#3�#B�#B�B����#3�#=�#=�=�"2�"A�"A���� � �$�$�T�%7�%7�%G�%G��M����(�2�2�3����"���!������C� ��(�(��)�)�0�0�2�,0�D�)��)�)��*�*�1�1�3�-1�D�*�*rc���|}|dks||jkDr|j}t|j�|kr*t|�|_t |j�|_|j S�Nr)r�r�r�rxryr�)r3�n�wants rr�zSSLProtocol.get_buffer�s`�����1�9��t�}�}�,��=�=�D��t��� �4�'�(���D��$.�t�/?�/?�$@�D�!��$�$�$rc���|jj|jd|�|jtj k(r|j �y|jtjk(r|j�y|jtjk(r|j�y|jtjk(r|j�yyr>) r�rr�r�r r� _do_handshaker �_do_readr� _do_flushr�_do_shutdown)r3�nbytess rr�zSSLProtocol.buffer_updated�s��������T�2�2�7�F�;�<��;�;�*�7�7�7���� � �[�[�,�4�4� 4��M�M�O� �[�[�,�5�5� 5��N�N�� �[�[�,�5�5� 5�����6rc���d|_ |jj�rtjd|�|j tjk(r|jt�y|j tjk(r=|jtj�|jry|j�y|j tjk(r@|j�|jtj �|j#�y|j tj k(r|j#�yy#t$$r|j&j)��wxYw)aCalled when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Tz%r received EOFN)r�r0� get_debugr�debugr�r r�_on_handshake_complete�ConnectionResetErrorr r�rrRr�� _do_writerr�� Exceptionr�rKrDs r�eof_receivedzSSLProtocol.eof_received�s��"��� ��z�z�#�#�%����.��5��{�{�.�;�;�;��+�+�,@�A���� 0� 8� 8�8���� 0� 9� 9�:��+�+���N�N�$���� 0� 9� 9�9���� ���� 0� 9� 9�:��!�!�#���� 0� 9� 9�9��!�!�#�:��� ��O�O�!�!�#�� �s&�A"E�,AE�5E�AE�#-E�%E7c��||jvr|j|S|j�|jj||�S|Sr>)r�r�r<r9s rr8zSSLProtocol._get_extra_info�sC���4�;�;���;�;�t�$�$� �_�_� (��?�?�1�1�$��@�@��Nrc�&�d}|tjk(rd}n�|jtjk(r|tjk(rd}n�|jtjk(r|tjk(rd}ne|jtjk(r|tj k(rd}n2|jtj k(r|tjk(rd}|r||_ytdj|j|���)NFTz!cannot switch state from {} to {}) r rr�rr rrr��format)r3� new_state�alloweds rr�zSSLProtocol._set_state�s������(�2�2�2��G� �K�K�+�5�5�5��)�6�6�6��G� �K�K�+�8�8�8��)�1�1�1��G� �K�K�+�3�3�3��)�2�2�2��G� �K�K�+�4�4�4��)�2�2�2��G��#�D�K��3�:�:��K�K��,�-� -rc�n���jj�r6tjd���jj ��_nd�_�j tj��jj�j�fd���_�j�y)Nz%r starts SSL handshakec�$���j�Sr>)�_check_handshake_timeoutrDs�r�<lambda>z.SSLProtocol._start_handshake.<locals>.<lambda>$s���$�*G�*G�*Ir) r0r�rr��time�_handshake_start_timer�r r� call_laterr�r�r�rDs`rr�zSSLProtocol._start_handshakes�����:�:���!��L�L�2�D�9�)-�����):�D�&�)-�D�&����(�5�5�6� �J�J�!�!�$�"=�"=�"I� K� �&� ���rc��|jtjk(r+d|j�d�}|j t|��yy)Nz$SSL handshake is taking longer than z! seconds: aborting the connection)r�r rr��_fatal_error�ConnectionAbortedError)r3�msgs rr�z$SSLProtocol._check_handshake_timeout(sN���;�;�*�7�7�7�6��.�.�/�0*�+� � ���4�S�9�:� 8rc��� |jj�|jd�y#t$r|j �Yyt j$r}|j|�Yd}~yd}~wwxYwr>)r��do_handshaker��SSLAgainErrors�_process_outgoingr�SSLErrorr�s rr�zSSLProtocol._do_handshake1sb�� .��L�L�%�%�'� �'�'��-��� %��"�"�$��|�|� -��'�'��,�,�� -�s�.�A6� A6�A1�1A6c���|j�!|jj�d|_|j} |� |jtj �n|�|j �}|jj�rA|jj!�|j"z }t%j&d||dz�|j(j+||j-�|j/�|��|j0t2j4k(r>t2j6|_|j8j;|j=��|j�|j?�y#t$rm}d}|jtj�t|tj�rd}nd}|j||�|j|�Yd}~yd}~wwxYw)Nz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@�@)�peercert�cipher�compression� ssl_object) r�r�r�r�r r �getpeercertr�rrvr�CertificateErrorr�r�r0r�r�r�rr�r��updater r r�rrrrCr�r�r�)r3� handshake_exc�sslobjrr�r�dts rr�z"SSLProtocol._on_handshake_complete;s����)�)�5��*�*�1�1�3�-1�D�*����� ��$���� 0� 8� 8�9�#�#��)�)�+�H��:�:���!������"�T�%?�%?�?�B��L�L�9�4��c��J� �����H�"(�-�-�/�'-�'9�'9�';�&,� � .��?�?�.�9�9�9�.�=�=�D�O����.�.�t�/F�/F�/H�I������ � ���1� � �M��O�O�,�6�6�7��#�s�3�3�4�I��,�����c�3�'�����$��� �s�4F� G7� A#G2�2G7c�����jtjtjtjfvry�j �d�j _�jtjk(r�jd�y�jtj��jj�j�fd���_ �j�y)NTc�$���j�Sr>)�_check_shutdown_timeoutrDs�rr�z-SSLProtocol._start_shutdown.<locals>.<lambda>us����4�4�6r)r�r rrrr�r2rr�r�r0r�r�r�r�rDs`rrJzSSLProtocol._start_shutdownds�����K�K� �)�)� �)�)� �*�*�� � ����*�*.�D���'��;�;�*�7�7�7��K�K����O�O�,�5�5�6�,0�J�J�,A�,A��*�*�6�-�D�)� �N�N�rc��|jtjtjfvr/|jjt jd��yy)NzSSL shutdown timed out)r�r rrr�r�r�TimeoutErrorrDs rrz#SSLProtocol._check_shutdown_timeoutysN���K�K� �)�)� �)�)�� � �O�O�(�(��'�'�(@�A� C� rc��|j�|jtj�|j �yr>)r�r�r rr�rDs rr�zSSLProtocol._do_flush�s*��� � �����(�1�1�2����rc�J� |js|jj�|j�|j �|jd�y#t$r|j�Yytj$r}|j|�Yd}~yd}~wwxYwr>) r�r��unwrapr�_call_eof_received�_on_shutdown_completerrrr�s rr�zSSLProtocol._do_shutdown�s��� -��%�%����#�#�%� �"�"�$��#�#�%��&�&�t�,��� %��"�"�$��|�|� ,��&�&�s�+�+�� ,�s�&A�B"�5B"�B�B"c���|j�!|jj�d|_|r|j|�y|jj |j j�yr>)r�r�r�r0r�r�rK)r3�shutdown_excs rrz!SSLProtocol._on_shutdown_complete�sU���(�(�4��)�)�0�0�2�,0�D�)�����l�+��J�J� � ����!6�!6�7rc��|jtj�|j�|jj |�yyr>)r�r rr�r�r�s rr�zSSLProtocol._abort�s6�����(�2�2�3��?�?�&��O�O�(�(��-�'rc�8�|jtjtjtjfvrH|j tjk\rtjd�|xj dz c_y|D];}|jj|�|xjt|�z c_�= |jtjk(r|j�yy#t $r}|j#|d�Yd}~yd}~wwxYw)NzSSL connection is closedr�Fatal error on SSL protocol)r�r rrrr�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr�warningr�r�r�r�r r�r�r�)r3r�r~�exs rr|zSSLProtocol._write_appdata�s����K�K� �)�)� �)�)� �*�*�� ����)�"M�"M�M����9�:��O�O�q� �O�� �D����&�&�t�,��#�#�s�4�y�0�#�!� A��{�{�.�6�6�6���� �7��� A����b�"?�@�@�� A�s�-C4�4 D�=D�Dc�~� |jr�|jd}|jj|�}t|�}||kr(||d|jd<|xj|zc_n"|jd=|xj|zc_|jr��|j �y#t $rY�wxYwr�)r�r�rr�r�rr)r3r~�count�data_lens rr�zSSLProtocol._do_write�s��� ��%�%��*�*�1�-�����*�*�4�0���t�9���8�#�-1�%�&�\�D�'�'��*��+�+�u�4�+��+�+�A�.��+�+�x�7�+��%�%� ��� ��� �� �s�BB0�0 B<�;B<c��|js@|jj�}t|�r|jj|�|j �yr>)r�r�r�r�r�rr\r}s rrzSSLProtocol._process_outgoing�sB���'�'��>�>�&�&�(�D��4�y����%�%�d�+��!�!�#rc��|jtjtjfvry |jsZ|j r|j �n|j�|jr|j�n|j�|j�y#t$r}|j|d�Yd}~yd}~wwxYw)Nr )r�r r rrRr��_do_read__buffered�_do_read__copiedr�r�rrir�r�)r3r#s rr�zSSLProtocol._do_read�s����K�K� �(�(� �)�)� � � � A��+�+��/�/��+�+�-��)�)�+��&�&��N�N�$��*�*�,��%�%�'��� A����b�"?�@�@�� A�s�A6B&�& C�/C�Cc����d}d}�j�j��}t|�} �jj ||�}|dkDrY|}||kr4�jj ||z ||d�}|dkDr||z }nn$||kr�4�j j �fd��|dkDr�j|�|s!�j��j�yy#t$rY�EwxYw)Nrrc�$���j�Sr>)r�rDs�rr�z0SSLProtocol._do_read__buffered.<locals>.<lambda>s������r)r�rpr�r�r�r0r�rr�rrJ)r3�offsetr%�buf�wantss` rr)zSSLProtocol._do_read__buffered�s���������+�+�D�,F�,F�,H�I���C��� ��L�L�%�%�e�S�1�E��q�y����u�n� �L�L�-�-�e�f�n�c�&�'�l�K�E��q�y��%�����u�n��J�J�(�(�)@�A��A�:��-�-�f�5���#�#�%�� � �"��� � �� �s�AC%� C%�% C1�0C1c��d}d}d} |jj|j�}|sn$|rd}d}|}n|rd}|g}nj|��L |r|j j �n,|s*|j j dj��|s!|j�|j�yy#t$rY�ywxYw)N�1TFr) r�r�r�r�rrC� data_received�joinrrJ)r3�chunk�zero�one�firstr~s rr*zSSLProtocol._do_read__copied s��������� �����)�)�$�-�-�8����� �D��C�!�E���C�!�5�>�D��K�K��&�������,�,�U�3�����,�,�S�X�X�d�^�<���#�#�%�� � �"��� � �� �s�A C� C�Cc�>� |jtjk(rHtj|_|jj�}|rt jd�yyy#ttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nz?returning true from eof_received() has no effect when using sslzError calling eof_received())r�rrrrCr�rr"�KeyboardInterrupt� SystemExit� BaseExceptionr�)r3� keep_openr#s rrzSSLProtocol._call_eof_received(s��� B����"2�"A�"A�A�"2�"<�"<��� �.�.�;�;�=� ���N�N�$B�C��B��"�:�.� ��� B����b�"@�A�A�� B�s�A#A(�(B�B�Bc�Z�|j�}||jk\r/|js#d|_ |jj �y||jkr0|jr#d|_ |jj�yyy#t tf$r�t$r4}|jjd||j|d��Yd}~yd}~wwxYw#t tf$r�t$r4}|jjd||j|d��Yd}~yd}~wwxYw)NTzprotocol.pause_writing() failed��message� exceptionr�r@Fz protocol.resume_writing() failed) rerarsrC� pause_writingr9r:r;r0�call_exception_handlerr�r`�resume_writing)r3�sizer�s rr\z SSLProtocol._control_app_writing7s$���*�*�,���4�,�,�,�T�5M�5M�'+�D�$� ��"�"�0�0�2��T�-�-� -�$�2J�2J�',�D�$� ��"�"�1�1�3�3K� -��&�z�2� �� � �� � �1�1�@�!$�!%�!4�!4� $� 3���� ��&�z�2� �� � �� � �1�1�A�!$�!%�!4�!4� $� 3���� �s/�B�2C�C�'*C�C�D*�6*D%�%D*c�H�|jj|jzSr>)r��pendingr�rDs rrez"SSLProtocol._get_write_buffer_sizeTs���~�~�%�%��(?�(?�?�?rc�\�t||tj�\}}||_||_yr>)r,r�!FLOW_CONTROL_HIGH_WATER_SSL_WRITErar`r]s rr[z$SSLProtocol._set_write_buffer_limitsWs.��,��#�y�B�B�D� ��c�$(��!�#&�� rc��d|_yr�)rRrDs rrUzSSLProtocol._pause_reading_s ��#'�� rc�n���jr(d�_�fd�}�jj|�yy)NFc����jtjk(r�j�y�jtjk(r�j�y�jtjk(r�j�yyr>)r�r r r�rr�rr�rDs�r�resumez+SSLProtocol._resume_reading.<locals>.resumefs`����;�;�"2�":�":�:��M�M�O��[�[�$4�$=�$=�=��N�N�$��[�[�$4�$=�$=�=��%�%�'�>r)rRr0r�)r3rLs` rrXzSSLProtocol._resume_readingbs2����#�#�',�D�$� (� �J�J� � ��(�$rc��|j�}||jk\r.|js"d|_|jj �y||j kr/|jr"d|_|jj �yyy)NTF)rprmr�r�rVrlrY)r3rDs rriz SSLProtocol._control_ssl_readingqsu���)�)�+���4�,�,�,�T�5M�5M�'+�D�$��O�O�)�)�+� �T�-�-� -�$�2J�2J�',�D�$��O�O�*�*�,�3K� -rc�\�t||tj�\}}||_||_yr>)r,r� FLOW_CONTROL_HIGH_WATER_SSL_READrmrlr]s rrhz#SSLProtocol._set_read_buffer_limitszs.��,��#�y�A�A�C� ��c�$(��!�#&�� rc�.�|jjSr>)r�rFrDs rrpz!SSLProtocol._get_read_buffer_size�s���~�~�%�%�%rc��d|_y)z\Called when the low-level transport's buffer goes over the high-water mark. TN)r�rDs rrAzSSLProtocol.pause_writing�s�� $(�� rc�2�d|_|j�y)z^Called when the low-level transport's buffer drains below the low-water mark. FN)r�rrDs rrCzSSLProtocol.resume_writing�s�� $)�� ���� rc�f�|jr|jj|�t|t�r5|jj�rt jd||d��yyt|tj�s+|jj|||j|d��yy)Nz%r: %sT)�exc_infor>)r�r�rv�OSErrorr0r�rr�r�CancelledErrorrB)r3r�r?s rr�zSSLProtocol._fatal_error�s����?�?��O�O�(�(��-��c�7�#��z�z�#�#�%����X�t�W�t�D�&��C��!:�!:�;��J�J�-�-�"� �!�_�_� � /� �<r)FNTNNr>r�)zFatal error on transport)/rrrr�r�r�r�r6r?r�r�rGr�r�r�r�r�r8r�r�r�r�r�rJrr�r�rr�r|r�rr�r)r*rr\rer[rUrXrirhrprArCr�rrrr�r�s����H� �� $��#��59�&*�'+�&*� Q"�f 1��#�L� �"2�H%� �!�F�$-�P� ;�.�%�R�*C�� -�8�.�A�0!� $�A�,#�:#�<B��:@�'�(�)�-�'�&� (�!� rr�)r��enumr�r�ImportError�rrrr�logr�SSLWantReadError�SSLSyscallErrorr�Enumr rr$r,�_FlowControlMixin� Transportr.r�r�rrr�<module>r`s��� �����������?��*�*�C�,?�,?�@�N��t�y�y�� &�t�y�y� &� ��*r;�J�8�8�&�0�0�r;�jZ �)�,�,�Z ��{�� �C��s�B0�0B:�9B:__pycache__/sslproto.cpython-312.opt-2.pyc000064400000111753151706172560014326 0ustar00� T��h�|��z�ddlZddlZddlZ ddlZddlmZddlmZddlmZddlm Z ddl mZe�ejejfZGd�d ej�ZGd �dej�Zd�Zd �ZGd�de j(e j*�ZGd�dej.�Zy#e$rdZY��wxYw)�N�)� constants)� exceptions)� protocols)� transports)�loggerc� �eZdZdZdZdZdZdZy)�SSLProtocolState� UNWRAPPED�DO_HANDSHAKE�WRAPPED�FLUSHING�SHUTDOWNN)�__name__� __module__�__qualname__rrr rr���)/usr/lib64/python3.12/asyncio/sslproto.pyr r s���I�!�L��G��H��Hrr c��eZdZdZdZdZdZy)�AppProtocolState� STATE_INIT�STATE_CON_MADE� STATE_EOF�STATE_CON_LOSTN)rrrrrrrrrrrrs���J�%�N��I�%�Nrrc�Z�|rtd��tj�}|sd|_|S)Nz(Server side SSL needs a valid SSLContextF)� ValueError�ssl�create_default_context�check_hostname)�server_side�server_hostname� sslcontexts r�_create_transport_contextr$/s2����C�D�D��+�+�-�J��$)� �!��rc��|�|�|dz}n |}d|z}n|}|�|dz}n|}||cxk\rdk\sntd|�d|�d���||fS)Ni�rzhigh (z) must be >= low (z) must be >= 0)r)�high�low�kb�hi�los r�add_flowcontrol_defaultsr,=sh���|��;��d��B��B��R��B� �� �{� �1�W�� �� ��=�q�=���b�"�#� #��r�6�Mrc���eZdZdZej jZd�Zdd�Z d�Z d�Zd�Zd�Z efd �Zd �Zd�Zd�Zdd �Zd�Zd�Zdd�Zd�Zd�Zed��Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!y)�_SSLProtocolTransportTc�.�||_||_d|_y�NF)�_loop� _ssl_protocol�_closed)�self�loop�ssl_protocols r�__init__z_SSLProtocolTransport.__init__Xs���� �)�����rNc�<� |jj||�S�N)r2�_get_extra_info�r4�name�defaults r�get_extra_infoz$_SSLProtocolTransport.get_extra_info]s��1��!�!�1�1�$��@�@rc�:�|jj|�yr9)r2�_set_app_protocol)r4�protocols r�set_protocolz"_SSLProtocolTransport.set_protocolas�����,�,�X�6rc�.�|jjSr9)r2� _app_protocol�r4s r�get_protocolz"_SSLProtocolTransport.get_protocolds���!�!�/�/�/rc�R�|jxs|jj�Sr9)r3r2�_is_transport_closingrEs r� is_closingz _SSLProtocolTransport.is_closinggs ���|�|�I�t�1�1�G�G�I�Irc�p� |js"d|_|jj�yd|_y�NT)r3r2�_start_shutdownrEs r�closez_SSLProtocolTransport.closejs1�� ��|�|��D�L����.�.�0�!%�D�rc�X�|jsd|_|jdt�yy)NTz9unclosed transport <asyncio._SSLProtocolTransport object>)r3�warn�ResourceWarning)r4� _warningss r�__del__z_SSLProtocolTransport.__del__xs)���|�|��D�L��N�N��*� ,�rc�0�|jjSr9)r2�_app_reading_pausedrEs r� is_readingz _SSLProtocolTransport.is_readings���%�%�9�9�9�9rc�:� |jj�yr9)r2�_pause_readingrEs r� pause_readingz#_SSLProtocolTransport.pause_reading�s�� � ���)�)�+rc�:� |jj�yr9)r2�_resume_readingrEs r�resume_readingz$_SSLProtocolTransport.resume_reading�s�� � ���*�*�,rc�r� |jj||�|jj�yr9)r2�_set_write_buffer_limits�_control_app_writing�r4r'r(s r�set_write_buffer_limitsz-_SSLProtocolTransport.set_write_buffer_limits�s1�� �$ ���3�3�D�#�>����/�/�1rc�Z�|jj|jjfSr9)r2�_outgoing_low_water�_outgoing_high_waterrEs r�get_write_buffer_limitsz-_SSLProtocolTransport.get_write_buffer_limits��*���"�"�6�6��"�"�7�7�9� 9rc�8� |jj�Sr9)r2�_get_write_buffer_sizerEs r�get_write_buffer_sizez+_SSLProtocolTransport.get_write_buffer_size�s��;��!�!�8�8�:�:rc�r� |jj||�|jj�yr9)r2�_set_read_buffer_limits�_control_ssl_readingr_s r�set_read_buffer_limitsz,_SSLProtocolTransport.set_read_buffer_limits�s1�� �$ ���2�2�4��=����/�/�1rc�Z�|jj|jjfSr9)r2�_incoming_low_water�_incoming_high_waterrEs r�get_read_buffer_limitsz,_SSLProtocolTransport.get_read_buffer_limits�rerc�8� |jj�Sr9)r2�_get_read_buffer_sizerEs r�get_read_buffer_sizez*_SSLProtocolTransport.get_read_buffer_size�s��9��!�!�7�7�9�9rc�.�|jjSr9)r2�_app_writing_pausedrEs r�_protocol_pausedz&_SSLProtocolTransport._protocol_paused�s���!�!�5�5�5rc�� t|tttf�s!t dt|�j����|sy|jj|f�y)Nz+data: expecting a bytes-like instance, got ) � isinstance�bytes� bytearray� memoryview� TypeError�typerr2�_write_appdata�r4�datas r�writez_SSLProtocolTransport.write�s]�� � �$�� �:� >�?��#�#'��:�#6�#6�"7�9�:� :������)�)�4�'�2rc�<� |jj|�yr9)r2r~)r4�list_of_datas r� writelinesz _SSLProtocolTransport.writelines�s�� � ���)�)�,�7rc�� t�r9)�NotImplementedErrorrEs r� write_eofz_SSLProtocolTransport.write_eof�s�� �"�!rc�� yr0rrEs r� can_write_eofz#_SSLProtocolTransport.can_write_eof�s��O�rc�(� |jd�yr9)�_force_closerEs r�abortz_SSLProtocolTransport.abort�s�� � ���$�rc�b�d|_|j�|jj|�yyrK)r3r2�_abort�r4�excs rr�z"_SSLProtocolTransport._force_close�s.��������)����%�%�c�*�*rc��|jjj|�|jxjt |�z c_yr9)r2�_write_backlog�append�_write_buffer_size�lenrs r�_test__append_write_backlogz1_SSLProtocolTransport._test__append_write_backlogs7�����)�)�0�0��6����-�-��T��:�-rr9�NN)"rrr�_start_tls_compatibler� _SendfileMode�FALLBACK�_sendfile_compatibler7r>rBrFrIrM�warningsrRrUrXr[r`rdrhrlrprs�propertyrvr�r�r�r�r�r�r�rrrr.r.Rs���!��$�2�2�;�;��� A�7�0�J�&�!)�,�:�,�-�2�,9�;�2�,9�:��6��6�3�8�"�� �+� ;rr.c� �eZdZdZdZdZdZ d+d�Zd�Zd,d�Z d�Z d�Zd�Zd �Z d �Zd�Zd�Zd,d �Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d �Z$d!�Z%d-d"�Z&d#�Z'd$�Z(d%�Z)d-d&�Z*d'�Z+d(�Z,d)�Z-d.d*�Z.y)/�SSLProtocoliNc ���t�td��t|j�|_t|j�|_|�tj}n|dkrtd|����| �tj} n| dkrtd| ����|st||�}||_|r |s||_ nd|_ ||_t|��|_t#j$�|_d|_||_||_|j/|�d|_d|_d|_||_| |_tj:�|_tj:�|_t@jB|_"d|_#|rtHjJ|_&ntHjN|_&|jjQ|j<|j>|j|j��|_)d|_*d|_+d|_,d|_-d|_.|j_�d|_0d|_1d|_2d|_3|ji�|jk�y)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got z6ssl_shutdown_timeout should be a positive number, got )r#F)r!r")6r�RuntimeErrorrz�max_size�_ssl_bufferr{�_ssl_buffer_viewr�SSL_HANDSHAKE_TIMEOUTr�SSL_SHUTDOWN_TIMEOUTr$�_server_side�_server_hostname�_sslcontext�dict�_extra�collections�dequer�r��_waiterr1r@�_app_transport�_app_transport_created� _transport�_ssl_handshake_timeout�_ssl_shutdown_timeout� MemoryBIO� _incoming� _outgoingr r�_state� _conn_lostrr� _app_stater�wrap_bio�_sslobj�_ssl_writing_pausedrT�_ssl_reading_pausedrornrj� _eof_receivedrurcrbr]�_get_app_transport) r4r5�app_protocolr#�waiterr!r"�call_connection_made�ssl_handshake_timeout�ssl_shutdown_timeouts rr7zSSLProtocol.__init__sE�� �;��@�A�A�$�T�]�]�3��� *�4�+;�+;� <��� �(�$-�$C�$C�!� "�a� '���,�-�/�0� 0� �'�#,�#A�#A� � !�Q� &���+�,�.�/� /��2��_�.�J�(����;�$3�D�!�$(�D�!�%����j�1���*�/�/�1���"#�������� ����|�,�"���&+��#����&;��#�%9��"�������������&�0�0�������.�9�9�D�O�.�=�=�D�O��'�'�0�0��N�N�D�N�N��)�)� �1�1�1�3���$)�� �#(�� �#(�� �$%��!�#$�� ��$�$�&�"���#(�� �$%��!�#$�� ��%�%�'����!rc��||_t|d�rDt|tj�r*|j |_|j|_d|_ yd|_ y)N� get_bufferTF) rD�hasattrrxr�BufferedProtocolr��_app_protocol_get_buffer�buffer_updated�_app_protocol_buffer_updated�_app_protocol_is_buffer)r4r�s rr@zSSLProtocol._set_app_protocolasP��)����L�,�/��<��)C�)C�D�,8�,C�,C�D�)�0<�0K�0K�D�-�+/�D�(�+0�D�(rc���|j�y|jj�s@|�#|jj|�d|_y|jjd�d|_yr9)r�� cancelled� set_exception� set_resultr�s r�_wakeup_waiterzSSLProtocol._wakeup_waiterlsZ���<�<����|�|�%�%�'������*�*�3�/�������'�'��-���rc��|j�9|jrtd��t|j|�|_d|_|jS)Nz$Creating _SSLProtocolTransport twiceT)r�r�r�r.r1rEs rr�zSSLProtocol._get_app_transportvsJ�����&��*�*�"�#I�J�J�"7�� � �D�"I�D��*.�D�'��"�"�"rc�V�|jduxr|jj�Sr9)r�rIrEs rrHz!SSLProtocol._is_transport_closing~s#�����d�*�K�t���/I�/I�/K�Krc�4� ||_|j�yr9)r��_start_handshake)r4� transports r�connection_madezSSLProtocol.connection_made�s�� �$������rc�J� |jj�|jj�|xjdz c_|j �d|j _|jtjk7r|jtjk(s|jtjk(rEtj|_ |jj!|j"j$|�|j'tj(�d|_d|_d|_|j-|�|j.r!|j.j1�d|_|j2r"|j2j1�d|_yy)NrT)r��clearr��readr�r�r3r�r rr�rrrrr1� call_soonrD�connection_lost� _set_staterr�r��_shutdown_timeout_handle�cancel�_handshake_timeout_handler�s rr�zSSLProtocol.connection_lost�s>�� � ���!�!�#����������1������*�*.�D���'��;�;�*�7�7�7����#3�#B�#B�B����#3�#=�#=�=�"2�"A�"A���� � �$�$�T�%7�%7�%G�%G��M����(�2�2�3����"���!������C� ��(�(��)�)�0�0�2�,0�D�)��)�)��*�*�1�1�3�-1�D�*�*rc���|}|dks||jkDr|j}t|j�|kr*t|�|_t |j�|_|j S�Nr)r�r�r�rzr{r�)r4�n�wants rr�zSSLProtocol.get_buffer�s`�����1�9��t�}�}�,��=�=�D��t��� �4�'�(���D��$.�t�/?�/?�$@�D�!��$�$�$rc���|jj|jd|�|jtj k(r|j �y|jtjk(r|j�y|jtjk(r|j�y|jtjk(r|j�yyr9) r�r�r�r�r r� _do_handshaker �_do_readr� _do_flushr�_do_shutdown)r4�nbytess rr�zSSLProtocol.buffer_updated�s��������T�2�2�7�F�;�<��;�;�*�7�7�7���� � �[�[�,�4�4� 4��M�M�O� �[�[�,�5�5� 5��N�N�� �[�[�,�5�5� 5�����6rc�� d|_ |jj�rtjd|�|j tjk(r|jt�y|j tjk(r=|jtj�|jry|j�y|j tjk(r@|j�|jtj �|j#�y|j tj k(r|j#�yy#t$$r|j&j)��wxYw)NTz%r received EOF)r�r1� get_debugr�debugr�r r�_on_handshake_complete�ConnectionResetErrorr r�rrTr�� _do_writerr�� Exceptionr�rMrEs r�eof_receivedzSSLProtocol.eof_received�s�� �"��� ��z�z�#�#�%����.��5��{�{�.�;�;�;��+�+�,@�A���� 0� 8� 8�8���� 0� 9� 9�:��+�+���N�N�$���� 0� 9� 9�9���� ���� 0� 9� 9�:��!�!�#���� 0� 9� 9�9��!�!�#�:��� ��O�O�!�!�#�� �s&�A"E�-AE�6E�AE�$-E�%E8c��||jvr|j|S|j�|jj||�S|Sr9)r�r�r>r;s rr:zSSLProtocol._get_extra_info�sC���4�;�;���;�;�t�$�$� �_�_� (��?�?�1�1�$��@�@��Nrc�&�d}|tjk(rd}n�|jtjk(r|tjk(rd}n�|jtjk(r|tjk(rd}ne|jtjk(r|tj k(rd}n2|jtj k(r|tjk(rd}|r||_ytdj|j|���)NFTz!cannot switch state from {} to {}) r rr�rr rrr��format)r4� new_state�alloweds rr�zSSLProtocol._set_state�s������(�2�2�2��G� �K�K�+�5�5�5��)�6�6�6��G� �K�K�+�8�8�8��)�1�1�1��G� �K�K�+�3�3�3��)�2�2�2��G� �K�K�+�4�4�4��)�2�2�2��G��#�D�K��3�:�:��K�K��,�-� -rc�n���jj�r6tjd���jj ��_nd�_�j tj��jj�j�fd���_�j�y)Nz%r starts SSL handshakec�$���j�Sr9)�_check_handshake_timeoutrEs�r�<lambda>z.SSLProtocol._start_handshake.<locals>.<lambda>$s���$�*G�*G�*Ir) r1r�rr��time�_handshake_start_timer�r r� call_laterr�r�r�rEs`rr�zSSLProtocol._start_handshakes�����:�:���!��L�L�2�D�9�)-�����):�D�&�)-�D�&����(�5�5�6� �J�J�!�!�$�"=�"=�"I� K� �&� ���rc��|jtjk(r+d|j�d�}|j t|��yy)Nz$SSL handshake is taking longer than z! seconds: aborting the connection)r�r rr��_fatal_error�ConnectionAbortedError)r4�msgs rr�z$SSLProtocol._check_handshake_timeout(sN���;�;�*�7�7�7�6��.�.�/�0*�+� � ���4�S�9�:� 8rc��� |jj�|jd�y#t$r|j �Yyt j$r}|j|�Yd}~yd}~wwxYwr9)r��do_handshaker��SSLAgainErrors�_process_outgoingr�SSLErrorr�s rr�zSSLProtocol._do_handshake1sb�� .��L�L�%�%�'� �'�'��-��� %��"�"�$��|�|� -��'�'��,�,�� -�s�.�A6� A6�A1�1A6c���|j�!|jj�d|_|j} |� |jtj �n|�|j �}|jj�rA|jj!�|j"z }t%j&d||dz�|j(j+||j-�|j/�|��|j0t2j4k(r>t2j6|_|j8j;|j=��|j�|j?�y#t$rm}d}|jtj�t|tj�rd}nd}|j||�|j|�Yd}~yd}~wwxYw)Nz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@�@)�peercert�cipher�compression� ssl_object) r�r�r�r�r r �getpeercertr�rrxr�CertificateErrorrr�r1r�r�r�rr�r��updater rr�rrrrDr�r�r�)r4� handshake_exc�sslobjr r�r�dts rr�z"SSLProtocol._on_handshake_complete;s����)�)�5��*�*�1�1�3�-1�D�*����� ��$���� 0� 8� 8�9�#�#��)�)�+�H��:�:���!������"�T�%?�%?�?�B��L�L�9�4��c��J� �����H�"(�-�-�/�'-�'9�'9�';�&,� � .��?�?�.�9�9�9�.�=�=�D�O����.�.�t�/F�/F�/H�I������ � ���1� � �M��O�O�,�6�6�7��#�s�3�3�4�I��,�����c�3�'�����$��� �s�4F� G7� A#G2�2G7c�����jtjtjtjfvry�j �d�j _�jtjk(r�jd�y�jtj��jj�j�fd���_ �j�y)NTc�$���j�Sr9)�_check_shutdown_timeoutrEs�rr�z-SSLProtocol._start_shutdown.<locals>.<lambda>us����4�4�6r)r�r rrrr�r3rr�r�r1r�r�r�r�rEs`rrLzSSLProtocol._start_shutdownds�����K�K� �)�)� �)�)� �*�*�� � ����*�*.�D���'��;�;�*�7�7�7��K�K����O�O�,�5�5�6�,0�J�J�,A�,A��*�*�6�-�D�)� �N�N�rc��|jtjtjfvr/|jjt jd��yy)NzSSL shutdown timed out)r�r rrr�r�r�TimeoutErrorrEs rrz#SSLProtocol._check_shutdown_timeoutysN���K�K� �)�)� �)�)�� � �O�O�(�(��'�'�(@�A� C� rc��|j�|jtj�|j �yr9)r�r�r rr�rEs rr�zSSLProtocol._do_flush�s*��� � �����(�1�1�2����rc�J� |js|jj�|j�|j �|jd�y#t$r|j�Yytj$r}|j|�Yd}~yd}~wwxYwr9) r�r��unwrapr�_call_eof_received�_on_shutdown_completerrrr�s rr�zSSLProtocol._do_shutdown�s��� -��%�%����#�#�%� �"�"�$��#�#�%��&�&�t�,��� %��"�"�$��|�|� ,��&�&�s�+�+�� ,�s�&A�B"�5B"�B�B"c���|j�!|jj�d|_|r|j|�y|jj |j j�yr9)r�r�rr1r�r�rM)r4�shutdown_excs rrz!SSLProtocol._on_shutdown_complete�sU���(�(�4��)�)�0�0�2�,0�D�)�����l�+��J�J� � ����!6�!6�7rc��|jtj�|j�|jj |�yyr9)r�r rr�r�r�s rr�zSSLProtocol._abort�s6�����(�2�2�3��?�?�&��O�O�(�(��-�'rc�8�|jtjtjtjfvrH|j tjk\rtjd�|xj dz c_y|D];}|jj|�|xjt|�z c_�= |jtjk(r|j�yy#t $r}|j#|d�Yd}~yd}~wwxYw)NzSSL connection is closedr�Fatal error on SSL protocol)r�r rrrr�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr�warningr�r�r�r�r r�r�r)r4r�r��exs rr~zSSLProtocol._write_appdata�s����K�K� �)�)� �)�)� �*�*�� ����)�"M�"M�M����9�:��O�O�q� �O�� �D����&�&�t�,��#�#�s�4�y�0�#�!� A��{�{�.�6�6�6���� �7��� A����b�"?�@�@�� A�s�-C4�4 D�=D�Dc�~� |jr�|jd}|jj|�}t|�}||kr(||d|jd<|xj|zc_n"|jd=|xj|zc_|jr��|j �y#t $rY�wxYwr�)r�r�r�r�r�rr)r4r��count�data_lens rr�zSSLProtocol._do_write�s��� ��%�%��*�*�1�-�����*�*�4�0���t�9���8�#�-1�%�&�\�D�'�'��*��+�+�u�4�+��+�+�A�.��+�+�x�7�+��%�%� ��� ��� �� �s�BB0�0 B<�;B<c��|js@|jj�}t|�r|jj|�|j �yr9)r�r�r�r�r�r�r^rs rrzSSLProtocol._process_outgoing�sB���'�'��>�>�&�&�(�D��4�y����%�%�d�+��!�!�#rc��|jtjtjfvry |jsZ|j r|j �n|j�|jr|j�n|j�|j�y#t$r}|j|d�Yd}~yd}~wwxYw)Nr!)r�r r rrTr��_do_read__buffered�_do_read__copiedr�r�rrkr�r)r4r$s rr�zSSLProtocol._do_read�s����K�K� �(�(� �)�)� � � � A��+�+��/�/��+�+�-��)�)�+��&�&��N�N�$��*�*�,��%�%�'��� A����b�"?�@�@�� A�s�A6B&�& C�/C�Cc����d}d}�j�j��}t|�} �jj ||�}|dkDrY|}||kr4�jj ||z ||d�}|dkDr||z }nn$||kr�4�j j �fd��|dkDr�j|�|s!�j��j�yy#t$rY�EwxYw)Nrrc�$���j�Sr9)r�rEs�rr�z0SSLProtocol._do_read__buffered.<locals>.<lambda>s������r)r�rrr�r�r�r1r�rr�rrL)r4�offsetr&�buf�wantss` rr*zSSLProtocol._do_read__buffered�s���������+�+�D�,F�,F�,H�I���C��� ��L�L�%�%�e�S�1�E��q�y����u�n� �L�L�-�-�e�f�n�c�&�'�l�K�E��q�y��%�����u�n��J�J�(�(�)@�A��A�:��-�-�f�5���#�#�%�� � �"��� � �� �s�AC%� C%�% C1�0C1c��d}d}d} |jj|j�}|sn$|rd}d}|}n|rd}|g}nj|��L |r|j j �n,|s*|j j dj��|s!|j�|j�yy#t$rY�ywxYw)N�1TFr) r�r�r�r�rrD� data_received�joinrrL)r4�chunk�zero�one�firstr�s rr+zSSLProtocol._do_read__copied s��������� �����)�)�$�-�-�8����� �D��C�!�E���C�!�5�>�D��K�K��&�������,�,�U�3�����,�,�S�X�X�d�^�<���#�#�%�� � �"��� � �� �s�A C� C�Cc�>� |jtjk(rHtj|_|jj�}|rt jd�yyy#ttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nz?returning true from eof_received() has no effect when using sslzError calling eof_received())r�rrrrDr�rr#�KeyboardInterrupt� SystemExit� BaseExceptionr)r4� keep_openr$s rrzSSLProtocol._call_eof_received(s��� B����"2�"A�"A�A�"2�"<�"<��� �.�.�;�;�=� ���N�N�$B�C��B��"�:�.� ��� B����b�"@�A�A�� B�s�A#A(�(B�B�Bc�Z�|j�}||jk\r/|js#d|_ |jj �y||jkr0|jr#d|_ |jj�yyy#t tf$r�t$r4}|jjd||j|d��Yd}~yd}~wwxYw#t tf$r�t$r4}|jjd||j|d��Yd}~yd}~wwxYw)NTzprotocol.pause_writing() failed��message� exceptionr�rAFz protocol.resume_writing() failed) rgrcrurD� pause_writingr:r;r<r1�call_exception_handlerr�rb�resume_writing)r4�sizer�s rr^z SSLProtocol._control_app_writing7s$���*�*�,���4�,�,�,�T�5M�5M�'+�D�$� ��"�"�0�0�2��T�-�-� -�$�2J�2J�',�D�$� ��"�"�1�1�3�3K� -��&�z�2� �� � �� � �1�1�@�!$�!%�!4�!4� $� 3���� ��&�z�2� �� � �� � �1�1�A�!$�!%�!4�!4� $� 3���� �s/�B�2C�C�'*C�C�D*�6*D%�%D*c�H�|jj|jzSr9)r��pendingr�rEs rrgz"SSLProtocol._get_write_buffer_sizeTs���~�~�%�%��(?�(?�?�?rc�\�t||tj�\}}||_||_yr9)r,r�!FLOW_CONTROL_HIGH_WATER_SSL_WRITErcrbr_s rr]z$SSLProtocol._set_write_buffer_limitsWs.��,��#�y�B�B�D� ��c�$(��!�#&�� rc��d|_yrK)rTrEs rrWzSSLProtocol._pause_reading_s ��#'�� rc�n���jr(d�_�fd�}�jj|�yy)NFc����jtjk(r�j�y�jtjk(r�j�y�jtjk(r�j�yyr9)r�r r r�rr�rr�rEs�r�resumez+SSLProtocol._resume_reading.<locals>.resumefs`����;�;�"2�":�":�:��M�M�O��[�[�$4�$=�$=�=��N�N�$��[�[�$4�$=�$=�=��%�%�'�>r)rTr1r�)r4rMs` rrZzSSLProtocol._resume_readingbs2����#�#�',�D�$� (� �J�J� � ��(�$rc��|j�}||jk\r.|js"d|_|jj �y||j kr/|jr"d|_|jj �yyy)NTF)rrror�r�rXrnr[)r4rEs rrkz SSLProtocol._control_ssl_readingqsu���)�)�+���4�,�,�,�T�5M�5M�'+�D�$��O�O�)�)�+� �T�-�-� -�$�2J�2J�',�D�$��O�O�*�*�,�3K� -rc�\�t||tj�\}}||_||_yr9)r,r� FLOW_CONTROL_HIGH_WATER_SSL_READrornr_s rrjz#SSLProtocol._set_read_buffer_limitszs.��,��#�y�A�A�C� ��c�$(��!�#&�� rc�.�|jjSr9)r�rGrEs rrrz!SSLProtocol._get_read_buffer_size�s���~�~�%�%�%rc�� d|_yrK)r�rEs rrBzSSLProtocol.pause_writing�s�� �$(�� rc�4� d|_|j�yr0)r�rrEs rrDzSSLProtocol.resume_writing�s�� �$)�� ���� rc�f�|jr|jj|�t|t�r5|jj�rt jd||d��yyt|tj�s+|jj|||j|d��yy)Nz%r: %sT)�exc_infor?)r�r�rx�OSErrorr1r�rr�r�CancelledErrorrC)r4r�r@s rrzSSLProtocol._fatal_error�s����?�?��O�O�(�(��-��c�7�#��z�z�#�#�%����X�t�W�t�D�&��C��!:�!:�;��J�J�-�-�"� �!�_�_� � /� �<r)FNTNNr9r�)zFatal error on transport)/rrrr�r�r�r�r7r@r�r�rHr�r�r�r�r�r:r�r�r�r�r�rLrr�r�rr�r~r�rr�r*r+rr^rgr]rWrZrkrjrrrBrDrrrrr�r�s����H� �� $��#��59�&*�'+�&*� Q"�f 1��#�L� �"2�H%� �!�F�$-�P� ;�.�%�R�*C�� -�8�.�A�0!� $�A�,#�:#�<B��:@�'�(�)�-�'�&� (�!� rr�)r��enumr�r�ImportError�rrrr�logr�SSLWantReadError�SSLSyscallErrorr�Enumr rr$r,�_FlowControlMixin� Transportr.r�r�rrr�<module>ras��� �����������?��*�*�C�,?�,?�@�N��t�y�y�� &�t�y�y� &� ��*r;�J�8�8�&�0�0�r;�jZ �)�,�,�Z ��{�� �C��s�B0�0B:�9B:__pycache__/sslproto.cpython-312.pyc000064400000121646151706172560013370 0ustar00� T��h�|��z�ddlZddlZddlZ ddlZddlmZddlmZddlmZddlm Z ddl mZe�ejejfZGd�d ej�ZGd �dej�Zd�Zd �ZGd�de j(e j*�ZGd�dej.�Zy#e$rdZY��wxYw)�N�)� constants)� exceptions)� protocols)� transports)�loggerc� �eZdZdZdZdZdZdZy)�SSLProtocolState� UNWRAPPED�DO_HANDSHAKE�WRAPPED�FLUSHING�SHUTDOWNN)�__name__� __module__�__qualname__rrr rr���)/usr/lib64/python3.12/asyncio/sslproto.pyr r s���I�!�L��G��H��Hrr c��eZdZdZdZdZdZy)�AppProtocolState� STATE_INIT�STATE_CON_MADE� STATE_EOF�STATE_CON_LOSTN)rrrrrrrrrrrrs���J�%�N��I�%�Nrrc�Z�|rtd��tj�}|sd|_|S)Nz(Server side SSL needs a valid SSLContextF)� ValueError�ssl�create_default_context�check_hostname)�server_side�server_hostname� sslcontexts r�_create_transport_contextr$/s2����C�D�D��+�+�-�J��$)� �!��rc��|�|�|dz}n |}d|z}n|}|�|dz}n|}||cxk\rdk\sntd|�d|�d���||fS)Ni�rzhigh (z) must be >= low (z) must be >= 0)r)�high�low�kb�hi�los r�add_flowcontrol_defaultsr,=sh���|��;��d��B��B��R��B� �� �{� �1�W�� �� ��=�q�=���b�"�#� #��r�6�Mrc���eZdZdZej jZd�Zdd�Z d�Z d�Zd�Zd�Z efd �Zd �Zd�Zd�Zdd �Zd�Zd�Zdd�Zd�Zd�Zed��Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!y)�_SSLProtocolTransportTc�.�||_||_d|_y)NF)�_loop� _ssl_protocol�_closed)�self�loop�ssl_protocols r�__init__z_SSLProtocolTransport.__init__Xs���� �)�����rNc�:�|jj||�S)z#Get optional transport information.)r1�_get_extra_info�r3�name�defaults r�get_extra_infoz$_SSLProtocolTransport.get_extra_info]s���!�!�1�1�$��@�@rc�:�|jj|�y�N)r1�_set_app_protocol)r3�protocols r�set_protocolz"_SSLProtocolTransport.set_protocolas�����,�,�X�6rc�.�|jjSr>)r1� _app_protocol�r3s r�get_protocolz"_SSLProtocolTransport.get_protocolds���!�!�/�/�/rc�R�|jxs|jj�Sr>)r2r1�_is_transport_closingrDs r� is_closingz _SSLProtocolTransport.is_closinggs ���|�|�I�t�1�1�G�G�I�Irc�n�|js"d|_|jj�yd|_y)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. TN)r2r1�_start_shutdownrDs r�closez_SSLProtocolTransport.closejs,���|�|��D�L����.�.�0�!%�D�rc�X�|jsd|_|jdt�yy)NTz9unclosed transport <asyncio._SSLProtocolTransport object>)r2�warn�ResourceWarning)r3� _warningss r�__del__z_SSLProtocolTransport.__del__xs)���|�|��D�L��N�N��*� ,�rc�0�|jjSr>)r1�_app_reading_pausedrDs r� is_readingz _SSLProtocolTransport.is_readings���%�%�9�9�9�9rc�8�|jj�y)z�Pause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)r1�_pause_readingrDs r� pause_readingz#_SSLProtocolTransport.pause_reading�s�� ���)�)�+rc�8�|jj�y)z�Resume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)r1�_resume_readingrDs r�resume_readingz$_SSLProtocolTransport.resume_reading�s�� ���*�*�,rc�p�|jj||�|jj�y)a�Set the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)r1�_set_write_buffer_limits�_control_app_writing�r3r'r(s r�set_write_buffer_limitsz-_SSLProtocolTransport.set_write_buffer_limits�s,��& ���3�3�D�#�>����/�/�1rc�Z�|jj|jjfSr>)r1�_outgoing_low_water�_outgoing_high_waterrDs r�get_write_buffer_limitsz-_SSLProtocolTransport.get_write_buffer_limits��*���"�"�6�6��"�"�7�7�9� 9rc�6�|jj�S)z-Return the current size of the write buffers.)r1�_get_write_buffer_sizerDs r�get_write_buffer_sizez+_SSLProtocolTransport.get_write_buffer_size�s���!�!�8�8�:�:rc�p�|jj||�|jj�y)a�Set the high- and low-water limits for read flow control. These two values control when to call the upstream transport's pause_reading() and resume_reading() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_reading() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_reading() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)r1�_set_read_buffer_limits�_control_ssl_readingr]s r�set_read_buffer_limitsz,_SSLProtocolTransport.set_read_buffer_limits�s,��& ���2�2�4��=����/�/�1rc�Z�|jj|jjfSr>)r1�_incoming_low_water�_incoming_high_waterrDs r�get_read_buffer_limitsz,_SSLProtocolTransport.get_read_buffer_limits�rcrc�6�|jj�S)z+Return the current size of the read buffer.)r1�_get_read_buffer_sizerDs r�get_read_buffer_sizez*_SSLProtocolTransport.get_read_buffer_size�s���!�!�7�7�9�9rc�.�|jjSr>)r1�_app_writing_pausedrDs r�_protocol_pausedz&_SSLProtocolTransport._protocol_paused�s���!�!�5�5�5rc��t|tttf�s!t dt|�j����|sy|jj|f�y)z�Write some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. z+data: expecting a bytes-like instance, got N) � isinstance�bytes� bytearray� memoryview� TypeError�typerr1�_write_appdata�r3�datas r�writez_SSLProtocolTransport.write�sX���$�� �:� >�?��#�#'��:�#6�#6�"7�9�:� :������)�)�4�'�2rc�:�|jj|�y)z�Write a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. N)r1r|)r3�list_of_datas r� writelinesz _SSLProtocolTransport.writelines�s�� ���)�)�,�7rc��t�)zuClose the write end after flushing buffered data. This raises :exc:`NotImplementedError` right now. )�NotImplementedErrorrDs r� write_eofz_SSLProtocolTransport.write_eof�s �� "�!rc��y)zAReturn True if this transport supports write_eof(), False if not.FrrDs r� can_write_eofz#_SSLProtocolTransport.can_write_eof�s��rc�&�|jd�y)z�Close the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)�_force_closerDs r�abortz_SSLProtocolTransport.abort�s�� ���$�rc�b�d|_|j�|jj|�yy�NT)r2r1�_abort�r3�excs rr�z"_SSLProtocolTransport._force_close�s.��������)����%�%�c�*�*rc��|jjj|�|jxjt |�z c_yr>)r1�_write_backlog�append�_write_buffer_size�lenr}s r�_test__append_write_backlogz1_SSLProtocolTransport._test__append_write_backlogs7�����)�)�0�0��6����-�-��T��:�-rr>�NN)"rrr�_start_tls_compatibler� _SendfileMode�FALLBACK�_sendfile_compatibler6r<rArErHrK�warningsrPrSrVrYr^rbrfrjrnrq�propertyrtrr�r�r�r�r�r�rrrr.r.Rs���!��$�2�2�;�;��� A�7�0�J�&�!)�,�:�,�-�2�,9�;�2�,9�:��6��6�3�8�"�� �+� ;rr.c� �eZdZdZdZdZdZ d+d�Zd�Zd,d�Z d�Z d�Zd�Zd �Z d �Zd�Zd�Zd,d �Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d �Z$d!�Z%d-d"�Z&d#�Z'd$�Z(d%�Z)d-d&�Z*d'�Z+d(�Z,d)�Z-d.d*�Z.y)/�SSLProtocoliNc ���t�td��t|j�|_t|j�|_|�tj}n|dkrtd|����| �tj} n| dkrtd| ����|st||�}||_|r |s||_ nd|_ ||_t|��|_t#j$�|_d|_||_||_|j/|�d|_d|_d|_||_| |_tj:�|_tj:�|_t@jB|_"d|_#|rtHjJ|_&ntHjN|_&|jjQ|j<|j>|j|j��|_)d|_*d|_+d|_,d|_-d|_.|j_�d|_0d|_1d|_2d|_3|ji�|jk�y)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got z6ssl_shutdown_timeout should be a positive number, got )r#F)r!r")6r�RuntimeErrorrx�max_size�_ssl_bufferry�_ssl_buffer_viewr�SSL_HANDSHAKE_TIMEOUTr�SSL_SHUTDOWN_TIMEOUTr$�_server_side�_server_hostname�_sslcontext�dict�_extra�collections�dequer�r��_waiterr0r?�_app_transport�_app_transport_created� _transport�_ssl_handshake_timeout�_ssl_shutdown_timeout� MemoryBIO� _incoming� _outgoingr r�_state� _conn_lostrr� _app_stater�wrap_bio�_sslobj�_ssl_writing_pausedrR�_ssl_reading_pausedrmrlrh� _eof_receivedrsrar`r[�_get_app_transport) r3r4�app_protocolr#�waiterr!r"�call_connection_made�ssl_handshake_timeout�ssl_shutdown_timeouts rr6zSSLProtocol.__init__sE�� �;��@�A�A�$�T�]�]�3��� *�4�+;�+;� <��� �(�$-�$C�$C�!� "�a� '���,�-�/�0� 0� �'�#,�#A�#A� � !�Q� &���+�,�.�/� /��2��_�.�J�(����;�$3�D�!�$(�D�!�%����j�1���*�/�/�1���"#�������� ����|�,�"���&+��#����&;��#�%9��"�������������&�0�0�������.�9�9�D�O�.�=�=�D�O��'�'�0�0��N�N�D�N�N��)�)� �1�1�1�3���$)�� �#(�� �#(�� �$%��!�#$�� ��$�$�&�"���#(�� �$%��!�#$�� ��%�%�'����!rc��||_t|d�rDt|tj�r*|j |_|j|_d|_ yd|_ y)N� get_bufferTF) rC�hasattrrvr�BufferedProtocolr��_app_protocol_get_buffer�buffer_updated�_app_protocol_buffer_updated�_app_protocol_is_buffer)r3r�s rr?zSSLProtocol._set_app_protocolasP��)����L�,�/��<��)C�)C�D�,8�,C�,C�D�)�0<�0K�0K�D�-�+/�D�(�+0�D�(rc���|j�y|jj�s@|�#|jj|�d|_y|jjd�d|_yr>)r�� cancelled� set_exception� set_resultr�s r�_wakeup_waiterzSSLProtocol._wakeup_waiterlsZ���<�<����|�|�%�%�'������*�*�3�/�������'�'��-���rc��|j�9|jrtd��t|j|�|_d|_|jS)Nz$Creating _SSLProtocolTransport twiceT)r�r�r�r.r0rDs rr�zSSLProtocol._get_app_transportvsJ�����&��*�*�"�#I�J�J�"7�� � �D�"I�D��*.�D�'��"�"�"rc�V�|jduxr|jj�Sr>)r�rHrDs rrGz!SSLProtocol._is_transport_closing~s#�����d�*�K�t���/I�/I�/K�Krc�2�||_|j�y)zXCalled when the low-level connection is made. Start the SSL handshake. N)r��_start_handshake)r3� transports r�connection_madezSSLProtocol.connection_made�s�� $������rc�H�|jj�|jj�|xjdz c_|j �d|j _|jtjk7r|jtjk(s|jtjk(rEtj|_ |jj!|j"j$|�|j'tj(�d|_d|_d|_|j-|�|j.r!|j.j1�d|_|j2r"|j2j1�d|_yy)z�Called when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). rNT)r��clearr��readr�r�r2r�r rr�rrrrr0� call_soonrC�connection_lost� _set_staterr�r��_shutdown_timeout_handle�cancel�_handshake_timeout_handler�s rr�zSSLProtocol.connection_lost�s9�� ���!�!�#����������1������*�*.�D���'��;�;�*�7�7�7����#3�#B�#B�B����#3�#=�#=�=�"2�"A�"A���� � �$�$�T�%7�%7�%G�%G��M����(�2�2�3����"���!������C� ��(�(��)�)�0�0�2�,0�D�)��)�)��*�*�1�1�3�-1�D�*�*rc���|}|dks||jkDr|j}t|j�|kr*t|�|_t |j�|_|j S�Nr)r�r�r�rxryr�)r3�n�wants rr�zSSLProtocol.get_buffer�s`�����1�9��t�}�}�,��=�=�D��t��� �4�'�(���D��$.�t�/?�/?�$@�D�!��$�$�$rc���|jj|jd|�|jtj k(r|j �y|jtjk(r|j�y|jtjk(r|j�y|jtjk(r|j�yyr>) r�rr�r�r r� _do_handshaker �_do_readr� _do_flushr�_do_shutdown)r3�nbytess rr�zSSLProtocol.buffer_updated�s��������T�2�2�7�F�;�<��;�;�*�7�7�7���� � �[�[�,�4�4� 4��M�M�O� �[�[�,�5�5� 5��N�N�� �[�[�,�5�5� 5�����6rc���d|_ |jj�rtjd|�|j tjk(r|jt�y|j tjk(r=|jtj�|jry|j�y|j tjk(r@|j�|jtj �|j#�y|j tj k(r|j#�yy#t$$r|j&j)��wxYw)aCalled when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Tz%r received EOFN)r�r0� get_debugr�debugr�r r�_on_handshake_complete�ConnectionResetErrorr r�rrRr�� _do_writerr�� Exceptionr�rKrDs r�eof_receivedzSSLProtocol.eof_received�s��"��� ��z�z�#�#�%����.��5��{�{�.�;�;�;��+�+�,@�A���� 0� 8� 8�8���� 0� 9� 9�:��+�+���N�N�$���� 0� 9� 9�9���� ���� 0� 9� 9�:��!�!�#���� 0� 9� 9�9��!�!�#�:��� ��O�O�!�!�#�� �s&�A"E�,AE�5E�AE�#-E�%E7c��||jvr|j|S|j�|jj||�S|Sr>)r�r�r<r9s rr8zSSLProtocol._get_extra_info�sC���4�;�;���;�;�t�$�$� �_�_� (��?�?�1�1�$��@�@��Nrc�&�d}|tjk(rd}n�|jtjk(r|tjk(rd}n�|jtjk(r|tjk(rd}ne|jtjk(r|tj k(rd}n2|jtj k(r|tjk(rd}|r||_ytdj|j|���)NFTz!cannot switch state from {} to {}) r rr�rr rrr��format)r3� new_state�alloweds rr�zSSLProtocol._set_state�s������(�2�2�2��G� �K�K�+�5�5�5��)�6�6�6��G� �K�K�+�8�8�8��)�1�1�1��G� �K�K�+�3�3�3��)�2�2�2��G� �K�K�+�4�4�4��)�2�2�2��G��#�D�K��3�:�:��K�K��,�-� -rc�n���jj�r6tjd���jj ��_nd�_�j tj��jj�j�fd���_�j�y)Nz%r starts SSL handshakec�$���j�Sr>)�_check_handshake_timeoutrDs�r�<lambda>z.SSLProtocol._start_handshake.<locals>.<lambda>$s���$�*G�*G�*Ir) r0r�rr��time�_handshake_start_timer�r r� call_laterr�r�r�rDs`rr�zSSLProtocol._start_handshakes�����:�:���!��L�L�2�D�9�)-�����):�D�&�)-�D�&����(�5�5�6� �J�J�!�!�$�"=�"=�"I� K� �&� ���rc��|jtjk(r+d|j�d�}|j t|��yy)Nz$SSL handshake is taking longer than z! seconds: aborting the connection)r�r rr��_fatal_error�ConnectionAbortedError)r3�msgs rr�z$SSLProtocol._check_handshake_timeout(sN���;�;�*�7�7�7�6��.�.�/�0*�+� � ���4�S�9�:� 8rc��� |jj�|jd�y#t$r|j �Yyt j$r}|j|�Yd}~yd}~wwxYwr>)r��do_handshaker��SSLAgainErrors�_process_outgoingr�SSLErrorr�s rr�zSSLProtocol._do_handshake1sb�� .��L�L�%�%�'� �'�'��-��� %��"�"�$��|�|� -��'�'��,�,�� -�s�.�A6� A6�A1�1A6c���|j�!|jj�d|_|j} |� |jtj �n|�|j �}|jj�rA|jj!�|j"z }t%j&d||dz�|j(j+||j-�|j/�|��|j0t2j4k(r>t2j6|_|j8j;|j=��|j�|j?�y#t$rm}d}|jtj�t|tj�rd}nd}|j||�|j|�Yd}~yd}~wwxYw)Nz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@�@)�peercert�cipher�compression� ssl_object) r�r�r�r�r r �getpeercertr�rrvr�CertificateErrorr�r�r0r�r�r�rr�r��updater r r�rrrrCr�r�r�)r3� handshake_exc�sslobjrr�r�dts rr�z"SSLProtocol._on_handshake_complete;s����)�)�5��*�*�1�1�3�-1�D�*����� ��$���� 0� 8� 8�9�#�#��)�)�+�H��:�:���!������"�T�%?�%?�?�B��L�L�9�4��c��J� �����H�"(�-�-�/�'-�'9�'9�';�&,� � .��?�?�.�9�9�9�.�=�=�D�O����.�.�t�/F�/F�/H�I������ � ���1� � �M��O�O�,�6�6�7��#�s�3�3�4�I��,�����c�3�'�����$��� �s�4F� G7� A#G2�2G7c�����jtjtjtjfvry�j �d�j _�jtjk(r�jd�y�jtj��jj�j�fd���_ �j�y)NTc�$���j�Sr>)�_check_shutdown_timeoutrDs�rr�z-SSLProtocol._start_shutdown.<locals>.<lambda>us����4�4�6r)r�r rrrr�r2rr�r�r0r�r�r�r�rDs`rrJzSSLProtocol._start_shutdownds�����K�K� �)�)� �)�)� �*�*�� � ����*�*.�D���'��;�;�*�7�7�7��K�K����O�O�,�5�5�6�,0�J�J�,A�,A��*�*�6�-�D�)� �N�N�rc��|jtjtjfvr/|jjt jd��yy)NzSSL shutdown timed out)r�r rrr�r�r�TimeoutErrorrDs rrz#SSLProtocol._check_shutdown_timeoutysN���K�K� �)�)� �)�)�� � �O�O�(�(��'�'�(@�A� C� rc��|j�|jtj�|j �yr>)r�r�r rr�rDs rr�zSSLProtocol._do_flush�s*��� � �����(�1�1�2����rc�J� |js|jj�|j�|j �|jd�y#t$r|j�Yytj$r}|j|�Yd}~yd}~wwxYwr>) r�r��unwrapr�_call_eof_received�_on_shutdown_completerrrr�s rr�zSSLProtocol._do_shutdown�s��� -��%�%����#�#�%� �"�"�$��#�#�%��&�&�t�,��� %��"�"�$��|�|� ,��&�&�s�+�+�� ,�s�&A�B"�5B"�B�B"c���|j�!|jj�d|_|r|j|�y|jj |j j�yr>)r�r�r�r0r�r�rK)r3�shutdown_excs rrz!SSLProtocol._on_shutdown_complete�sU���(�(�4��)�)�0�0�2�,0�D�)�����l�+��J�J� � ����!6�!6�7rc��|jtj�|j�|jj |�yyr>)r�r rr�r�r�s rr�zSSLProtocol._abort�s6�����(�2�2�3��?�?�&��O�O�(�(��-�'rc�8�|jtjtjtjfvrH|j tjk\rtjd�|xj dz c_y|D];}|jj|�|xjt|�z c_�= |jtjk(r|j�yy#t $r}|j#|d�Yd}~yd}~wwxYw)NzSSL connection is closedr�Fatal error on SSL protocol)r�r rrrr�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr�warningr�r�r�r�r r�r�r�)r3r�r~�exs rr|zSSLProtocol._write_appdata�s����K�K� �)�)� �)�)� �*�*�� ����)�"M�"M�M����9�:��O�O�q� �O�� �D����&�&�t�,��#�#�s�4�y�0�#�!� A��{�{�.�6�6�6���� �7��� A����b�"?�@�@�� A�s�-C4�4 D�=D�Dc�~� |jr�|jd}|jj|�}t|�}||kr(||d|jd<|xj|zc_n"|jd=|xj|zc_|jr��|j �y#t $rY�wxYwr�)r�r�rr�r�rr)r3r~�count�data_lens rr�zSSLProtocol._do_write�s��� ��%�%��*�*�1�-�����*�*�4�0���t�9���8�#�-1�%�&�\�D�'�'��*��+�+�u�4�+��+�+�A�.��+�+�x�7�+��%�%� ��� ��� �� �s�BB0�0 B<�;B<c��|js@|jj�}t|�r|jj|�|j �yr>)r�r�r�r�r�rr\r}s rrzSSLProtocol._process_outgoing�sB���'�'��>�>�&�&�(�D��4�y����%�%�d�+��!�!�#rc��|jtjtjfvry |jsZ|j r|j �n|j�|jr|j�n|j�|j�y#t$r}|j|d�Yd}~yd}~wwxYw)Nr )r�r r rrRr��_do_read__buffered�_do_read__copiedr�r�rrir�r�)r3r#s rr�zSSLProtocol._do_read�s����K�K� �(�(� �)�)� � � � A��+�+��/�/��+�+�-��)�)�+��&�&��N�N�$��*�*�,��%�%�'��� A����b�"?�@�@�� A�s�A6B&�& C�/C�Cc����d}d}�j�j��}t|�} �jj ||�}|dkDrY|}||kr4�jj ||z ||d�}|dkDr||z }nn$||kr�4�j j �fd��|dkDr�j|�|s!�j��j�yy#t$rY�EwxYw)Nrrc�$���j�Sr>)r�rDs�rr�z0SSLProtocol._do_read__buffered.<locals>.<lambda>s������r)r�rpr�r�r�r0r�rr�rrJ)r3�offsetr%�buf�wantss` rr)zSSLProtocol._do_read__buffered�s���������+�+�D�,F�,F�,H�I���C��� ��L�L�%�%�e�S�1�E��q�y����u�n� �L�L�-�-�e�f�n�c�&�'�l�K�E��q�y��%�����u�n��J�J�(�(�)@�A��A�:��-�-�f�5���#�#�%�� � �"��� � �� �s�AC%� C%�% C1�0C1c��d}d}d} |jj|j�}|sn$|rd}d}|}n|rd}|g}nj|��L |r|j j �n,|s*|j j dj��|s!|j�|j�yy#t$rY�ywxYw)N�1TFr) r�r�r�r�rrC� data_received�joinrrJ)r3�chunk�zero�one�firstr~s rr*zSSLProtocol._do_read__copied s��������� �����)�)�$�-�-�8����� �D��C�!�E���C�!�5�>�D��K�K��&�������,�,�U�3�����,�,�S�X�X�d�^�<���#�#�%�� � �"��� � �� �s�A C� C�Cc�>� |jtjk(rHtj|_|jj�}|rt jd�yyy#ttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nz?returning true from eof_received() has no effect when using sslzError calling eof_received())r�rrrrCr�rr"�KeyboardInterrupt� SystemExit� BaseExceptionr�)r3� keep_openr#s rrzSSLProtocol._call_eof_received(s��� B����"2�"A�"A�A�"2�"<�"<��� �.�.�;�;�=� ���N�N�$B�C��B��"�:�.� ��� B����b�"@�A�A�� B�s�A#A(�(B�B�Bc�Z�|j�}||jk\r/|js#d|_ |jj �y||jkr0|jr#d|_ |jj�yyy#t tf$r�t$r4}|jjd||j|d��Yd}~yd}~wwxYw#t tf$r�t$r4}|jjd||j|d��Yd}~yd}~wwxYw)NTzprotocol.pause_writing() failed��message� exceptionr�r@Fz protocol.resume_writing() failed) rerarsrC� pause_writingr9r:r;r0�call_exception_handlerr�r`�resume_writing)r3�sizer�s rr\z SSLProtocol._control_app_writing7s$���*�*�,���4�,�,�,�T�5M�5M�'+�D�$� ��"�"�0�0�2��T�-�-� -�$�2J�2J�',�D�$� ��"�"�1�1�3�3K� -��&�z�2� �� � �� � �1�1�@�!$�!%�!4�!4� $� 3���� ��&�z�2� �� � �� � �1�1�A�!$�!%�!4�!4� $� 3���� �s/�B�2C�C�'*C�C�D*�6*D%�%D*c�H�|jj|jzSr>)r��pendingr�rDs rrez"SSLProtocol._get_write_buffer_sizeTs���~�~�%�%��(?�(?�?�?rc�\�t||tj�\}}||_||_yr>)r,r�!FLOW_CONTROL_HIGH_WATER_SSL_WRITErar`r]s rr[z$SSLProtocol._set_write_buffer_limitsWs.��,��#�y�B�B�D� ��c�$(��!�#&�� rc��d|_yr�)rRrDs rrUzSSLProtocol._pause_reading_s ��#'�� rc�n���jr(d�_�fd�}�jj|�yy)NFc����jtjk(r�j�y�jtjk(r�j�y�jtjk(r�j�yyr>)r�r r r�rr�rr�rDs�r�resumez+SSLProtocol._resume_reading.<locals>.resumefs`����;�;�"2�":�":�:��M�M�O��[�[�$4�$=�$=�=��N�N�$��[�[�$4�$=�$=�=��%�%�'�>r)rRr0r�)r3rLs` rrXzSSLProtocol._resume_readingbs2����#�#�',�D�$� (� �J�J� � ��(�$rc��|j�}||jk\r.|js"d|_|jj �y||j kr/|jr"d|_|jj �yyy)NTF)rprmr�r�rVrlrY)r3rDs rriz SSLProtocol._control_ssl_readingqsu���)�)�+���4�,�,�,�T�5M�5M�'+�D�$��O�O�)�)�+� �T�-�-� -�$�2J�2J�',�D�$��O�O�*�*�,�3K� -rc�\�t||tj�\}}||_||_yr>)r,r� FLOW_CONTROL_HIGH_WATER_SSL_READrmrlr]s rrhz#SSLProtocol._set_read_buffer_limitszs.��,��#�y�A�A�C� ��c�$(��!�#&�� rc�.�|jjSr>)r�rFrDs rrpz!SSLProtocol._get_read_buffer_size�s���~�~�%�%�%rc�.�|jrJ�d|_y)z\Called when the low-level transport's buffer goes over the high-water mark. TN)r�rDs rrAzSSLProtocol.pause_writing�s���+�+�+�+�#'�� rc�N�|jsJ�d|_|j�y)z^Called when the low-level transport's buffer drains below the low-water mark. FN)r�rrDs rrCzSSLProtocol.resume_writing�s'���'�'�'�'�#(�� ���� rc�f�|jr|jj|�t|t�r5|jj�rt jd||d��yyt|tj�s+|jj|||j|d��yy)Nz%r: %sT)�exc_infor>)r�r�rv�OSErrorr0r�rr�r�CancelledErrorrB)r3r�r?s rr�zSSLProtocol._fatal_error�s����?�?��O�O�(�(��-��c�7�#��z�z�#�#�%����X�t�W�t�D�&��C��!:�!:�;��J�J�-�-�"� �!�_�_� � /� �<r)FNTNNr>r�)zFatal error on transport)/rrrr�r�r�r�r6r?r�r�rGr�r�r�r�r�r8r�r�r�r�r�rJrr�r�rr�r|r�rr�r)r*rr\rer[rUrXrirhrprArCr�rrrr�r�s����H� �� $��#��59�&*�'+�&*� Q"�f 1��#�L� �"2�H%� �!�F�$-�P� ;�.�%�R�*C�� -�8�.�A�0!� $�A�,#�:#�<B��:@�'�(�)�-�'�&� (�!� rr�)r��enumr�r�ImportError�rrrr�logr�SSLWantReadError�SSLSyscallErrorr�Enumr rr$r,�_FlowControlMixin� Transportr.r�r�rrr�<module>r`s��� �����������?��*�*�C�,?�,?�@�N��t�y�y�� &�t�y�y� &� ��*r;�J�8�8�&�0�0�r;�jZ �)�,�,�Z ��{�� �C��s�B0�0B:�9B:__pycache__/staggered.cpython-312.opt-1.pyc000064400000014376151706172560014410 0ustar00� T��h���P�dZdZddlZddlmZddlmZddlmZddlmZdd �d �Z y)zFSupport for running coroutines in parallel with staggered start times.)�staggered_race�N�)�events)� exceptions)�locks)�tasks)�loopc ��t���� � ��� ���K��xstj��t|��d�d�g�g� t��d� � ��fd�� d��� ���� ��f d��d} t j �}�j �|d��}�j|�|j� �|j�d}�r �j�� � �d{���d� �r� |�|���� f� ~�S7�#tj$r,}|}�D]}|j|j��Yd}~�Nd}~wwxYw#� ~�wxYw�w)a�Run coroutines with staggered start times and take the first to finish. This method takes an iterable of coroutine functions. The first one is started immediately. From then on, whenever the immediately preceding one fails (raises an exception), or when *delay* seconds has passed, the next coroutine is started. This continues until one of the coroutines complete successfully, in which case all others are cancelled, or until all coroutines fail. The coroutines provided should be well-behaved in the following way: * They should only ``return`` if completed successfully. * They should always raise an exception if they did not complete successfully. In particular, if they handle cancellation, they should probably reraise, like this:: try: # do work except asyncio.CancelledError: # undo partially completed work raise Args: coro_fns: an iterable of coroutine functions, i.e. callables that return a coroutine object when called. Use ``functools.partial`` or lambdas to pass arguments. delay: amount of time, in seconds, between starting coroutines. If ``None``, the coroutines will run sequentially. loop: the event loop to use. Returns: tuple *(winner_result, winner_index, exceptions)* where - *winner_result*: the result of the winning coroutine, or ``None`` if no coroutines won. - *winner_index*: the index of the winning coroutine in ``coro_fns``, or ``None`` if no coroutines won. If the winning coroutine may return None on success, *winner_index* can be used to definitively determine whether any coroutine won. - *exceptions*: list of exceptions returned by the coroutines. ``len(exceptions)`` is equal to the number of coroutines actually started, and the order is the same as in ``coro_fns``. The winning coroutine's entry is ``None``. Nc�����j|���#�j�s�s�jd�|j�ry|j �}|�y�j|�y�N)�discard�done� set_result� cancelled� exception�append)�task�exc�on_completed_fut� running_tasks�unhandled_exceptionss ����*/usr/lib64/python3.12/asyncio/staggered.py� task_donez!staggered_race.<locals>.task_doneJsc������d�#��(�$�)�)�+�!��'�'��-��>�>����n�n����;���#�#�C�(�c��X� K�|j��d{���|�Xtjtj�5tj|j����d{���ddd� t��\}}tj�}tj�}�j�||��}�j|�|j��|j�� jd� |��d{���}|�|�tj ��}�D]} | |us�| j#��y7��77��#1swY��xYw#t$rYywxYw7�Z#t$t&f$r�t($r} | � |<|j�Yd} ~ yd} ~ wwxYw�wr)�wait� contextlib�suppress�exceptions_mod�TimeoutErrorr�wait_for�next� StopIterationr�Event�create_task�add�add_done_callback�setr�current_task�cancel� SystemExit�KeyboardInterrupt� BaseException)�ok_to_start�previous_failed� this_index�coro_fn�this_failed�next_ok_to_start� next_task�resultr)�t�e�delay� enum_coro_fnsrr �run_one_cororr�winner_index� winner_results ���������rr:z$staggered_race.<locals>.run_one_coro[s��������� � � ��&��$�$�^�%@�%@�A� �n�n�_�%9�%9�%;�U�C�C�C�B� �"&�}�"5��J���k�k�m�� �;�;�=���$�$�\�2B�K�%P�Q� ����)�$��#�#�I�.� �������$�� �"�9�_�F�&�L�"�M�!�-�-�d�3�L�"���L�(��H�H�J�#�a !��D��B�A��� �� �� %���-�.� ��� �%&�J�z�"��O�O���� �s��F*�E�)F*�(E�)E�*E�.F*�7E�BF*� E0�E.�E0�"F*�;F*�E�E�F*� E+�(F*�*E+�+F*�.E0�0F'�F"�F*�"F'�'F*)�returnN)r�get_running_loop� enumerater(rr$r%r&r'� create_futurer�CancelledErrorr*�args�ExceptionGroup)�coro_fnsr8r �propagate_cancellation_errorr.� first_task�exrr9rrr:rrrr;r<s `` @@@@@@@@@rrr sQ������h�,�6�*�*�,�D��h�'�M��M��L����J��E�M���)�"6�6�p$(� �K��k�k�m���%�%�l�;��&E�F� ����*�%��$�$�Y�/�����'+�$��#�1�1�3�� *�&�&�&� $����(�3�.�.��l�J�6��4�6J�'��!�0�0� *�/1�,�)�D��D�K�K����)�*�� *�� �4�6J�sa�AD8�A2D0�C.�C,�C.�D0� D0�(D8�,C.�.D-�"D(�#D0�(D-�-D0�0D5�5D8) �__doc__�__all__r�rrrrrr�rr�<module>rLs(��L� ����*���37�aKr__pycache__/staggered.cpython-312.opt-2.pyc000064400000010264151706172560014401 0ustar00� T��h���N� dZddlZddlmZddlmZddlmZddlmZdd�d �Zy) )�staggered_race�N�)�events)� exceptions)�locks)�tasks)�loopc ��v���� � ��� ���K� �xstj��t|��d�d�g�g� t��d� � ��fd�� d��� ���� ��f d��d} t j �}�j �|d��}�j|�|j� �|j�d}�r �j�� � �d{���d� �r� |�|���� f� ~�S7�#tj$r,}|}�D]}|j|j��Yd}~�Nd}~wwxYw#� ~�wxYw�w)Nc�����j|���#�j�s�s�jd�|j�ry|j �}|�y�j|�y�N)�discard�done� set_result� cancelled� exception�append)�task�exc�on_completed_fut� running_tasks�unhandled_exceptionss ����*/usr/lib64/python3.12/asyncio/staggered.py� task_donez!staggered_race.<locals>.task_doneJsc������d�#��(�$�)�)�+�!��'�'��-��>�>����n�n����;���#�#�C�(�c��X� K�|j��d{���|�Xtjtj�5tj|j����d{���ddd� t��\}}tj�}tj�}�j�||��}�j|�|j��|j�� jd� |��d{���}|�|�tj ��}�D]} | |us�| j#��y7��77��#1swY��xYw#t$rYywxYw7�Z#t$t&f$r�t($r} | � |<|j�Yd} ~ yd} ~ wwxYw�wr)�wait� contextlib�suppress�exceptions_mod�TimeoutErrorr�wait_for�next� StopIterationr�Event�create_task�add�add_done_callback�setr�current_task�cancel� SystemExit�KeyboardInterrupt� BaseException)�ok_to_start�previous_failed� this_index�coro_fn�this_failed�next_ok_to_start� next_task�resultr)�t�e�delay� enum_coro_fnsrr �run_one_cororr�winner_index� winner_results ���������rr:z$staggered_race.<locals>.run_one_coro[s��������� � � ��&��$�$�^�%@�%@�A� �n�n�_�%9�%9�%;�U�C�C�C�B� �"&�}�"5��J���k�k�m�� �;�;�=���$�$�\�2B�K�%P�Q� ����)�$��#�#�I�.� �������$�� �"�9�_�F�&�L�"�M�!�-�-�d�3�L�"���L�(��H�H�J�#�a !��D��B�A��� �� �� %���-�.� ��� �%&�J�z�"��O�O���� �s��F*�E�)F*�(E�)E�*E�.F*�7E�BF*� E0�E.�E0�"F*�;F*�E�E�F*� E+�(F*�*E+�+F*�.E0�0F'�F"�F*�"F'�'F*)�returnN)r�get_running_loop� enumerater(rr$r%r&r'� create_futurer�CancelledErrorr*�args�ExceptionGroup)�coro_fnsr8r �propagate_cancellation_errorr.� first_task�exrr9rrr:rrrr;r<s `` @@@@@@@@@rrr sV������1�f�,�6�*�*�,�D��h�'�M��M��L����J��E�M���)�"6�6�p$(� �K��k�k�m���%�%�l�;��&E�F� ����*�%��$�$�Y�/�����'+�$��#�1�1�3�� *�&�&�&� $����(�3�.�.��l�J�6��4�6J�'��!�0�0� *�/1�,�)�D��D�K�K����)�*�� *�� �4�6J�sa�AD9�A2D1�C/�C-�C/�D1� D1�)D9�-C/�/D.�"D)�$D1�)D.�.D1�1D6�6D9) �__all__r�rrrrrr�rr�<module>rKs(��L� ����*���37�aKr__pycache__/staggered.cpython-312.pyc000064400000014626151706172560013447 0ustar00� T��h���P�dZdZddlZddlmZddlmZddlmZddlmZdd �d �Z y)zFSupport for running coroutines in parallel with staggered start times.)�staggered_race�N�)�events)� exceptions)�locks)�tasks)�loopc ������ � ��� ���K��xstj��t|��d�d�g�g� t��d� � ��fd�� d��� ���� ��f d��d} t j �}�j �|d��}�j|�|j� �|j�d}�r �j�� � �d{���d� �r� �rtd���|�|���� f� ~�S7�##tj$r,}|}�D]}|j|j��Yd}~�[d}~wwxYw#� ~�wxYw�w)a�Run coroutines with staggered start times and take the first to finish. This method takes an iterable of coroutine functions. The first one is started immediately. From then on, whenever the immediately preceding one fails (raises an exception), or when *delay* seconds has passed, the next coroutine is started. This continues until one of the coroutines complete successfully, in which case all others are cancelled, or until all coroutines fail. The coroutines provided should be well-behaved in the following way: * They should only ``return`` if completed successfully. * They should always raise an exception if they did not complete successfully. In particular, if they handle cancellation, they should probably reraise, like this:: try: # do work except asyncio.CancelledError: # undo partially completed work raise Args: coro_fns: an iterable of coroutine functions, i.e. callables that return a coroutine object when called. Use ``functools.partial`` or lambdas to pass arguments. delay: amount of time, in seconds, between starting coroutines. If ``None``, the coroutines will run sequentially. loop: the event loop to use. Returns: tuple *(winner_result, winner_index, exceptions)* where - *winner_result*: the result of the winning coroutine, or ``None`` if no coroutines won. - *winner_index*: the index of the winning coroutine in ``coro_fns``, or ``None`` if no coroutines won. If the winning coroutine may return None on success, *winner_index* can be used to definitively determine whether any coroutine won. - *exceptions*: list of exceptions returned by the coroutines. ``len(exceptions)`` is equal to the number of coroutines actually started, and the order is the same as in ``coro_fns``. The winning coroutine's entry is ``None``. Nc�����j|���#�j�s�s�jd�|j�ry|j �}|�y�j|�y)N)�discard�done� set_result� cancelled� exception�append)�task�exc�on_completed_fut� running_tasks�unhandled_exceptionss ����*/usr/lib64/python3.12/asyncio/staggered.py� task_donez!staggered_race.<locals>.task_doneJsc������d�#��(�$�)�)�+�!��'�'��-��>�>����n�n����;���#�#�C�(�c��� K�|j��d{���|�Xtjtj�5tj|j����d{���ddd� t��\}}tj�}tj�}�j�||��}�j|�|j��|j�� jd�t!� �|dzk(sJ� |��d{���}��J�|�|�tj"��}�D]} | |us�| j%��y7��N7��#1swY��xYw#t$rYywxYw7�^#t&t(f$r�t*$r} | � |<|j�Yd} ~ yd} ~ wwxYw�w)Nr)�wait� contextlib�suppress�exceptions_mod�TimeoutErrorr�wait_for�next� StopIterationr�Event�create_task�add�add_done_callback�setr�len�current_task�cancel� SystemExit�KeyboardInterrupt� BaseException)�ok_to_start�previous_failed� this_index�coro_fn�this_failed�next_ok_to_start� next_task�resultr)�t�e�delay� enum_coro_fnsrr �run_one_cororr�winner_index� winner_results ���������rr:z$staggered_race.<locals>.run_one_coro[s��������� � � ��&��$�$�^�%@�%@�A� �n�n�_�%9�%9�%;�U�C�C�C�B� �"&�}�"5��J���k�k�m�� �;�;�=���$�$�\�2B�K�%P�Q� ����)�$��#�#�I�.� �������$���:��*�q�.�0�0�0� �"�9�_�F� �'�'�'�%�L�"�M�!�-�-�d�3�L�"���L�(��H�H�J�#�a !��D��B�A��� �� �� %���-�.� ��� �%&�J�z�"��O�O���� �s��G�E%�)G�(E*�)E(�*E*�.G�7E6�BG� F�&F�'F�+&G�G�(E*�*E3�/G�6 F�?G�F�G�F�F>�F9�4G�9F>�>Gzstaggered race failed)�returnN)r�get_running_loop� enumerater'rr#r$r%r&� create_futurer�CancelledErrorr*�args�ExceptionGroup)�coro_fnsr8r �propagate_cancellation_errorr.� first_task�exrr9rrr:rrrr;r<s `` @@@@@@@@@rrr s`������h�,�6�*�*�,�D��h�'�M��M��L����J��E�M���)�"6�6�p$(� �K��k�k�m���%�%�l�;��&E�F� ����*�%��$�$�Y�/�����'+�$��#�1�1�3�� *�&�&�&� $���.�!�!8�:N�O�O�'�3�.�.��l�J�6��4�6J�'��!�0�0� *�/1�,�)�D��D�K�K����)�*�� *�� �4�6J�sa�AE�A2D=�C;�C9�C;�D=�D=�5E�9C;�;D:�"D5�0D=�5D:�:D=�=E�E) �__doc__�__all__r�rrrrrr�rr�<module>rLs(��L� ����*���37�aKr__pycache__/streams.cpython-312.opt-1.pyc000064400000100275151706172560014113 0ustar00� T��h�k��l�dZddlZddlZddlZddlZddlZeed�redz ZddlmZddlm Z ddlm Z dd lmZdd lmZddl mZddlmZd Zded�d�Zded�d�Zeed�rded�d�Zded�d�ZGd�dej,�ZGd�deej,�ZGd�d�ZGd�d�Zy))�StreamReader�StreamWriter�StreamReaderProtocol�open_connection�start_server�N�AF_UNIX)�open_unix_connection�start_unix_server�)� coroutines)�events)� exceptions)�format_helpers)� protocols)�logger)�sleepi)�limitc���� K�tj�}t||��}t||��� |j� fd�||fi|���d{���\}}t|� ||�}||fS7��w)a�A wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) �r�loop�rc����S�N���protocols��(/usr/lib64/python3.12/asyncio/streams.py�<lambda>z!open_connection.<locals>.<lambda>1s����N)r �get_running_looprr�create_connectionr) �host�portr�kwdsr�reader� transport�_�writerrs @rrrsx�����&�"�"�$�D� ��D� 1�F�#�F��6�H�/��/�/��$��.�(,�.�.�L�I�q� �)�X�v�t� <�F��6�>��.�s�A A)� A'�A)c�����K�tj�����fd�}�j|||fi|���d{���S7��w)a�Start a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword argument is limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. c�>��t����}t|����}|S�Nrr�rr�r%r�client_connected_cbrrs ���r�factoryzstart_server.<locals>.factoryNs&����E��5��'��0C�-1�3���rN)r r � create_server)r.r"r#rr$r/rs` ` @rrr6s@�����,�"�"�$�D��$��#�#�G�T�4�@�4�@�@�@�@�s�4A�>�Ac����K�tj�}t||��}t||���|j�fd�|fi|���d{���\}}t|�||�}||fS7��w)z@Similar to `open_connection` but works with UNIX Domain Sockets.rrc����Srrrs�rrz&open_unix_connection.<locals>.<lambda>bs���HrN)r r rr�create_unix_connectionr) �pathrr$rr%r&r'r(rs @rr r Zsv������&�&�(���E��5��'��T�:��8�T�8�8��d�,�&*�,�,�� �1��i��6�4�@���v�~��,�s�A A(�A&� A(c�����K�tj�����fd�}�j||fi|���d{���S7��w)z=Similar to `start_server` but works with UNIX Domain Sockets.c�>��t����}t|����}|Sr+r,r-s ���rr/z"start_unix_server.<locals>.factoryks&���!��D�9�F�+�F�4G�15�7�H��OrN)r r �create_unix_server)r.r4rr$r/rs` ` @rr r fs>������&�&�(�� �-�T�,�,�W�d�C�d�C�C�C�C�s�3?�=�?c�6�eZdZdZd d�Zd�Zd�Zd�Zd�Zd�Z y) �FlowControlMixina)Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_writing() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. Nc��|�tj�|_n||_d|_t j �|_d|_y�NF)r �get_event_loop�_loop�_paused�collections�deque�_drain_waiters�_connection_lost)�selfrs r�__init__zFlowControlMixin.__init__~s>���<��.�.�0�D�J��D�J����)�/�/�1��� %��rc�t�d|_|jj�rtjd|�yy)NTz%r pauses writing)r>r=� get_debugr�debug�rCs r� pause_writingzFlowControlMixin.pause_writing�s-������:�:���!��L�L�,�d�3�"rc���d|_|jj�rtjd|�|j D]$}|j �r�|jd��&y)NFz%r resumes writing)r>r=rFrrGrA�done� set_result�rC�waiters r�resume_writingzFlowControlMixin.resume_writing�sO������:�:���!��L�L�-�t�4��)�)�F��;�;�=��!�!�$�'�*rc��d|_|jsy|jD]8}|j�r�|�|j d��(|j|��:y�NT)rBr>rArKrL� set_exception�rC�excrNs r�connection_lostz FlowControlMixin.connection_lost�sN�� $����|�|���)�)�F��;�;�=��;��%�%�d�+��(�(��-�*rc��NK�|jrtd��|jsy|jj �}|j j |� |�d{���|j j|�y7� #|j j|�wxYw�w)NzConnection lost)rB�ConnectionResetErrorr>r=� create_futurerA�append�removerMs r� _drain_helperzFlowControlMixin._drain_helper�s������ � �&�'8�9�9��|�|�����)�)�+�����"�"�6�*� /��L�L����&�&�v�.� �����&�&�v�.�s0�AB%�B�"B�#B�'B%�B�B"�"B%c��t�r)�NotImplementedError�rC�streams r�_get_close_waiterz"FlowControlMixin._get_close_waiter�s��!�!rr) �__name__� __module__�__qualname__�__doc__rDrIrOrUr[r`rrrr9r9ts%���&�4�(�.� /�"rr9c�f��eZdZdZdZd�fd� Zed��Zd�Zd�Z �fd�Z d�Zd �Zd �Z d�Z�xZS) ra=Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) Nc�4��t�|�|��|�,tj|�|_|j |_nd|_|�||_d|_d|_d|_ d|_ ||_d|_|jj�|_y)NrF)�superrD�weakref�ref�_stream_reader_wr�_source_traceback�_strong_reader�_reject_connection�_stream_writer�_task� _transport�_client_connected_cb� _over_sslr=rX�_closed)rC� stream_readerr.r� __class__s �rrDzStreamReaderProtocol.__init__�s���� ���d��#��$�%,�[�[��%?�D�"�%2�%D�%D�D�"�%)�D�"��*�#0�D��"'���"����� ����$7��!�����z�z�/�/�1��rc�<�|j�y|j�Sr)rjrHs r�_stream_readerz#StreamReaderProtocol._stream_reader�s ���!�!�)���%�%�'�'rc��|j}|j}||_||_|j d�du|_y)N� sslcontext)r=r&rnrp�get_extra_inforr)rCr(rr&s r�_replace_writerz$StreamReaderProtocol._replace_writer�s<���z�z���$�$� �$���#���"�1�1�,�?�t�K��rc�x����jrKddi}�jr�j|d<�jj|��j �y��_�j}|�|j���jd�du�_ �j��t��|�j��_�j|�j�}tj|�rA��fd�}�jj|��_�j j#|�d�_yy)N�messagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.�source_tracebackryc����|j�r�j�y|j�}|�0�jj d|�d���j�yy)Nz*Unhandled exception in client_connected_cb)r}� exceptionr&)� cancelled�closer�r=�call_exception_handler)�taskrTrCr&s ��r�callbackz6StreamReaderProtocol.connection_made.<locals>.callback�s\����~�~�'�!���)���.�.�*�C���� � �9�9�'S�),�)2�;�� "���)� 'r)rmrkr=r��abortrprw� set_transportrzrrrqrrnr�iscoroutine�create_taskro�add_done_callbackrl)rCr&�contextr%�resr�s`` r�connection_madez$StreamReaderProtocol.connection_made�s#����"�"��@��G� �%�%�.2�.D�.D��*�+��J�J�-�-�g�6��O�O���#����$�$����� � ��+�"�1�1�,�?�t�K����$�$�0�".�y�$�/5�/3�z�z�#;�D���+�+�F�,0�,?�,?�A�C��%�%�c�*�*�"�Z�Z�3�3�C�8�� �� � �,�,�X�6�"&�D��/1rc�f��|j}|�$|�|j�n|j|�|jj �s9|�|jjd�n|jj|�t�|�|�d|_d|_ d|_ d|_yr)rw�feed_eofrRrsrKrLrgrUrjrnrorp)rCrTr%rus �rrUz$StreamReaderProtocol.connection_lost s�����$�$�����{����!��$�$�S�)��|�|� � �"��{����'�'��-����*�*�3�/� ����$�!%���"����� ���rc�D�|j}|�|j|�yyr)rw� feed_data)rC�datar%s r� data_receivedz"StreamReaderProtocol.data_receiveds&���$�$�������T�"�rc�Z�|j}|�|j�|jryy)NFT)rwr�rr)rCr%s r�eof_receivedz!StreamReaderProtocol.eof_received!s,���$�$�����O�O���>�>��rc��|jSr)rsr^s rr`z&StreamReaderProtocol._get_close_waiter,s���|�|�rc�� |j}|j�r"|j�s|j�yyy#t$rYywxYwr)rsrKr�r��AttributeError)rC�closeds r�__del__zStreamReaderProtocol.__del__/sM�� #��\�\�F��{�{�}�V�%5�%5�%7�� � �"�&8�}��� �� �s�A� A �A �NN)rarbrcrdrkrD�propertyrwr{r�rUr�r�r`r�� __classcell__)rus@rrr�sN������2�(�(��(� L�('�T�$#� �� #rrc�z�eZdZdZd�Zd�Zed��Zd�Zd�Z d�Z d�Zd �Zd �Z d�Zdd �Zd�Zdddd�d�Zd�Zy)ra'Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. c��||_||_||_||_|jj �|_|j j d�yr)rp� _protocol�_readerr=rX� _complete_futrL)rCr&rr%rs rrDzStreamWriter.__init__EsI��#���!�������� �!�Z�Z�5�5�7������%�%�d�+rc���|jjd|j��g}|j�|j d|j���djdj |��S)N� transport=zreader=�<{}>� )rurarpr�rY�format�join�rC�infos r�__repr__zStreamWriter.__repr__Os[�����'�'�:�d�o�o�5H�)I�J���<�<�#��K�K�'�$�,�,�!1�2�3��}�}�S�X�X�d�^�,�,rc��|jSr�rprHs rr&zStreamWriter.transportUs�����rc�:�|jj|�yr)rp�write�rCr�s rr�zStreamWriter.writeYs�������d�#rc�:�|jj|�yr)rp� writelinesr�s rr�zStreamWriter.writelines\s�����"�"�4�(rc�6�|jj�Sr)rp� write_eofrHs rr�zStreamWriter.write_eof_s�����(�(�*�*rc�6�|jj�Sr)rp� can_write_eofrHs rr�zStreamWriter.can_write_eofbs�����,�,�.�.rc�6�|jj�Sr)rpr�rHs rr�zStreamWriter.closees�����$�$�&�&rc�6�|jj�Sr)rp� is_closingrHs rr�zStreamWriter.is_closinghs�����)�)�+�+rc��VK�|jj|��d{���y7��wr)r�r`rHs r�wait_closedzStreamWriter.wait_closedks�����n�n�.�.�t�4�4�4�s�)�'�)Nc�:�|jj||�Sr)rprz)rC�name�defaults rrzzStreamWriter.get_extra_infons�����-�-�d�G�<�<rc��K�|j�|jj�}|�|�|jj�rt d��d{���|j j ��d{���y7�'7��w)zyFlush the write buffer. The intended use is to write w.write(data) await w.drain() Nr)r�r�rpr�rr�r[)rCrTs r�drainzStreamWriter.drainqsj�����<�<�#��,�,�(�(�*�C���� ��?�?�%�%�'���(�N�N��n�n�*�*�,�,�,� ��,�s$�AB�A=�!B�7A?�8B�?B)�server_hostname�ssl_handshake_timeout�ssl_shutdown_timeoutc ��$K�|jjdu}|j}|j��d{���|jj |j ||||||���d{���}||_|j |�y7�Q7��w)z3Upgrade an existing stream-based connection to TLS.N)�server_sider�r�r�)r�rqr�r=� start_tlsrpr{)rCryr�r�r�r�r� new_transports rr�zStreamWriter.start_tls�s����� �n�n�9�9��E���>�>���j�j�l���"�j�j�2�2��O�O�X�z�#�_�"7�!5� 3�7�7� � (���� � ��&� ��7�s!�8B�B�3B�.B�/B�Bc��|jj�sc|jj�rt j dt�y|j�t j d|��t�yy)Nzloop is closedz unclosed )rpr�r=� is_closed�warnings�warn�ResourceWarningr�rHs rr�zStreamWriter.__del__�sT�����)�)�+��z�z�#�#�%�� � �.��@�� � ��� � � �$��2�O�D�,rr)rarbrcrdrDr�r�r&r�r�r�r�r�r�r�rzr�r�r�rrrrr;sh���,�-�����$�)�+�/�'�,�5�=�-�4)-�.2�-1�'� Errc��eZdZdZedfd�Zd�Zd�Zd�Zd�Z d�Z d�Zd �Zd �Z d�Zd�Zd �Zdd�Zdd�Zd�Zd�Zd�Zy)rNc�l�|dkrtd��||_|�tj�|_n||_t�|_d|_d|_d|_ d|_ d|_|jj�r.tjtj d��|_yy)NrzLimit cannot be <= 0Fr)� ValueError�_limitr r<r=� bytearray�_buffer�_eof�_waiter� _exceptionrpr>rFr� extract_stack�sys� _getframerk)rCrrs rrDzStreamReader.__init__�s����A�:��3�4�4�����<��.�.�0�D�J��D�J� �{����� ��������������:�:���!�%3�%A�%A�� � �a� �&"�D�"�"rc��dg}|jr'|jt|j��d��|jr|jd�|jt k7r|jd|j���|jr|jd|j���|jr|jd|j���|jr|jd|j���|jr|jd�d jd j|��S)Nrz bytes�eofzlimit=zwaiter=z exception=r��pausedr�r�)r�rY�lenr�r��_DEFAULT_LIMITr�r�rpr>r�r�r�s rr�zStreamReader.__repr__�s�������<�<��K�K�3�t�|�|�,�-�V�4�5��9�9��K�K����;�;�.�(��K�K�&���� �.�/��<�<��K�K�'�$�,�,�!1�2�3��?�?��K�K�*�T�_�_�$7�8�9��?�?��K�K�*�T�_�_�$7�8�9��<�<��K�K��!��}�}�S�X�X�d�^�,�,rc��|jSr)r�rHs rr�zStreamReader.exception�s�����rc��||_|j}|�*d|_|j�s|j|�yyyr)r�r�r�rRrSs rrRzStreamReader.set_exception�sC������������D�L��#�#�%��$�$�S�)�&�rc�t�|j}|�*d|_|j�s|jd�yyy)z1Wakeup read*() functions waiting for data or EOF.N)r�r�rLrMs r�_wakeup_waiterzStreamReader._wakeup_waiter�s<���������D�L��#�#�%��!�!�$�'�&�rc��||_yrr�)rCr&s rr�zStreamReader.set_transport�s ��#��rc��|jrEt|j�|jkr"d|_|jj�yyyr;)r>r�r�r�rp�resume_readingrHs r�_maybe_resume_transportz$StreamReader._maybe_resume_transport�s;���<�<�C����-����<� �D�L��O�O�*�*�,�=�<rc�2�d|_|j�yrQ)r�r�rHs rr�zStreamReader.feed_eof�s���� ����rc�8�|jxr |jS)z=Return True if the buffer is empty and 'feed_eof' was called.)r�r�rHs r�at_eofzStreamReader.at_eof�s���y�y�-����-�-rc�P�|sy|jj|�|j�|j�V|jsIt|j�d|jzkDr# |jj�d|_yyyy#t$r d|_YywxYw)N�T) r��extendr�rpr>r�r�� pause_readingr]r�s rr�zStreamReader.feed_data�s����������D�!������O�O�'��L�L��D�L�L�!�A����O�3� $����-�-�/� $���4�!� (�� '� '�#'��� '�s�-B�B%�$B%c��,K�|j�t|�d���|jr!d|_|jj �|j j �|_ |j�d{���d|_y7�#d|_wxYw�w)zpWait until feed_data() or feed_eof() is called. If stream was paused, automatically resume it. NzF() called while another coroutine is already waiting for incoming dataF)r��RuntimeErrorr>rpr�r=rX)rC� func_names r�_wait_for_datazStreamReader._wait_for_data s������<�<�#���+�4�5�6� 6��<�<� �D�L��O�O�*�*�,��z�z�/�/�1��� ��,�,����D�L� ���D�L�s0�A'B�*B�9B�:B�>B�B� B�Bc���K�d}t|�} |j|��d{���}|S7�#tj$r}|jcYd}~Sd}~wtj $r�}|jj||j�r|jd|j|z�=n|jj�|j�t|jd��d}~wwxYw�w)a�Read chunk of data from the stream until newline (b' ') is found. On success, return chunk that ends with newline. If only partial line can be read due to EOF, return incomplete line without terminating newline. When EOF was reached while no bytes read, empty bytes object is returned. If limit is reached, ValueError will be raised. In that case, if newline was found, complete line including newline will be removed from internal buffer. Else, internal buffer will be cleared. Limit is compared against part of the line without newline. If stream was paused, this function will automatically resume it if needed. � Nr) r�� readuntilr�IncompleteReadError�partial�LimitOverrunErrorr�� startswith�consumed�clearr�r��args)rC�sep�seplen�line�es r�readlinezStreamReader.readline%s����� ���S��� (�����,�,�D���-���-�-� ��9�9����+�+� (��|�|�&�&�s�A�J�J�7��L�L�!5�!�*�*�v�"5�!5�6����"�"�$��(�(�*��Q�V�V�A�Y�'�'�� (�sJ�C5�.�,�.�C5�.�C2�A�C2� C5�C2�(BC-�-C2�2C5c���K�t|�}|dk(rtd��|j�|j�d} t|j�}||z |k\rO|jj ||�}|dk7rn�|dz|z }||j kDrt jd|��|jrEt|j�}|jj�t j|d��|jd��d{�����||j kDrt jd|��|jd||z}|jd||z�=|j�t|�S7�i�w) aVRead data from the stream until ``separator`` is found. On success, the data and separator will be removed from the internal buffer (consumed). Returned data will include the separator at the end. Configured stream limit is used to check result. Limit sets the maximal length of data that can be returned, not counting the separator. If an EOF occurs and the complete separator is still not found, an IncompleteReadError exception will be raised, and the internal buffer will be reset. The IncompleteReadError.partial attribute may contain the separator partially. If the data cannot be read because of over limit, a LimitOverrunError exception will be raised, and the data will be left in the internal buffer, so it can be read again. rz,Separator should be at least one-byte stringN���rz2Separator is not found, and chunk exceed the limitr�z2Separator is found, but chunk is longer than limit)r�r�r�r��findr�rr�r��bytesr�r�r�r�)rC� separatorr��offset�buflen�isep�chunks rr�zStreamReader.readuntilDsz����(�Y����Q�;��K�L�L��?�?�&��/�/�!�*�������&�F����&�(��|�|�(�(��F�;���2�:�� �!��f�,���D�K�K�'�$�6�6�L�� � ��y�y��d�l�l�+�����"�"�$� �4�4�U�D�A�A��%�%�k�2�2�2�=�@�$�+�+���.�.�D�d�L� L����^�d�V�m�,���L�L��$��-��(��$�$�&��U�|�� 3�s�DE6� E4�A*E6c���K�|j�|j�|dk(ry|dkrLg} |j|j��d{���}|sn|j|��8dj |�S|j s%|js|jd��d{���tt|j �d|�}|j d|�=|j�|S7��7�H�w)a�Read up to `n` bytes from the stream. If `n` is not provided or set to -1, read until EOF, then return all read bytes. If EOF was received and the internal buffer is empty, return an empty bytes object. If `n` is 0, return an empty bytes object immediately. If `n` is positive, return at most `n` available bytes as soon as at least 1 byte is available in the internal buffer. If EOF is received before any byte is read, return an empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. Nrr�read)r�r r�rYr�r�r�r�r� memoryviewr�)rC�n�blocks�blockr�s rr zStreamReader.read�s�����,�?�?�&��/�/�!���6���q�5� �F��"�i�i����4�4����� � �e�$� � �8�8�F�#�#��|�|�D�I�I��%�%�f�-�-�-��Z����-�b�q�1�2���L�L��!����$�$�&���5�� .�s&�AC)�C%�AC)�C'�AC)�'C)c��K�|dkrtd��|j�|j�|dk(ryt|j�|kr�|jrEt|j�}|jj �tj||��|jd��d{���t|j�|kr��t|j�|k(r0t|j�}|jj �n0tt|j�d|�}|jd|�=|j�|S7���w)a�Read exactly `n` bytes. Raise an IncompleteReadError if EOF is reached before `n` bytes can be read. The IncompleteReadError.partial attribute of the exception will contain the partial read bytes. if n is zero, return empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. rz*readexactly size can not be less than zeroNr�readexactly)r�r�r�r�r�rr�rr�r�rr�)rCr� incompleter�s rrzStreamReader.readexactly�s���� �q�5��I�J�J��?�?�&��/�/�!���6���$�,�,��!�#��y�y�"�4�<�<�0� ����"�"�$� �4�4�Z��C�C��%�%�m�4�4�4� �$�,�,��!�#��t�|�|���!�����&�D��L�L��� ���D�L�L�1�"�1�5�6�D����R�a�R� ��$�$�&��� 5�s�B,E�.E�/E�BEc��|SrrrHs r� __aiter__zStreamReader.__aiter__�s���rc��XK�|j��d{���}|dk(rt�|S7��w)Nr)r��StopAsyncIteration)rC�vals r� __anext__zStreamReader.__anext__�s+�����M�M�O�#���#�:�$�$�� �$�s�*�(�*)r�)r)rarbrcrkr�rDr�r�rRr�r�r�r�r�r�r�r�r�r rrrrrrrr�sf����+�$�"�,-�$�*�(�$�-� �.�$�, �8�>Y�v1�f'�R�rrr�r)�__all__r?�socketr�r�rh�hasattr�rr rrr�logr�tasksrr�rrr r �Protocolr9rrrrrr�<module>rs���'��� � ��� �6�9���<�<�G����������� .��8A�+�A�B�6�9�� �)7� �D�&4�D�="�y�)�)�="�@D#�+�Y�-?�-?�D#�NeE�eE�N`�`r__pycache__/streams.cpython-312.opt-2.pyc000064400000065042151706172560014116 0ustar00� T��h�k��l�dZddlZddlZddlZddlZddlZeed�redz ZddlmZddlm Z ddlm Z dd lmZdd lmZddl mZddlmZd Zded�d�Zded�d�Zeed�rded�d�Zded�d�ZGd�dej,�ZGd�deej,�ZGd�d�ZGd�d�Zy))�StreamReader�StreamWriter�StreamReaderProtocol�open_connection�start_server�N�AF_UNIX)�open_unix_connection�start_unix_server�)� coroutines)�events)� exceptions)�format_helpers)� protocols)�logger)�sleepi)�limitc���� K� tj�}t||��}t||��� |j� fd�||fi|���d{���\}}t|� ||�}||fS7��w)N�r�loop�rc����S�N���protocols��(/usr/lib64/python3.12/asyncio/streams.py�<lambda>z!open_connection.<locals>.<lambda>1s����)r �get_running_looprr�create_connectionr) �host�portr�kwdsr�reader� transport�_�writerrs @rrrs}������"�"�"�$�D� ��D� 1�F�#�F��6�H�/��/�/��$��.�(,�.�.�L�I�q� �)�X�v�t� <�F��6�>��.�s�AA*�A(�A*c�����K� tj�����fd�}�j|||fi|���d{���S7��w)Nc�>��t����}t|����}|S�Nrr�rr�r%r�client_connected_cbrrs ���r�factoryzstart_server.<locals>.factoryNs&����E��5��'��0C�-1�3���r)r r � create_server)r.r"r#rr$r/rs` ` @rrr6sE������(�"�"�$�D��$��#�#�G�T�4�@�4�@�@�@�@�s�5A�?�Ac����K� tj�}t||��}t||���|j�fd�|fi|���d{���\}}t|�||�}||fS7��w)Nrrc����Srrrs�rrz&open_unix_connection.<locals>.<lambda>bs���Hr)r r rr�create_unix_connectionr) �pathrr$rr%r&r'r(rs @rr r Zsw�����N��&�&�(���E��5��'��T�:��8�T�8�8��d�,�&*�,�,�� �1��i��6�4�@���v�~��,�s�A A)� A'�A)c�����K� tj�����fd�}�j||fi|���d{���S7��w)Nc�>��t����}t|����}|Sr+r,r-s ���rr/z"start_unix_server.<locals>.factoryks&���!��D�9�F�+�F�4G�15�7�H��Or)r r �create_unix_server)r.r4rr$r/rs` ` @rr r fs?�����K��&�&�(�� �-�T�,�,�W�d�C�d�C�C�C�C�s�4A�>�Ac�4�eZdZ dd�Zd�Zd�Zd�Zd�Zd�Zy) �FlowControlMixinNc��|�tj�|_n||_d|_t j �|_d|_y�NF)r �get_event_loop�_loop�_paused�collections�deque�_drain_waiters�_connection_lost)�selfrs r�__init__zFlowControlMixin.__init__~s>���<��.�.�0�D�J��D�J����)�/�/�1��� %��rc�t�d|_|jj�rtjd|�yy)NTz%r pauses writing)r>r=� get_debugr�debug�rCs r� pause_writingzFlowControlMixin.pause_writing�s-������:�:���!��L�L�,�d�3�"rc���d|_|jj�rtjd|�|j D]$}|j �r�|jd��&y)NFz%r resumes writing)r>r=rFrrGrA�done� set_result�rC�waiters r�resume_writingzFlowControlMixin.resume_writing�sO������:�:���!��L�L�-�t�4��)�)�F��;�;�=��!�!�$�'�*rc��d|_|jsy|jD]8}|j�r�|�|j d��(|j|��:y�NT)rBr>rArKrL� set_exception�rC�excrNs r�connection_lostz FlowControlMixin.connection_lost�sN�� $����|�|���)�)�F��;�;�=��;��%�%�d�+��(�(��-�*rc��NK�|jrtd��|jsy|jj �}|j j |� |�d{���|j j|�y7� #|j j|�wxYw�w)NzConnection lost)rB�ConnectionResetErrorr>r=� create_futurerA�append�removerMs r� _drain_helperzFlowControlMixin._drain_helper�s������ � �&�'8�9�9��|�|�����)�)�+�����"�"�6�*� /��L�L����&�&�v�.� �����&�&�v�.�s0�AB%�B�"B�#B�'B%�B�B"�"B%c��t�r)�NotImplementedError�rC�streams r�_get_close_waiterz"FlowControlMixin._get_close_waiter�s��!�!rr) �__name__� __module__�__qualname__rDrIrOrUr[r`rrrr9r9ts%���&�4�(�.� /�"rr9c�d��eZdZ dZd�fd� Zed��Zd�Zd�Z�fd�Z d�Z d�Zd �Zd �Z �xZS)rNc�4��t�|�|��|�,tj|�|_|j |_nd|_|�||_d|_d|_d|_ d|_ ||_d|_|jj�|_y)NrF)�superrD�weakref�ref�_stream_reader_wr�_source_traceback�_strong_reader�_reject_connection�_stream_writer�_task� _transport�_client_connected_cb� _over_sslr=rX�_closed)rC� stream_readerr.r� __class__s �rrDzStreamReaderProtocol.__init__�s���� ���d��#��$�%,�[�[��%?�D�"�%2�%D�%D�D�"�%)�D�"��*�#0�D��"'���"����� ����$7��!�����z�z�/�/�1��rc�<�|j�y|j�Sr)rirHs r�_stream_readerz#StreamReaderProtocol._stream_reader�s ���!�!�)���%�%�'�'rc��|j}|j}||_||_|j d�du|_y)N� sslcontext)r=r&rmro�get_extra_inforq)rCr(rr&s r�_replace_writerz$StreamReaderProtocol._replace_writer�s<���z�z���$�$� �$���#���"�1�1�,�?�t�K��rc�x����jrKddi}�jr�j|d<�jj|��j �y��_�j}|�|j���jd�du�_ �j��t��|�j��_�j|�j�}tj|�rA��fd�}�jj|��_�j j#|�d�_yy)N�messagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.�source_tracebackrxc����|j�r�j�y|j�}|�0�jj d|�d���j�yy)Nz*Unhandled exception in client_connected_cb)r|� exceptionr&)� cancelled�closerr=�call_exception_handler)�taskrTrCr&s ��r�callbackz6StreamReaderProtocol.connection_made.<locals>.callback�s\����~�~�'�!���)���.�.�*�C���� � �9�9�'S�),�)2�;�� "���)� 'r)rlrjr=r��abortrorv� set_transportryrqrprrmr�iscoroutine�create_taskrn�add_done_callbackrk)rCr&�contextr%�resr�s`` r�connection_madez$StreamReaderProtocol.connection_made�s#����"�"��@��G� �%�%�.2�.D�.D��*�+��J�J�-�-�g�6��O�O���#����$�$����� � ��+�"�1�1�,�?�t�K����$�$�0�".�y�$�/5�/3�z�z�#;�D���+�+�F�,0�,?�,?�A�C��%�%�c�*�*�"�Z�Z�3�3�C�8�� �� � �,�,�X�6�"&�D��/1rc�f��|j}|�$|�|j�n|j|�|jj �s9|�|jjd�n|jj|�t�|�|�d|_d|_ d|_ d|_yr)rv�feed_eofrRrrrKrLrfrUrirmrnro)rCrTr%rts �rrUz$StreamReaderProtocol.connection_lost s�����$�$�����{����!��$�$�S�)��|�|� � �"��{����'�'��-����*�*�3�/� ����$�!%���"����� ���rc�D�|j}|�|j|�yyr)rv� feed_data)rC�datar%s r� data_receivedz"StreamReaderProtocol.data_receiveds&���$�$�������T�"�rc�Z�|j}|�|j�|jryy)NFT)rvr�rq)rCr%s r�eof_receivedz!StreamReaderProtocol.eof_received!s,���$�$�����O�O���>�>��rc��|jSr)rrr^s rr`z&StreamReaderProtocol._get_close_waiter,s���|�|�rc�� |j}|j�r"|j�s|j�yyy#t$rYywxYwr)rrrKr�r�AttributeError)rC�closeds r�__del__zStreamReaderProtocol.__del__/sM�� #��\�\�F��{�{�}�V�%5�%5�%7�� � �"�&8�}��� �� �s�A� A �A �NN)rarbrcrjrD�propertyrvrzr�rUr�r�r`r�� __classcell__)rts@rrr�sN������2�(�(��(� L�('�T�$#� �� #rrc�x�eZdZ d�Zd�Zed��Zd�Zd�Zd�Z d�Z d�Zd �Zd �Z dd�Zd �Zdddd�d�Zd�Zy)rc��||_||_||_||_|jj �|_|j j d�yr)ro� _protocol�_readerr=rX� _complete_futrL)rCr&rr%rs rrDzStreamWriter.__init__EsI��#���!�������� �!�Z�Z�5�5�7������%�%�d�+rc���|jjd|j��g}|j�|j d|j���djdj |��S)N� transport=zreader=�<{}>� )rtraror�rY�format�join�rC�infos r�__repr__zStreamWriter.__repr__Os[�����'�'�:�d�o�o�5H�)I�J���<�<�#��K�K�'�$�,�,�!1�2�3��}�}�S�X�X�d�^�,�,rc��|jSr�rorHs rr&zStreamWriter.transportUs�����rc�:�|jj|�yr)ro�write�rCr�s rr�zStreamWriter.writeYs�������d�#rc�:�|jj|�yr)ro� writelinesr�s rr�zStreamWriter.writelines\s�����"�"�4�(rc�6�|jj�Sr)ro� write_eofrHs rr�zStreamWriter.write_eof_s�����(�(�*�*rc�6�|jj�Sr)ro� can_write_eofrHs rr�zStreamWriter.can_write_eofbs�����,�,�.�.rc�6�|jj�Sr)ror�rHs rr�zStreamWriter.closees�����$�$�&�&rc�6�|jj�Sr)ro� is_closingrHs rr�zStreamWriter.is_closinghs�����)�)�+�+rc��VK�|jj|��d{���y7��wr)r�r`rHs r�wait_closedzStreamWriter.wait_closedks�����n�n�.�.�t�4�4�4�s�)�'�)Nc�:�|jj||�Sr)rory)rC�name�defaults rryzStreamWriter.get_extra_infons�����-�-�d�G�<�<rc��K� |j�|jj�}|�|�|jj�rt d��d{���|j j ��d{���y7�'7��w)Nr)r�rror�rr�r[)rCrTs r�drainzStreamWriter.drainqso���� ��<�<�#��,�,�(�(�*�C���� ��?�?�%�%�'���(�N�N��n�n�*�*�,�,�,� ��,�s$�AB�A>�!B�8B�9B�B)�server_hostname�ssl_handshake_timeout�ssl_shutdown_timeoutc ��&K� |jjdu}|j}|j��d{���|jj |j ||||||���d{���}||_|j |�y7�Q7��w)N)�server_sider�r�r�)r�rpr�r=� start_tlsrorz)rCrxr�r�r�r�r� new_transports rr�zStreamWriter.start_tls�s����� B��n�n�9�9��E���>�>���j�j�l���"�j�j�2�2��O�O�X�z�#�_�"7�!5� 3�7�7� � (���� � ��&� ��7�s!�9B�B �3B�/B�0B�Bc��|jj�sc|jj�rt j dt�y|j�t j d|��t�yy)Nzloop is closedz unclosed )ror�r=� is_closed�warnings�warn�ResourceWarningr�rHs rr�zStreamWriter.__del__�sT�����)�)�+��z�z�#�#�%�� � �.��@�� � ��� � � �$��2�O�D�,rr)rarbrcrDr�r�r&r�r�r�r�r�r�r�ryr�r�r�rrrrr;sh���,�-�����$�)�+�/�'�,�5�=�-�4)-�.2�-1�'� Errc��eZdZdZedfd�Zd�Zd�Zd�Zd�Z d�Z d�Zd �Zd �Z d�Zd�Zd �Zdd�Zdd�Zd�Zd�Zd�Zy)rNc�l�|dkrtd��||_|�tj�|_n||_t�|_d|_d|_d|_ d|_ d|_|jj�r.tjtj d��|_yy)NrzLimit cannot be <= 0Fr)� ValueError�_limitr r<r=� bytearray�_buffer�_eof�_waiter� _exceptionror>rFr� extract_stack�sys� _getframerj)rCrrs rrDzStreamReader.__init__�s����A�:��3�4�4�����<��.�.�0�D�J��D�J� �{����� ��������������:�:���!�%3�%A�%A�� � �a� �&"�D�"�"rc��dg}|jr'|jt|j��d��|jr|jd�|jt k7r|jd|j���|jr|jd|j���|jr|jd|j���|jr|jd|j���|jr|jd�d jd j|��S)Nrz bytes�eofzlimit=zwaiter=z exception=r��pausedr�r�)r�rY�lenr�r��_DEFAULT_LIMITr�r�ror>r�r�r�s rr�zStreamReader.__repr__�s�������<�<��K�K�3�t�|�|�,�-�V�4�5��9�9��K�K����;�;�.�(��K�K�&���� �.�/��<�<��K�K�'�$�,�,�!1�2�3��?�?��K�K�*�T�_�_�$7�8�9��?�?��K�K�*�T�_�_�$7�8�9��<�<��K�K��!��}�}�S�X�X�d�^�,�,rc��|jSr)r�rHs rrzStreamReader.exception�s�����rc��||_|j}|�*d|_|j�s|j|�yyyr)r�r�r�rRrSs rrRzStreamReader.set_exception�sC������������D�L��#�#�%��$�$�S�)�&�rc�v� |j}|�*d|_|j�s|jd�yyyr)r�r�rLrMs r�_wakeup_waiterzStreamReader._wakeup_waiter�s?��?��������D�L��#�#�%��!�!�$�'�&�rc��||_yrr�)rCr&s rr�zStreamReader.set_transport�s ��#��rc��|jrEt|j�|jkr"d|_|jj�yyyr;)r>r�r�r�ro�resume_readingrHs r�_maybe_resume_transportz$StreamReader._maybe_resume_transport�s;���<�<�C����-����<� �D�L��O�O�*�*�,�=�<rc�2�d|_|j�yrQ)r�r�rHs rr�zStreamReader.feed_eof�s���� ����rc�:� |jxr |jSr)r�r�rHs r�at_eofzStreamReader.at_eof�s��K��y�y�-����-�-rc�P�|sy|jj|�|j�|j�V|jsIt|j�d|jzkDr# |jj�d|_yyyy#t$r d|_YywxYw)N�T) r��extendr�ror>r�r�� pause_readingr]r�s rr�zStreamReader.feed_data�s����������D�!������O�O�'��L�L��D�L�L�!�A����O�3� $����-�-�/� $���4�!� (�� '� '�#'��� '�s�-B�B%�$B%c��.K� |j�t|�d���|jr!d|_|jj �|j j �|_ |j�d{���d|_y7�#d|_wxYw�w)NzF() called while another coroutine is already waiting for incoming dataF)r��RuntimeErrorr>ror�r=rX)rC� func_names r�_wait_for_datazStreamReader._wait_for_data s����� ��<�<�#���+�4�5�6� 6��<�<� �D�L��O�O�*�*�,��z�z�/�/�1��� ��,�,����D�L� ���D�L�s0�A(B�+B �:B�;B �?B�B � B�Bc���K� d}t|�} |j|��d{���}|S7�#tj$r}|jcYd}~Sd}~wtj $r�}|jj||j�r|jd|j|z�=n|jj�|j�t|jd��d}~wwxYw�w)N� r) r�� readuntilr�IncompleteReadError�partial�LimitOverrunErrorr�� startswith�consumed�clearr�r��args)rC�sep�seplen�line�es r�readlinezStreamReader.readline%s����� ����S��� (�����,�,�D���-���-�-� ��9�9����+�+� (��|�|�&�&�s�A�J�J�7��L�L�!5�!�*�*�v�"5�!5�6����"�"�$��(�(�*��Q�V�V�A�Y�'�'�� (�sJ�C6�/�-�/�C6�/�C3�A� C3�C6�C3�)BC.�.C3�3C6c���K� t|�}|dk(rtd��|j�|j�d} t|j�}||z |k\rO|jj ||�}|dk7rn�|dz|z }||j kDrt jd|��|jrEt|j�}|jj�t j|d��|jd��d{�����||j kDrt jd|��|jd||z}|jd||z�=|j�t|�S7�i�w)Nrz,Separator should be at least one-byte string���rz2Separator is not found, and chunk exceed the limitr�z2Separator is found, but chunk is longer than limit)r�r�r�r��findr�rr�r��bytesr�r�r�r�)rC� separatorr��offset�buflen�isep�chunks rr�zStreamReader.readuntilDs���� �&�Y����Q�;��K�L�L��?�?�&��/�/�!�*�������&�F����&�(��|�|�(�(��F�;���2�:�� �!��f�,���D�K�K�'�$�6�6�L�� � ��y�y��d�l�l�+�����"�"�$� �4�4�U�D�A�A��%�%�k�2�2�2�=�@�$�+�+���.�.�D�d�L� L����^�d�V�m�,���L�L��$��-��(��$�$�&��U�|�� 3�s�D E7�E5�A*E7c���K� |j�|j�|dk(ry|dkrLg} |j|j��d{���}|sn|j|��8dj |�S|j s%|js|jd��d{���tt|j �d|�}|j d|�=|j�|S7��7�H�w)Nrr�read)r�r r�rYr�r�r�r�r� memoryviewr�)rC�n�blocks�blockr�s rr zStreamReader.read�s����� �*�?�?�&��/�/�!���6���q�5� �F��"�i�i����4�4����� � �e�$� � �8�8�F�#�#��|�|�D�I�I��%�%�f�-�-�-��Z����-�b�q�1�2���L�L��!����$�$�&���5�� .�s&�AC*�C&� AC*�C(� AC*�(C*c��K� |dkrtd��|j�|j�|dk(ryt|j�|kr�|jrEt|j�}|jj �tj||��|jd��d{���t|j�|kr��t|j�|k(r0t|j�}|jj �n0tt|j�d|�}|jd|�=|j�|S7���w)Nrz*readexactly size can not be less than zeror�readexactly)r�r�r�r�r�rr�rr�r�r r�)rCr� incompleter�s rrzStreamReader.readexactly�s���� � �q�5��I�J�J��?�?�&��/�/�!���6���$�,�,��!�#��y�y�"�4�<�<�0� ����"�"�$� �4�4�Z��C�C��%�%�m�4�4�4� �$�,�,��!�#��t�|�|���!�����&�D��L�L��� ���D�L�L�1�"�1�5�6�D����R�a�R� ��$�$�&��� 5�s�B-E�/E�0E� BEc��|SrrrHs r� __aiter__zStreamReader.__aiter__�s���rc��XK�|j��d{���}|dk(rt�|S7��w)Nr)r��StopAsyncIteration)rC�vals r� __anext__zStreamReader.__anext__�s+�����M�M�O�#���#�:�$�$�� �$�s�*�(�*)r�)r)rarbrcrjr�rDr�rrRr�r�r�r�r�r�r�r�r�r rrrrrrrr�sf����+�$�"�,-�$�*�(�$�-� �.�$�, �8�>Y�v1�f'�R�rrr�r)�__all__r?�socketr�r�rg�hasattr�rr rrr�logr�tasksrr�rrr r �Protocolr9rrrrrr�<module>rs���'��� � ��� �6�9���<�<�G����������� .��8A�+�A�B�6�9�� �)7� �D�&4�D�="�y�)�)�="�@D#�+�Y�-?�-?�D#�NeE�eE�N`�`r__pycache__/streams.cpython-312.pyc000064400000101130151706172560013143 0ustar00� T��h�k��l�dZddlZddlZddlZddlZddlZeed�redz ZddlmZddlm Z ddlm Z dd lmZdd lmZddl mZddlmZd Zded�d�Zded�d�Zeed�rded�d�Zded�d�ZGd�dej,�ZGd�deej,�ZGd�d�ZGd�d�Zy))�StreamReader�StreamWriter�StreamReaderProtocol�open_connection�start_server�N�AF_UNIX)�open_unix_connection�start_unix_server�)� coroutines)�events)� exceptions)�format_helpers)� protocols)�logger)�sleepi)�limitc���� K�tj�}t||��}t||��� |j� fd�||fi|���d{���\}}t|� ||�}||fS7��w)a�A wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) �r�loop�rc����S�N���protocols��(/usr/lib64/python3.12/asyncio/streams.py�<lambda>z!open_connection.<locals>.<lambda>1s����N)r �get_running_looprr�create_connectionr) �host�portr�kwdsr�reader� transport�_�writerrs @rrrsx�����&�"�"�$�D� ��D� 1�F�#�F��6�H�/��/�/��$��.�(,�.�.�L�I�q� �)�X�v�t� <�F��6�>��.�s�A A)� A'�A)c�����K�tj�����fd�}�j|||fi|���d{���S7��w)a�Start a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword argument is limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. c�>��t����}t|����}|S�Nrr�rr�r%r�client_connected_cbrrs ���r�factoryzstart_server.<locals>.factoryNs&����E��5��'��0C�-1�3���rN)r r � create_server)r.r"r#rr$r/rs` ` @rrr6s@�����,�"�"�$�D��$��#�#�G�T�4�@�4�@�@�@�@�s�4A�>�Ac����K�tj�}t||��}t||���|j�fd�|fi|���d{���\}}t|�||�}||fS7��w)z@Similar to `open_connection` but works with UNIX Domain Sockets.rrc����Srrrs�rrz&open_unix_connection.<locals>.<lambda>bs���HrN)r r rr�create_unix_connectionr) �pathrr$rr%r&r'r(rs @rr r Zsv������&�&�(���E��5��'��T�:��8�T�8�8��d�,�&*�,�,�� �1��i��6�4�@���v�~��,�s�A A(�A&� A(c�����K�tj�����fd�}�j||fi|���d{���S7��w)z=Similar to `start_server` but works with UNIX Domain Sockets.c�>��t����}t|����}|Sr+r,r-s ���rr/z"start_unix_server.<locals>.factoryks&���!��D�9�F�+�F�4G�15�7�H��OrN)r r �create_unix_server)r.r4rr$r/rs` ` @rr r fs>������&�&�(�� �-�T�,�,�W�d�C�d�C�C�C�C�s�3?�=�?c�6�eZdZdZd d�Zd�Zd�Zd�Zd�Zd�Z y) �FlowControlMixina)Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_writing() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. Nc��|�tj�|_n||_d|_t j �|_d|_y�NF)r �get_event_loop�_loop�_paused�collections�deque�_drain_waiters�_connection_lost)�selfrs r�__init__zFlowControlMixin.__init__~s>���<��.�.�0�D�J��D�J����)�/�/�1��� %��rc��|jrJ�d|_|jj�rtjd|�yy)NTz%r pauses writing)r>r=� get_debugr�debug�rCs r� pause_writingzFlowControlMixin.pause_writing�s:���<�<�������:�:���!��L�L�,�d�3�"rc���|jsJ�d|_|jj�rtjd|�|j D]$}|j �r�|jd��&y)NFz%r resumes writing)r>r=rFrrGrA�done� set_result�rC�waiters r�resume_writingzFlowControlMixin.resume_writing�s[���|�|��|�����:�:���!��L�L�-�t�4��)�)�F��;�;�=��!�!�$�'�*rc��d|_|jsy|jD]8}|j�r�|�|j d��(|j|��:y�NT)rBr>rArKrL� set_exception�rC�excrNs r�connection_lostz FlowControlMixin.connection_lost�sN�� $����|�|���)�)�F��;�;�=��;��%�%�d�+��(�(��-�*rc��NK�|jrtd��|jsy|jj �}|j j |� |�d{���|j j|�y7� #|j j|�wxYw�w)NzConnection lost)rB�ConnectionResetErrorr>r=� create_futurerA�append�removerMs r� _drain_helperzFlowControlMixin._drain_helper�s������ � �&�'8�9�9��|�|�����)�)�+�����"�"�6�*� /��L�L����&�&�v�.� �����&�&�v�.�s0�AB%�B�"B�#B�'B%�B�B"�"B%c��t�r)�NotImplementedError�rC�streams r�_get_close_waiterz"FlowControlMixin._get_close_waiter�s��!�!rr) �__name__� __module__�__qualname__�__doc__rDrIrOrUr[r`rrrr9r9ts%���&�4�(�.� /�"rr9c�f��eZdZdZdZd�fd� Zed��Zd�Zd�Z �fd�Z d�Zd �Zd �Z d�Z�xZS) ra=Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) Nc�4��t�|�|��|�,tj|�|_|j |_nd|_|�||_d|_d|_d|_ d|_ ||_d|_|jj�|_y)NrF)�superrD�weakref�ref�_stream_reader_wr�_source_traceback�_strong_reader�_reject_connection�_stream_writer�_task� _transport�_client_connected_cb� _over_sslr=rX�_closed)rC� stream_readerr.r� __class__s �rrDzStreamReaderProtocol.__init__�s���� ���d��#��$�%,�[�[��%?�D�"�%2�%D�%D�D�"�%)�D�"��*�#0�D��"'���"����� ����$7��!�����z�z�/�/�1��rc�<�|j�y|j�Sr)rjrHs r�_stream_readerz#StreamReaderProtocol._stream_reader�s ���!�!�)���%�%�'�'rc��|j}|j}||_||_|j d�du|_y)N� sslcontext)r=r&rnrp�get_extra_inforr)rCr(rr&s r�_replace_writerz$StreamReaderProtocol._replace_writer�s<���z�z���$�$� �$���#���"�1�1�,�?�t�K��rc�x����jrKddi}�jr�j|d<�jj|��j �y��_�j}|�|j���jd�du�_ �j��t��|�j��_�j|�j�}tj|�rA��fd�}�jj|��_�j j#|�d�_yy)N�messagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.�source_tracebackryc����|j�r�j�y|j�}|�0�jj d|�d���j�yy)Nz*Unhandled exception in client_connected_cb)r}� exceptionr&)� cancelled�closer�r=�call_exception_handler)�taskrTrCr&s ��r�callbackz6StreamReaderProtocol.connection_made.<locals>.callback�s\����~�~�'�!���)���.�.�*�C���� � �9�9�'S�),�)2�;�� "���)� 'r)rmrkr=r��abortrprw� set_transportrzrrrqrrnr�iscoroutine�create_taskro�add_done_callbackrl)rCr&�contextr%�resr�s`` r�connection_madez$StreamReaderProtocol.connection_made�s#����"�"��@��G� �%�%�.2�.D�.D��*�+��J�J�-�-�g�6��O�O���#����$�$����� � ��+�"�1�1�,�?�t�K����$�$�0�".�y�$�/5�/3�z�z�#;�D���+�+�F�,0�,?�,?�A�C��%�%�c�*�*�"�Z�Z�3�3�C�8�� �� � �,�,�X�6�"&�D��/1rc�f��|j}|�$|�|j�n|j|�|jj �s9|�|jjd�n|jj|�t�|�|�d|_d|_ d|_ d|_yr)rw�feed_eofrRrsrKrLrgrUrjrnrorp)rCrTr%rus �rrUz$StreamReaderProtocol.connection_lost s�����$�$�����{����!��$�$�S�)��|�|� � �"��{����'�'��-����*�*�3�/� ����$�!%���"����� ���rc�D�|j}|�|j|�yyr)rw� feed_data)rC�datar%s r� data_receivedz"StreamReaderProtocol.data_receiveds&���$�$�������T�"�rc�Z�|j}|�|j�|jryy)NFT)rwr�rr)rCr%s r�eof_receivedz!StreamReaderProtocol.eof_received!s,���$�$�����O�O���>�>��rc��|jSr)rsr^s rr`z&StreamReaderProtocol._get_close_waiter,s���|�|�rc�� |j}|j�r"|j�s|j�yyy#t$rYywxYwr)rsrKr�r��AttributeError)rC�closeds r�__del__zStreamReaderProtocol.__del__/sM�� #��\�\�F��{�{�}�V�%5�%5�%7�� � �"�&8�}��� �� �s�A� A �A �NN)rarbrcrdrkrD�propertyrwr{r�rUr�r�r`r�� __classcell__)rus@rrr�sN������2�(�(��(� L�('�T�$#� �� #rrc�z�eZdZdZd�Zd�Zed��Zd�Zd�Z d�Z d�Zd �Zd �Z d�Zdd �Zd�Zdddd�d�Zd�Zy)ra'Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. c���||_||_|�t|t�sJ�||_||_|j j �|_|jjd�yr) rp� _protocol� isinstancer�_readerr=rX� _complete_futrL)rCr&rr%rs rrDzStreamWriter.__init__Es[��#���!����~��F�L�!A�A�A������ �!�Z�Z�5�5�7������%�%�d�+rc���|jjd|j��g}|j�|j d|j���djdj |��S)N� transport=zreader=�<{}>� )rurarpr�rY�format�join�rC�infos r�__repr__zStreamWriter.__repr__Os[�����'�'�:�d�o�o�5H�)I�J���<�<�#��K�K�'�$�,�,�!1�2�3��}�}�S�X�X�d�^�,�,rc��|jSr�rprHs rr&zStreamWriter.transportUs�����rc�:�|jj|�yr)rp�write�rCr�s rr�zStreamWriter.writeYs�������d�#rc�:�|jj|�yr)rp� writelinesr�s rr�zStreamWriter.writelines\s�����"�"�4�(rc�6�|jj�Sr)rp� write_eofrHs rr�zStreamWriter.write_eof_s�����(�(�*�*rc�6�|jj�Sr)rp� can_write_eofrHs rr�zStreamWriter.can_write_eofbs�����,�,�.�.rc�6�|jj�Sr)rpr�rHs rr�zStreamWriter.closees�����$�$�&�&rc�6�|jj�Sr)rp� is_closingrHs rr�zStreamWriter.is_closinghs�����)�)�+�+rc��VK�|jj|��d{���y7��wr)r�r`rHs r�wait_closedzStreamWriter.wait_closedks�����n�n�.�.�t�4�4�4�s�)�'�)Nc�:�|jj||�Sr)rprz)rC�name�defaults rrzzStreamWriter.get_extra_infons�����-�-�d�G�<�<rc��K�|j�|jj�}|�|�|jj�rt d��d{���|j j ��d{���y7�'7��w)zyFlush the write buffer. The intended use is to write w.write(data) await w.drain() Nr)r�r�rpr�rr�r[)rCrTs r�drainzStreamWriter.drainqsj�����<�<�#��,�,�(�(�*�C���� ��?�?�%�%�'���(�N�N��n�n�*�*�,�,�,� ��,�s$�AB�A=�!B�7A?�8B�?B)�server_hostname�ssl_handshake_timeout�ssl_shutdown_timeoutc ��$K�|jjdu}|j}|j��d{���|jj |j ||||||���d{���}||_|j |�y7�Q7��w)z3Upgrade an existing stream-based connection to TLS.N)�server_sider�r�r�)r�rqr�r=� start_tlsrpr{)rCryr�r�r�r�r� new_transports rr�zStreamWriter.start_tls�s����� �n�n�9�9��E���>�>���j�j�l���"�j�j�2�2��O�O�X�z�#�_�"7�!5� 3�7�7� � (���� � ��&� ��7�s!�8B�B�3B�.B�/B�Bc��|jj�sc|jj�rt j dt�y|j�t j d|��t�yy)Nzloop is closedz unclosed )rpr�r=� is_closed�warnings�warn�ResourceWarningr�rHs rr�zStreamWriter.__del__�sT�����)�)�+��z�z�#�#�%�� � �.��@�� � ��� � � �$��2�O�D�,rr)rarbrcrdrDr�r�r&r�r�r�r�r�r�r�rzr�r�r�rrrrr;sh���,�-�����$�)�+�/�'�,�5�=�-�4)-�.2�-1�'� Errc��eZdZdZedfd�Zd�Zd�Zd�Zd�Z d�Z d�Zd �Zd �Z d�Zd�Zd �Zdd�Zdd�Zd�Zd�Zd�Zy)rNc�l�|dkrtd��||_|�tj�|_n||_t�|_d|_d|_d|_ d|_ d|_|jj�r.tjtj d��|_yy)NrzLimit cannot be <= 0Fr)� ValueError�_limitr r<r=� bytearray�_buffer�_eof�_waiter� _exceptionrpr>rFr� extract_stack�sys� _getframerk)rCrrs rrDzStreamReader.__init__�s����A�:��3�4�4�����<��.�.�0�D�J��D�J� �{����� ��������������:�:���!�%3�%A�%A�� � �a� �&"�D�"�"rc��dg}|jr'|jt|j��d��|jr|jd�|jt k7r|jd|j���|jr|jd|j���|jr|jd|j���|jr|jd|j���|jr|jd�d jd j|��S)Nrz bytes�eofzlimit=zwaiter=z exception=r��pausedr�r�)r�rY�lenr�r��_DEFAULT_LIMITr�r�rpr>r�r�r�s rr�zStreamReader.__repr__�s�������<�<��K�K�3�t�|�|�,�-�V�4�5��9�9��K�K����;�;�.�(��K�K�&���� �.�/��<�<��K�K�'�$�,�,�!1�2�3��?�?��K�K�*�T�_�_�$7�8�9��?�?��K�K�*�T�_�_�$7�8�9��<�<��K�K��!��}�}�S�X�X�d�^�,�,rc��|jSr)r�rHs rr�zStreamReader.exception�s�����rc��||_|j}|�*d|_|j�s|j|�yyyr)r�r�r�rRrSs rrRzStreamReader.set_exception�sC������������D�L��#�#�%��$�$�S�)�&�rc�t�|j}|�*d|_|j�s|jd�yyy)z1Wakeup read*() functions waiting for data or EOF.N)r�r�rLrMs r�_wakeup_waiterzStreamReader._wakeup_waiter�s<���������D�L��#�#�%��!�!�$�'�&�rc�8�|j�Jd��||_y)NzTransport already setr�)rCr&s rr�zStreamReader.set_transport�s�����&�?�(?�?�&�#��rc��|jrEt|j�|jkr"d|_|jj�yyyr;)r>r�r�r�rp�resume_readingrHs r�_maybe_resume_transportz$StreamReader._maybe_resume_transport�s;���<�<�C����-����<� �D�L��O�O�*�*�,�=�<rc�2�d|_|j�yrQ)r�r�rHs rr�zStreamReader.feed_eof�s���� ����rc�8�|jxr |jS)z=Return True if the buffer is empty and 'feed_eof' was called.)r�r�rHs r�at_eofzStreamReader.at_eof�s���y�y�-����-�-rc�v�|jrJd��|sy|jj|�|j�|j�V|j sIt |j�d|jzkDr# |jj�d|_yyyy#t$r d|_YywxYw)Nzfeed_data after feed_eof�T) r�r��extendr�rpr>r�r�� pause_readingr]r�s rr�zStreamReader.feed_data�s����9�9�8�8�8�}��������D�!������O�O�'��L�L��D�L�L�!�A����O�3� $����-�-�/� $���4�!� (�� '� '�#'��� '�s�B%�%B8�7B8c��RK�|j�t|�d���|jrJd��|jr!d|_|jj�|jj�|_ |j�d{���d|_y7�#d|_wxYw�w)zpWait until feed_data() or feed_eof() is called. If stream was paused, automatically resume it. NzF() called while another coroutine is already waiting for incoming dataz_wait_for_data after EOFF)r��RuntimeErrorr�r>rpr�r=rX)rC� func_names r�_wait_for_datazStreamReader._wait_for_data s������<�<�#���+�4�5�6� 6��9�9�8�8�8�}��<�<� �D�L��O�O�*�*�,��z�z�/�/�1��� ��,�,����D�L� ���D�L�s0�A:B'�=B�B� B�B'�B� B$�$B'c���K�d}t|�} |j|��d{���}|S7�#tj$r}|jcYd}~Sd}~wtj $r�}|jj||j�r|jd|j|z�=n|jj�|j�t|jd��d}~wwxYw�w)a�Read chunk of data from the stream until newline (b' ') is found. On success, return chunk that ends with newline. If only partial line can be read due to EOF, return incomplete line without terminating newline. When EOF was reached while no bytes read, empty bytes object is returned. If limit is reached, ValueError will be raised. In that case, if newline was found, complete line including newline will be removed from internal buffer. Else, internal buffer will be cleared. Limit is compared against part of the line without newline. If stream was paused, this function will automatically resume it if needed. � Nr) r�� readuntilr�IncompleteReadError�partial�LimitOverrunErrorr�� startswith�consumed�clearr�r��args)rC�sep�seplen�line�es r�readlinezStreamReader.readline%s����� ���S��� (�����,�,�D���-���-�-� ��9�9����+�+� (��|�|�&�&�s�A�J�J�7��L�L�!5�!�*�*�v�"5�!5�6����"�"�$��(�(�*��Q�V�V�A�Y�'�'�� (�sJ�C5�.�,�.�C5�.�C2�A�C2� C5�C2�(BC-�-C2�2C5c���K�t|�}|dk(rtd��|j�|j�d} t|j�}||z |k\rO|jj ||�}|dk7rn�|dz|z }||j kDrt jd|��|jrEt|j�}|jj�t j|d��|jd��d{�����||j kDrt jd|��|jd||z}|jd||z�=|j�t|�S7�i�w) aVRead data from the stream until ``separator`` is found. On success, the data and separator will be removed from the internal buffer (consumed). Returned data will include the separator at the end. Configured stream limit is used to check result. Limit sets the maximal length of data that can be returned, not counting the separator. If an EOF occurs and the complete separator is still not found, an IncompleteReadError exception will be raised, and the internal buffer will be reset. The IncompleteReadError.partial attribute may contain the separator partially. If the data cannot be read because of over limit, a LimitOverrunError exception will be raised, and the data will be left in the internal buffer, so it can be read again. rz,Separator should be at least one-byte stringN���rz2Separator is not found, and chunk exceed the limitr�z2Separator is found, but chunk is longer than limit)r�r�r�r��findr�rr�r��bytesr�r�r�r�)rC� separatorr��offset�buflen�isep�chunks rr�zStreamReader.readuntilDsz����(�Y����Q�;��K�L�L��?�?�&��/�/�!�*�������&�F����&�(��|�|�(�(��F�;���2�:�� �!��f�,���D�K�K�'�$�6�6�L�� � ��y�y��d�l�l�+�����"�"�$� �4�4�U�D�A�A��%�%�k�2�2�2�=�@�$�+�+���.�.�D�d�L� L����^�d�V�m�,���L�L��$��-��(��$�$�&��U�|�� 3�s�DE6� E4�A*E6c���K�|j�|j�|dk(ry|dkrLg} |j|j��d{���}|sn|j|��8dj |�S|j s%|js|jd��d{���tt|j �d|�}|j d|�=|j�|S7��7�H�w)a�Read up to `n` bytes from the stream. If `n` is not provided or set to -1, read until EOF, then return all read bytes. If EOF was received and the internal buffer is empty, return an empty bytes object. If `n` is 0, return an empty bytes object immediately. If `n` is positive, return at most `n` available bytes as soon as at least 1 byte is available in the internal buffer. If EOF is received before any byte is read, return an empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. Nrr�read)r�rr�rYr�r�r�r�r� memoryviewr�)rC�n�blocks�blockr�s rrzStreamReader.read�s�����,�?�?�&��/�/�!���6���q�5� �F��"�i�i����4�4����� � �e�$� � �8�8�F�#�#��|�|�D�I�I��%�%�f�-�-�-��Z����-�b�q�1�2���L�L��!����$�$�&���5�� .�s&�AC)�C%�AC)�C'�AC)�'C)c��K�|dkrtd��|j�|j�|dk(ryt|j�|kr�|jrEt|j�}|jj �tj||��|jd��d{���t|j�|kr��t|j�|k(r0t|j�}|jj �n0tt|j�d|�}|jd|�=|j�|S7���w)a�Read exactly `n` bytes. Raise an IncompleteReadError if EOF is reached before `n` bytes can be read. The IncompleteReadError.partial attribute of the exception will contain the partial read bytes. if n is zero, return empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. rz*readexactly size can not be less than zeroNr�readexactly)r�r�r�r�r�rr�rr�r�rr�)rCr � incompleter�s rrzStreamReader.readexactly�s���� �q�5��I�J�J��?�?�&��/�/�!���6���$�,�,��!�#��y�y�"�4�<�<�0� ����"�"�$� �4�4�Z��C�C��%�%�m�4�4�4� �$�,�,��!�#��t�|�|���!�����&�D��L�L��� ���D�L�L�1�"�1�5�6�D����R�a�R� ��$�$�&��� 5�s�B,E�.E�/E�BEc��|SrrrHs r� __aiter__zStreamReader.__aiter__�s���rc��XK�|j��d{���}|dk(rt�|S7��w)Nr)r�StopAsyncIteration)rC�vals r� __anext__zStreamReader.__anext__�s+�����M�M�O�#���#�:�$�$�� �$�s�*�(�*)r�)r)rarbrcrkr�rDr�r�rRr�r�r�r�r�r�r�rr�rrrrrrrrr�sf����+�$�"�,-�$�*�(�$�-� �.�$�, �8�>Y�v1�f'�R�rrr�r)�__all__r?�socketr�r�rh�hasattr�rr rrr�logr�tasksrr�rrr r �Protocolr9rrrrrr�<module>r s���'��� � ��� �6�9���<�<�G����������� .��8A�+�A�B�6�9�� �)7� �D�&4�D�="�y�)�)�="�@D#�+�Y�-?�-?�D#�NeE�eE�N`�`r__pycache__/subprocess.cpython-312.opt-1.pyc000064400000027451151706172560014631 0ustar00� T��h9��2�dZddlZddlmZddlmZddlmZddlmZddlmZejZ ejZ ejZGd �d ejej�ZGd�d�Zdddej fd �Zdddej d�d�Zy))�create_subprocess_exec�create_subprocess_shell�N�)�events)� protocols)�streams)�tasks)�loggerc�L��eZdZdZ�fd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Z�xZS) �SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.c����t�|�|��||_dx|_x|_|_d|_d|_g|_|jj�|_y)N)�loopF)�super�__init__�_limit�stdin�stdout�stderr� _transport�_process_exited� _pipe_fds�_loop� create_future� _stdin_closed)�self�limitr� __class__s ��+/usr/lib64/python3.12/asyncio/subprocess.pyrz!SubprocessStreamProtocol.__init__sZ��� ���d��#����15�5�� �5�T�[�4�;����$������!�Z�Z�5�5�7���c�l�|jjg}|j�|jd|j���|j�|jd|j���|j �|jd|j ���dj dj|��S)Nzstdin=zstdout=zstderr=z<{}>� )r�__name__r�appendrr�format�join)r�infos r�__repr__z!SubprocessStreamProtocol.__repr__s������'�'�(���:�:�!��K�K�&�����/�0��;�;�"��K�K�'�$�+�+��1�2��;�;�"��K�K�'�$�+�+��1�2��}�}�S�X�X�d�^�,�,rc�n�||_|jd�}|�ftj|j|j ��|_|jj|�|jjd�|jd�}|�ftj|j|j ��|_ |jj|�|jjd�|jd�}|�)tj||d|j ��|_yy)Nr�rr�r)�protocol�readerr) r�get_pipe_transportr�StreamReaderrrr� set_transportrr#r�StreamWriterr)r� transport�stdout_transport�stderr_transport�stdin_transports r�connection_madez(SubprocessStreamProtocol.connection_made(s���#���$�7�7��:���'�!�.�.�T�[�[�48�J�J�@�D�K��K�K�%�%�&6�7��N�N�!�!�!�$�$�7�7��:���'�!�.�.�T�[�[�48�J�J�@�D�K��K�K�%�%�&6�7��N�N�!�!�!�$�#�6�6�q�9���&� �-�-�o�7;�59�37�:�:�?�D�J�'rc�x�|dk(r |j}n|dk(r |j}nd}|�|j|�yy�Nrr*)rr� feed_data)r�fd�datar,s r�pipe_data_receivedz+SubprocessStreamProtocol.pipe_data_received@s@�� ��7��[�[�F� �1�W��[�[�F��F������T�"�rc��|dk(rz|j}|�|j�|j|�|�|jj d�y|jj|�d|j_y|dk(r |j}n|dk(r |j}nd}|�$|�|j�n|j|�||jvr|jj|�|j�y)NrFrr*) r�close�connection_lostr� set_result� set_exception�_log_tracebackrr�feed_eofr�remove�_maybe_close_transport)rr9�exc�piper,s r�pipe_connection_lostz-SubprocessStreamProtocol.pipe_connection_lostJs��� ��7��:�:�D���� � ��� � ��%��{��"�"�-�-�d�3� � �"�"�0�0��5�5:��"�"�1�� ��7��[�[�F� �1�W��[�[�F��F����{����!��$�$�S�)� ������N�N�!�!�"�%��#�#�%rc�2�d|_|j�y)NT)rrD�rs r�process_exitedz'SubprocessStreamProtocol.process_exitedhs��#����#�#�%rc��t|j�dk(r/|jr"|jj �d|_yyy)Nr)�lenrrrr=rIs rrDz/SubprocessStreamProtocol._maybe_close_transportls:���t�~�~��!�#��(<�(<��O�O�!�!�#�"�D�O�)=�#rc�8�||jur|jSy�N)rr)r�streams r�_get_close_waiterz*SubprocessStreamProtocol._get_close_waiterqs���T�Z�Z���%�%�%� r) r"� __module__�__qualname__�__doc__rr'r5r;rGrJrDrP� __classcell__)rs@rrrs.���:�8�-�?�0#�&�<&�#� &rrc�Z�eZdZd�Zd�Zed��Zd�Zd�Zd�Z d�Z d�Zd �Zd �Z d d�Zy)�Processc��||_||_||_|j|_|j|_|j |_|j �|_yrN)r� _protocolrrrr�get_pid�pid)rr1r+rs rrzProcess.__init__wsH��#���!����� ��^�^�� ��o�o����o�o����$�$�&��rc�P�d|jj�d|j�d�S)N�<r!�>)rr"rZrIs rr'zProcess.__repr__�s&���4�>�>�*�*�+�1�T�X�X�J�a�8�8rc�6�|jj�SrN)r�get_returncoderIs r� returncodezProcess.returncode�s�����-�-�/�/rc��RK�|jj��d{���S7��w)z?Wait until the process exit and return the process return code.N)r�_waitrIs r�waitzProcess.wait�s�����_�_�*�*�,�,�,�,�s�'�%�'c�:�|jj|�yrN)r�send_signal)r�signals rrezProcess.send_signal�s�����#�#�F�+rc�8�|jj�yrN)r� terminaterIs rrhzProcess.terminate�s�����!�!�#rc�8�|jj�yrN)r�killrIs rrjzProcess.kill�s�������rc���K�|jj�} |�=|jj|�|r t j d|t |��|jj��d{���|rt j d|�|jj�y7�7#ttf$r#}|rt j d||�Yd}~�bd}~wwxYw�w)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin)r� get_debugr�writer �debugrL�drain�BrokenPipeError�ConnectionResetErrorr=)r�inputrnrEs r�_feed_stdinzProcess._feed_stdin�s������ � �$�$�&�� H�� �� � � � ��'���L�L�?��s�5�z�S��*�*�"�"�$�$�$���L�L�6��=�� � ���� %���!5�6� H�����;�T�3�G��� H�sA�C)�AB4�:B2�;B4�?3C)�2B4�4C&�C!�C)�!C&�&C)c��K�y�wrN�rIs r�_noopz Process._noop�s �����s�c��K�|jj|�}|dk(r |j}n|j}|jj�r |dk(rdnd}t jd||�|j��d{���}|jj�r |dk(rdnd}t jd||�|j�|S7�P�w)Nr*rrrz%r communicate: read %sz%r communicate: close %s) rr-rrrrlr rn�readr=)rr9r1rO�name�outputs r�_read_streamzProcess._read_stream�s������O�O�6�6�r�:� � ��7��[�[�F��[�[�F��:�:���!�!�Q�w�8�H�D��L�L�2�D�$�?��{�{�}�$���:�:���!�!�Q�w�8�H�D��L�L�3�T�4�@������ �%�s�BC� C� ACNc��K�|j�|j|�}n|j�}|j�|j d�}n|j�}|j �|j d�}n|j�}t j|||��d{���\}}}|j��d{���||fS7�$7� �wr7) rrsrvrr{rr �gatherrc)rrrrrrs r�communicatezProcess.communicate�s������:�:�!��$�$�U�+�E��J�J�L�E��;�;�"��&�&�q�)�F��Z�Z�\�F��;�;�"��&�&�q�)�F��Z�Z�\�F�&+�l�l�5�&�&�&I� I���v�v��i�i�k�������!J���s$�B%C�'C�(C�C� C�CrN)r"rQrRrr'�propertyr`rcrerhrjrsrvr{r~rurrrVrVvsH��'�9��0��0�-�,�$���(��" rrVc���� K�tj�� �� fd�}� j||f|||d�|���d{���\}}t||� �S7��w)Nc���t����S�Nr)�rr)s��r�<lambda>z)create_subprocess_shell.<locals>.<lambda>�����7�e�=A� Cr�rrr)r�get_running_loop�subprocess_shellrV) �cmdrrrr�kwds�protocol_factoryr1r+rs ` @rrr�sm������"�"�$�D�C�� 5�� 5� 5���!����!��!���I�x��9�h��-�-� �s�6A�A�A)rrrrc���� K�tj�� �� fd�}� j||g|��|||d�|���d{���\}} t|| � �S7��w)Nc���t����Sr�r�r)s��rr�z(create_subprocess_exec.<locals>.<lambda>�r�rr�)rr��subprocess_execrV)�programrrrr�argsr�r�r1r+rs ` @rrr�sy������"�"�$�D�C�� 4�� 4� 4���!��!��F�� !�� !���I�x� �9�h��-�-��s�9A�A�A)�__all__� subprocess�rrrr �logr �PIPE�STDOUT�DEVNULL�FlowControlMixin�SubprocessProtocolrrV�_DEFAULT_LIMITrrrurr�<module>r�s��� =������������ � � �� � � ��b&�w�7�7�(�;�;�b&�JU �U �p.2�$�t�(/�(>�(>� .�8<�D�(,�G�4J�4J�.r__pycache__/subprocess.cpython-312.opt-2.pyc000064400000027262151706172560014632 0ustar00� T��h9��2�dZddlZddlmZddlmZddlmZddlmZddlmZejZ ejZ ejZGd �d ejej�ZGd�d�Zdddej fd �Zdddej d�d�Zy))�create_subprocess_exec�create_subprocess_shell�N�)�events)� protocols)�streams)�tasks)�loggerc�J��eZdZ �fd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z �xZS) �SubprocessStreamProtocolc����t�|�|��||_dx|_x|_|_d|_d|_g|_|jj�|_y)N)�loopF)�super�__init__�_limit�stdin�stdout�stderr� _transport�_process_exited� _pipe_fds�_loop� create_future� _stdin_closed)�self�limitr� __class__s ��+/usr/lib64/python3.12/asyncio/subprocess.pyrz!SubprocessStreamProtocol.__init__sZ��� ���d��#����15�5�� �5�T�[�4�;����$������!�Z�Z�5�5�7���c�l�|jjg}|j�|jd|j���|j�|jd|j���|j �|jd|j ���dj dj|��S)Nzstdin=zstdout=zstderr=z<{}>� )r�__name__r�appendrr�format�join)r�infos r�__repr__z!SubprocessStreamProtocol.__repr__s������'�'�(���:�:�!��K�K�&�����/�0��;�;�"��K�K�'�$�+�+��1�2��;�;�"��K�K�'�$�+�+��1�2��}�}�S�X�X�d�^�,�,rc�n�||_|jd�}|�ftj|j|j ��|_|jj|�|jjd�|jd�}|�ftj|j|j ��|_ |jj|�|jjd�|jd�}|�)tj||d|j ��|_yy)Nr�rr�r)�protocol�readerr) r�get_pipe_transportr�StreamReaderrrr� set_transportrr#r�StreamWriterr)r� transport�stdout_transport�stderr_transport�stdin_transports r�connection_madez(SubprocessStreamProtocol.connection_made(s���#���$�7�7��:���'�!�.�.�T�[�[�48�J�J�@�D�K��K�K�%�%�&6�7��N�N�!�!�!�$�$�7�7��:���'�!�.�.�T�[�[�48�J�J�@�D�K��K�K�%�%�&6�7��N�N�!�!�!�$�#�6�6�q�9���&� �-�-�o�7;�59�37�:�:�?�D�J�'rc�x�|dk(r |j}n|dk(r |j}nd}|�|j|�yy�Nrr*)rr� feed_data)r�fd�datar,s r�pipe_data_receivedz+SubprocessStreamProtocol.pipe_data_received@s@�� ��7��[�[�F� �1�W��[�[�F��F������T�"�rc��|dk(rz|j}|�|j�|j|�|�|jj d�y|jj|�d|j_y|dk(r |j}n|dk(r |j}nd}|�$|�|j�n|j|�||jvr|jj|�|j�y)NrFrr*) r�close�connection_lostr� set_result� set_exception�_log_tracebackrr�feed_eofr�remove�_maybe_close_transport)rr9�exc�piper,s r�pipe_connection_lostz-SubprocessStreamProtocol.pipe_connection_lostJs��� ��7��:�:�D���� � ��� � ��%��{��"�"�-�-�d�3� � �"�"�0�0��5�5:��"�"�1�� ��7��[�[�F� �1�W��[�[�F��F����{����!��$�$�S�)� ������N�N�!�!�"�%��#�#�%rc�2�d|_|j�y)NT)rrD�rs r�process_exitedz'SubprocessStreamProtocol.process_exitedhs��#����#�#�%rc��t|j�dk(r/|jr"|jj �d|_yyy)Nr)�lenrrrr=rIs rrDz/SubprocessStreamProtocol._maybe_close_transportls:���t�~�~��!�#��(<�(<��O�O�!�!�#�"�D�O�)=�#rc�8�||jur|jSy�N)rr)r�streams r�_get_close_waiterz*SubprocessStreamProtocol._get_close_waiterqs���T�Z�Z���%�%�%� r)r"� __module__�__qualname__rr'r5r;rGrJrDrP� __classcell__)rs@rrrs.���:�8�-�?�0#�&�<&�#� &rrc�Z�eZdZd�Zd�Zed��Zd�Zd�Zd�Z d�Z d�Zd �Zd �Z d d�Zy)�Processc��||_||_||_|j|_|j|_|j |_|j �|_yrN)r� _protocolrrrr�get_pid�pid)rr1r+rs rrzProcess.__init__wsH��#���!����� ��^�^�� ��o�o����o�o����$�$�&��rc�P�d|jj�d|j�d�S)N�<r!�>)rr"rYrIs rr'zProcess.__repr__�s&���4�>�>�*�*�+�1�T�X�X�J�a�8�8rc�6�|jj�SrN)r�get_returncoderIs r� returncodezProcess.returncode�s�����-�-�/�/rc��TK� |jj��d{���S7��wrN)r�_waitrIs r�waitzProcess.wait�s"����M��_�_�*�*�,�,�,�,�s�(�&�(c�:�|jj|�yrN)r�send_signal)r�signals rrdzProcess.send_signal�s�����#�#�F�+rc�8�|jj�yrN)r� terminaterIs rrgzProcess.terminate�s�����!�!�#rc�8�|jj�yrN)r�killrIs rrizProcess.kill�s�������rc���K�|jj�} |�=|jj|�|r t j d|t |��|jj��d{���|rt j d|�|jj�y7�7#ttf$r#}|rt j d||�Yd}~�bd}~wwxYw�w)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin)r� get_debugr�writer �debugrL�drain�BrokenPipeError�ConnectionResetErrorr=)r�inputrmrEs r�_feed_stdinzProcess._feed_stdin�s������ � �$�$�&�� H�� �� � � � ��'���L�L�?��s�5�z�S��*�*�"�"�$�$�$���L�L�6��=�� � ���� %���!5�6� H�����;�T�3�G��� H�sA�C)�AB4�:B2�;B4�?3C)�2B4�4C&�C!�C)�!C&�&C)c��K�y�wrN�rIs r�_noopz Process._noop�s �����s�c��K�|jj|�}|dk(r |j}n|j}|jj�r |dk(rdnd}t jd||�|j��d{���}|jj�r |dk(rdnd}t jd||�|j�|S7�P�w)Nr*rrrz%r communicate: read %sz%r communicate: close %s) rr-rrrrkr rm�readr=)rr9r1rO�name�outputs r�_read_streamzProcess._read_stream�s������O�O�6�6�r�:� � ��7��[�[�F��[�[�F��:�:���!�!�Q�w�8�H�D��L�L�2�D�$�?��{�{�}�$���:�:���!�!�Q�w�8�H�D��L�L�3�T�4�@������ �%�s�BC� C� ACNc��K�|j�|j|�}n|j�}|j�|j d�}n|j�}|j �|j d�}n|j�}t j|||��d{���\}}}|j��d{���||fS7�$7� �wr7) rrrrurrzrr �gatherrb)rrqrrrs r�communicatezProcess.communicate�s������:�:�!��$�$�U�+�E��J�J�L�E��;�;�"��&�&�q�)�F��Z�Z�\�F��;�;�"��&�&�q�)�F��Z�Z�\�F�&+�l�l�5�&�&�&I� I���v�v��i�i�k�������!J���s$�B%C�'C�(C�C� C�CrN)r"rQrRrr'�propertyr_rbrdrgrirrrurzr}rtrrrUrUvsH��'�9��0��0�-�,�$���(��" rrUc���� K�tj�� �� fd�}� j||f|||d�|���d{���\}}t||� �S7��w)Nc���t����S�Nr)�rr)s��r�<lambda>z)create_subprocess_shell.<locals>.<lambda>�����7�e�=A� Cr�rrr)r�get_running_loop�subprocess_shellrU) �cmdrrrr�kwds�protocol_factoryr1r+rs ` @rrr�sm������"�"�$�D�C�� 5�� 5� 5���!����!��!���I�x��9�h��-�-� �s�6A�A�A)rrrrc���� K�tj�� �� fd�}� j||g|��|||d�|���d{���\}} t|| � �S7��w)Nc���t����Sr�r�r)s��rr�z(create_subprocess_exec.<locals>.<lambda>�r�rr�)rr��subprocess_execrU)�programrrrr�argsr�r�r1r+rs ` @rrr�sy������"�"�$�D�C�� 4�� 4� 4���!��!��F�� !�� !���I�x� �9�h��-�-��s�9A�A�A)�__all__� subprocess�rrrr �logr �PIPE�STDOUT�DEVNULL�FlowControlMixin�SubprocessProtocolrrU�_DEFAULT_LIMITrrrtrr�<module>r�s��� =������������ � � �� � � ��b&�w�7�7�(�;�;�b&�JU �U �p.2�$�t�(/�(>�(>� .�8<�D�(,�G�4J�4J�.r__pycache__/subprocess.cpython-312.pyc000064400000027500151706172560013665 0ustar00� T��h9��2�dZddlZddlmZddlmZddlmZddlmZddlmZejZ ejZ ejZGd �d ejej�ZGd�d�Zdddej fd �Zdddej d�d�Zy))�create_subprocess_exec�create_subprocess_shell�N�)�events)� protocols)�streams)�tasks)�loggerc�L��eZdZdZ�fd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Z�xZS) �SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.c����t�|�|��||_dx|_x|_|_d|_d|_g|_|jj�|_y)N)�loopF)�super�__init__�_limit�stdin�stdout�stderr� _transport�_process_exited� _pipe_fds�_loop� create_future� _stdin_closed)�self�limitr� __class__s ��+/usr/lib64/python3.12/asyncio/subprocess.pyrz!SubprocessStreamProtocol.__init__sZ��� ���d��#����15�5�� �5�T�[�4�;����$������!�Z�Z�5�5�7���c�l�|jjg}|j�|jd|j���|j�|jd|j���|j �|jd|j ���dj dj|��S)Nzstdin=zstdout=zstderr=z<{}>� )r�__name__r�appendrr�format�join)r�infos r�__repr__z!SubprocessStreamProtocol.__repr__s������'�'�(���:�:�!��K�K�&�����/�0��;�;�"��K�K�'�$�+�+��1�2��;�;�"��K�K�'�$�+�+��1�2��}�}�S�X�X�d�^�,�,rc�n�||_|jd�}|�ftj|j|j ��|_|jj|�|jjd�|jd�}|�ftj|j|j ��|_ |jj|�|jjd�|jd�}|�)tj||d|j ��|_yy)Nr�rr�r)�protocol�readerr) r�get_pipe_transportr�StreamReaderrrr� set_transportrr#r�StreamWriterr)r� transport�stdout_transport�stderr_transport�stdin_transports r�connection_madez(SubprocessStreamProtocol.connection_made(s���#���$�7�7��:���'�!�.�.�T�[�[�48�J�J�@�D�K��K�K�%�%�&6�7��N�N�!�!�!�$�$�7�7��:���'�!�.�.�T�[�[�48�J�J�@�D�K��K�K�%�%�&6�7��N�N�!�!�!�$�#�6�6�q�9���&� �-�-�o�7;�59�37�:�:�?�D�J�'rc�x�|dk(r |j}n|dk(r |j}nd}|�|j|�yy�Nrr*)rr� feed_data)r�fd�datar,s r�pipe_data_receivedz+SubprocessStreamProtocol.pipe_data_received@s@�� ��7��[�[�F� �1�W��[�[�F��F������T�"�rc��|dk(rz|j}|�|j�|j|�|�|jj d�y|jj|�d|j_y|dk(r |j}n|dk(r |j}nd}|�$|�|j�n|j|�||jvr|jj|�|j�y)NrFrr*) r�close�connection_lostr� set_result� set_exception�_log_tracebackrr�feed_eofr�remove�_maybe_close_transport)rr9�exc�piper,s r�pipe_connection_lostz-SubprocessStreamProtocol.pipe_connection_lostJs��� ��7��:�:�D���� � ��� � ��%��{��"�"�-�-�d�3� � �"�"�0�0��5�5:��"�"�1�� ��7��[�[�F� �1�W��[�[�F��F����{����!��$�$�S�)� ������N�N�!�!�"�%��#�#�%rc�2�d|_|j�y)NT)rrD�rs r�process_exitedz'SubprocessStreamProtocol.process_exitedhs��#����#�#�%rc��t|j�dk(r/|jr"|jj �d|_yyy)Nr)�lenrrrr=rIs rrDz/SubprocessStreamProtocol._maybe_close_transportls:���t�~�~��!�#��(<�(<��O�O�!�!�#�"�D�O�)=�#rc�8�||jur|jSy�N)rr)r�streams r�_get_close_waiterz*SubprocessStreamProtocol._get_close_waiterqs���T�Z�Z���%�%�%� r) r"� __module__�__qualname__�__doc__rr'r5r;rGrJrDrP� __classcell__)rs@rrrs.���:�8�-�?�0#�&�<&�#� &rrc�Z�eZdZd�Zd�Zed��Zd�Zd�Zd�Z d�Z d�Zd �Zd �Z d d�Zy)�Processc��||_||_||_|j|_|j|_|j |_|j �|_yrN)r� _protocolrrrr�get_pid�pid)rr1r+rs rrzProcess.__init__wsH��#���!����� ��^�^�� ��o�o����o�o����$�$�&��rc�P�d|jj�d|j�d�S)N�<r!�>)rr"rZrIs rr'zProcess.__repr__�s&���4�>�>�*�*�+�1�T�X�X�J�a�8�8rc�6�|jj�SrN)r�get_returncoderIs r� returncodezProcess.returncode�s�����-�-�/�/rc��RK�|jj��d{���S7��w)z?Wait until the process exit and return the process return code.N)r�_waitrIs r�waitzProcess.wait�s�����_�_�*�*�,�,�,�,�s�'�%�'c�:�|jj|�yrN)r�send_signal)r�signals rrezProcess.send_signal�s�����#�#�F�+rc�8�|jj�yrN)r� terminaterIs rrhzProcess.terminate�s�����!�!�#rc�8�|jj�yrN)r�killrIs rrjzProcess.kill�s�������rc���K�|jj�} |�=|jj|�|r t j d|t |��|jj��d{���|rt j d|�|jj�y7�7#ttf$r#}|rt j d||�Yd}~�bd}~wwxYw�w)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin)r� get_debugr�writer �debugrL�drain�BrokenPipeError�ConnectionResetErrorr=)r�inputrnrEs r�_feed_stdinzProcess._feed_stdin�s������ � �$�$�&�� H�� �� � � � ��'���L�L�?��s�5�z�S��*�*�"�"�$�$�$���L�L�6��=�� � ���� %���!5�6� H�����;�T�3�G��� H�sA�C)�AB4�:B2�;B4�?3C)�2B4�4C&�C!�C)�!C&�&C)c��K�y�wrN�rIs r�_noopz Process._noop�s �����s�c���K�|jj|�}|dk(r |j}n|dk(sJ�|j}|jj�r |dk(rdnd}t jd||�|j��d{���}|jj�r |dk(rdnd}t jd||�|j�|S7�P�w)Nr*rrrz%r communicate: read %sz%r communicate: close %s) rr-rrrrlr rn�readr=)rr9r1rO�name�outputs r�_read_streamzProcess._read_stream�s������O�O�6�6�r�:� � ��7��[�[�F���7�N�7��[�[�F��:�:���!�!�Q�w�8�H�D��L�L�2�D�$�?��{�{�}�$���:�:���!�!�Q�w�8�H�D��L�L�3�T�4�@������ �%�s�BC#�C!�AC#Nc��K�|j�|j|�}n|j�}|j�|j d�}n|j�}|j �|j d�}n|j�}t j|||��d{���\}}}|j��d{���||fS7�$7� �wr7) rrsrvrr{rr �gatherrc)rrrrrrs r�communicatezProcess.communicate�s������:�:�!��$�$�U�+�E��J�J�L�E��;�;�"��&�&�q�)�F��Z�Z�\�F��;�;�"��&�&�q�)�F��Z�Z�\�F�&+�l�l�5�&�&�&I� I���v�v��i�i�k�������!J���s$�B%C�'C�(C�C� C�CrN)r"rQrRrr'�propertyr`rcrerhrjrsrvr{r~rurrrVrVvsH��'�9��0��0�-�,�$���(��" rrVc���� K�tj�� �� fd�}� j||f|||d�|���d{���\}}t||� �S7��w)Nc���t����S�Nr)�rr)s��r�<lambda>z)create_subprocess_shell.<locals>.<lambda>�����7�e�=A� Cr�rrr)r�get_running_loop�subprocess_shellrV) �cmdrrrr�kwds�protocol_factoryr1r+rs ` @rrr�sm������"�"�$�D�C�� 5�� 5� 5���!����!��!���I�x��9�h��-�-� �s�6A�A�A)rrrrc���� K�tj�� �� fd�}� j||g|��|||d�|���d{���\}} t|| � �S7��w)Nc���t����Sr�r�r)s��rr�z(create_subprocess_exec.<locals>.<lambda>�r�rr�)rr��subprocess_execrV)�programrrrr�argsr�r�r1r+rs ` @rrr�sy������"�"�$�D�C�� 4�� 4� 4���!��!��F�� !�� !���I�x� �9�h��-�-��s�9A�A�A)�__all__� subprocess�rrrr �logr �PIPE�STDOUT�DEVNULL�FlowControlMixin�SubprocessProtocolrrV�_DEFAULT_LIMITrrrurr�<module>r�s��� =������������ � � �� � � ��b&�w�7�7�(�;�;�b&�JU �U �p.2�$�t�(/�(>�(>� .�8<�D�(,�G�4J�4J�.r__pycache__/taskgroups.cpython-312.opt-1.pyc000064400000020233151706172560014632 0ustar00� T��hW%��@�dZddlmZddlmZddlmZGd�d�Zy))� TaskGroup�)�events)� exceptions)�tasksc�X�eZdZdZd�Zd�Zd�Zd�Zd�Zddd�d �Z d e defd�Zd �Z d�Zy)ra9Asynchronous context manager for managing groups of tasks. Example use: async with asyncio.TaskGroup() as group: task1 = group.create_task(some_coroutine(...)) task2 = group.create_task(other_coroutine(...)) print("Both tasks have completed now.") All tasks are awaited when the context manager exits. Any exceptions other than `asyncio.CancelledError` raised within a task will cancel all remaining tasks and wait for them to exit. The exceptions are then combined and raised as an `ExceptionGroup`. c��d|_d|_d|_d|_d|_d|_t �|_g|_d|_ d|_ y)NF)�_entered�_exiting� _aborting�_loop�_parent_task�_parent_cancel_requested�set�_tasks�_errors�_base_error�_on_completed_fut��selfs �+/usr/lib64/python3.12/asyncio/taskgroups.py�__init__zTaskGroup.__init__sN���� ��� ������ � ���(-��%��e���������!%���c�x�dg}|jr'|jdt|j����|jr'|jdt|j����|jr|jd�n|j r|jd�dj |�}d|�d�S) N�ztasks=zerrors=� cancelling�entered� z <TaskGroup�>)r�append�lenrrr �join)r�info�info_strs r�__repr__zTaskGroup.__repr__(s����t���;�;��K�K�&��T�[�[�!1� 2�3�4��<�<��K�K�'�#�d�l�l�"3�!4�5�6��>�>��K�K��%� �]�]��K�K� �"��8�8�D�>���H�:�Q�'�'rc��K�|jrtd|�d���|j�tj�|_tj|j�|_|j�td|�d���d|_|S�w)N� TaskGroup z has already been enteredz! cannot determine the parent taskT)r �RuntimeErrorrr�get_running_loopr�current_taskr rs r� __aenter__zTaskGroup.__aenter__6s������=�=���T�H�$=�>�@� @��:�:���0�0�2�D�J�!�.�.�t�z�z�:������$���T�H�$E�F�H� H��� ���s�B Bc��K�d} |j||��d{���d|_d|_d|_d}S7�#d|_d|_d|_d}wxYw�w�N)�_aexitr rr)r�et�exc�tbs r� __aexit__zTaskGroup.__aexit__Dsc���� �� ����R��-�-�!%�D���D�L�#�D���C�.��!%�D���D�L�#�D���C�s%�A�9�7�9�A�9�A�Ac��K�d|_|�$|j|�r|j�||_|tjur|nd}|j r|jj�dk(rd}|�|js|j�|jrT|j�|jj�|_ |j�d{���d|_|jr�T|j� |j� |r|js |�d}|�-|tjur|jj|�|jr t!d|j�d�y7��#tj$r(}|js|}|j�Yd}~��d}~wwxYw#d}wxYw#d}wxYw#d}wxYw#d}wxYw�w)NT�zunhandled errors in a TaskGroup)r �_is_base_errorrr�CancelledErrorrr �uncancelr�_abortrrr� create_futurerr�BaseExceptionGroup)rr.r/�propagate_cancellation_error�exs rr-zTaskGroup._aexitRs������� ��O��#�#�C�(�� � �(�"�D����2�2�2�C�� %��(�(�� � �)�)�+�q�0�04�,� �>��>�>���� ��k�k��%�%�-�)-���)A�)A�)C��&� "��,�,�,�,�&*�D�"�'�k�k�.���'� ��&�&�&� 0�+�D�L�L��6�6�,0�(� �>�b� �(A�(A�A��L�L����$��<�<� �(�5��L�L�����M-���,�,� "��~�~�46�0��K�K�M��� "��*����C��+/�(����s��CG�E2�E0�E2�G�/G�<F0� F>�F7�=G�G�/G�0E2�2F-�F(�#G�(F-�-G�0F4�4G�7F;�;F>�>G�G�G � GN)�name�contextc���|jstd|�d���|jr|jstd|�d���|jrtd|�d���|�|j j |�}n|j j ||��}tj||�|jj|�|j|j� |~S#~wxYw)zbCreate a new task in this group and return it. Similar to `asyncio.create_task`. r&z has not been enteredz is finishedz is shutting down)r=)r r'r rrr�create_taskr�_set_task_name�add�add_done_callback� _on_task_done)r�coror<r=�tasks rr?zTaskGroup.create_task�s��� �}�}���D�8�3H�I�J�J��=�=������D�8�<�@�A�A��>�>���D�8�3D�E�F�F��?��:�:�)�)�$�/�D��:�:�)�)�$��)�@�D� ���T�4�(� ����������t�1�1�2� �����s�&C)�)C,r/�returnc�.�t|ttf�Sr,)� isinstance� SystemExit�KeyboardInterrupt)rr/s rr4zTaskGroup._is_base_error�s���#� �,=�>�?�?rc�v�d|_|jD]#}|j�r�|j��%y)NT)rr�done�cancel)r�ts rr7zTaskGroup._abort�s)��������A��6�6�8���� �rc���|jj|�|j�A|js5|jj�s|jj d�|j�ry|j �}|�y|jj|�|j|�r|j�||_ |jj�r1|jjd|�d|j�d�||d��y|js?|js2|j!�d|_|jj#�yyy)NTzTask z% has errored out but its parent task z is already completed)�message� exceptionrE)r�discardrrL� set_result� cancelledrQrrr4rr r�call_exception_handlerrrr7rM)rrEr/s rrCzTaskGroup._on_task_done�s3�������D�!��!�!�-�d�k�k��)�)�.�.�0��&�&�1�1�$�7��>�>����n�n����;�������C� ����s�#��(8�(8�(@�"�D�����!�!�#� �J�J�-�-�"�4�(�+#�#'�#4�#4�"5�5J�L� �� /� � ��~�~�d�&C�&C�& �K�K�M�,0�D�)����$�$�&�+'D�~r)�__name__� __module__�__qualname__�__doc__rr$r*r1r-r?� BaseException�boolr4r7rC�rrrrsO��� &�(���W�t)-�d��F@�-�@�D�@��2'rrN)�__all__rrrrrr\rr�<module>r^s!�� �����@'�@'r__pycache__/taskgroups.cpython-312.opt-2.pyc000064400000016766151706172560014653 0ustar00� T��hW%��@�dZddlmZddlmZddlmZGd�d�Zy))� TaskGroup�)�events)� exceptions)�tasksc�V�eZdZ d�Zd�Zd�Zd�Zd�Zddd�d�Zd e d e fd�Zd�Zd �Z y)rc��d|_d|_d|_d|_d|_d|_t �|_g|_d|_ d|_ y)NF)�_entered�_exiting� _aborting�_loop�_parent_task�_parent_cancel_requested�set�_tasks�_errors�_base_error�_on_completed_fut��selfs �+/usr/lib64/python3.12/asyncio/taskgroups.py�__init__zTaskGroup.__init__sN���� ��� ������ � ���(-��%��e���������!%���c�x�dg}|jr'|jdt|j����|jr'|jdt|j����|jr|jd�n|j r|jd�dj |�}d|�d�S) N�ztasks=zerrors=� cancelling�entered� z <TaskGroup�>)r�append�lenrrr �join)r�info�info_strs r�__repr__zTaskGroup.__repr__(s����t���;�;��K�K�&��T�[�[�!1� 2�3�4��<�<��K�K�'�#�d�l�l�"3�!4�5�6��>�>��K�K��%� �]�]��K�K� �"��8�8�D�>���H�:�Q�'�'rc��K�|jrtd|�d���|j�tj�|_tj|j�|_|j�td|�d���d|_|S�w)N� TaskGroup z has already been enteredz! cannot determine the parent taskT)r �RuntimeErrorrr�get_running_loopr�current_taskr rs r� __aenter__zTaskGroup.__aenter__6s������=�=���T�H�$=�>�@� @��:�:���0�0�2�D�J�!�.�.�t�z�z�:������$���T�H�$E�F�H� H��� ���s�B Bc��K�d} |j||��d{���d|_d|_d|_d}S7�#d|_d|_d|_d}wxYw�w�N)�_aexitr rr)r�et�exc�tbs r� __aexit__zTaskGroup.__aexit__Dsc���� �� ����R��-�-�!%�D���D�L�#�D���C�.��!%�D���D�L�#�D���C�s%�A�9�7�9�A�9�A�Ac��K�d|_|�$|j|�r|j�||_|tjur|nd}|j r|jj�dk(rd}|�|js|j�|jrT|j�|jj�|_ |j�d{���d|_|jr�T|j� |j� |r|js |�d}|�-|tjur|jj|�|jr t!d|j�d�y7��#tj$r(}|js|}|j�Yd}~��d}~wwxYw#d}wxYw#d}wxYw#d}wxYw#d}wxYw�w)NT�zunhandled errors in a TaskGroup)r �_is_base_errorrr�CancelledErrorrr �uncancelr�_abortrrr� create_futurerr�BaseExceptionGroup)rr.r/�propagate_cancellation_error�exs rr-zTaskGroup._aexitRs������� ��O��#�#�C�(�� � �(�"�D����2�2�2�C�� %��(�(�� � �)�)�+�q�0�04�,� �>��>�>���� ��k�k��%�%�-�)-���)A�)A�)C��&� "��,�,�,�,�&*�D�"�'�k�k�.���'� ��&�&�&� 0�+�D�L�L��6�6�,0�(� �>�b� �(A�(A�A��L�L����$��<�<� �(�5��L�L�����M-���,�,� "��~�~�46�0��K�K�M��� "��*����C��+/�(����s��CG�E2�E0�E2�G�/G�<F0� F>�F7�=G�G�/G�0E2�2F-�F(�#G�(F-�-G�0F4�4G�7F;�;F>�>G�G�G � GN)�name�contextc��� |jstd|�d���|jr|jstd|�d���|jrtd|�d���|�|j j |�}n|j j ||��}tj||�|jj|�|j|j� |~S#~wxYw)Nr&z has not been enteredz is finishedz is shutting down)r=)r r'r rrr�create_taskr�_set_task_name�add�add_done_callback� _on_task_done)r�coror<r=�tasks rr?zTaskGroup.create_task�s��� ��}�}���D�8�3H�I�J�J��=�=������D�8�<�@�A�A��>�>���D�8�3D�E�F�F��?��:�:�)�)�$�/�D��:�:�)�)�$��)�@�D� ���T�4�(� ����������t�1�1�2� �����s�'C*�*C-r/�returnc�.�t|ttf�Sr,)� isinstance� SystemExit�KeyboardInterrupt)rr/s rr4zTaskGroup._is_base_error�s���#� �,=�>�?�?rc�v�d|_|jD]#}|j�r�|j��%y)NT)rr�done�cancel)r�ts rr7zTaskGroup._abort�s)��������A��6�6�8���� �rc���|jj|�|j�A|js5|jj�s|jj d�|j�ry|j �}|�y|jj|�|j|�r|j�||_ |jj�r1|jjd|�d|j�d�||d��y|js?|js2|j!�d|_|jj#�yyy)NTzTask z% has errored out but its parent task z is already completed)�message� exceptionrE)r�discardrrL� set_result� cancelledrQrrr4rr r�call_exception_handlerrrr7rM)rrEr/s rrCzTaskGroup._on_task_done�s3�������D�!��!�!�-�d�k�k��)�)�.�.�0��&�&�1�1�$�7��>�>����n�n����;�������C� ����s�#��(8�(8�(@�"�D�����!�!�#� �J�J�-�-�"�4�(�+#�#'�#4�#4�"5�5J�L� �� /� � ��~�~�d�&C�&C�& �K�K�M�,0�D�)����$�$�&�+'D�~r)�__name__� __module__�__qualname__rr$r*r1r-r?� BaseException�boolr4r7rC�rrrrsO��� &�(���W�t)-�d��F@�-�@�D�@��2'rrN)�__all__rrrrrr[rr�<module>r]s!�� �����@'�@'r__pycache__/taskgroups.cpython-312.pyc000064400000020374151706172560013701 0ustar00� T��hW%��@�dZddlmZddlmZddlmZGd�d�Zy))� TaskGroup�)�events)� exceptions)�tasksc�X�eZdZdZd�Zd�Zd�Zd�Zd�Zddd�d �Z d e defd�Zd �Z d�Zy)ra9Asynchronous context manager for managing groups of tasks. Example use: async with asyncio.TaskGroup() as group: task1 = group.create_task(some_coroutine(...)) task2 = group.create_task(other_coroutine(...)) print("Both tasks have completed now.") All tasks are awaited when the context manager exits. Any exceptions other than `asyncio.CancelledError` raised within a task will cancel all remaining tasks and wait for them to exit. The exceptions are then combined and raised as an `ExceptionGroup`. c��d|_d|_d|_d|_d|_d|_t �|_g|_d|_ d|_ y)NF)�_entered�_exiting� _aborting�_loop�_parent_task�_parent_cancel_requested�set�_tasks�_errors�_base_error�_on_completed_fut��selfs �+/usr/lib64/python3.12/asyncio/taskgroups.py�__init__zTaskGroup.__init__sN���� ��� ������ � ���(-��%��e���������!%���c�x�dg}|jr'|jdt|j����|jr'|jdt|j����|jr|jd�n|j r|jd�dj |�}d|�d�S) N�ztasks=zerrors=� cancelling�entered� z <TaskGroup�>)r�append�lenrrr �join)r�info�info_strs r�__repr__zTaskGroup.__repr__(s����t���;�;��K�K�&��T�[�[�!1� 2�3�4��<�<��K�K�'�#�d�l�l�"3�!4�5�6��>�>��K�K��%� �]�]��K�K� �"��8�8�D�>���H�:�Q�'�'rc��K�|jrtd|�d���|j�tj�|_tj|j�|_|j�td|�d���d|_|S�w)N� TaskGroup z has already been enteredz! cannot determine the parent taskT)r �RuntimeErrorrr�get_running_loopr�current_taskr rs r� __aenter__zTaskGroup.__aenter__6s������=�=���T�H�$=�>�@� @��:�:���0�0�2�D�J�!�.�.�t�z�z�:������$���T�H�$E�F�H� H��� ���s�B Bc��K�d} |j||��d{���d|_d|_d|_d}S7�#d|_d|_d|_d}wxYw�w�N)�_aexitr rr)r�et�exc�tbs r� __aexit__zTaskGroup.__aexit__Dsc���� �� ����R��-�-�!%�D���D�L�#�D���C�.��!%�D���D�L�#�D���C�s%�A�9�7�9�A�9�A�Ac��K�d|_|�$|j|�r|j�||_|tjur|nd}|j r|jj�dk(rd}|�|js|j�|jrT|j�|jj�|_ |j�d{���d|_|jr�T|jrJ�|j� |j� |r|js |�d}|�-|tjur|jj|�|jr t!d|j�d�y7��#tj$r(}|js|}|j�Yd}~��d}~wwxYw#d}wxYw#d}wxYw#d}wxYw#d}wxYw�w)NT�zunhandled errors in a TaskGroup)r �_is_base_errorrr�CancelledErrorrr �uncancelr�_abortrrr� create_futurerr�BaseExceptionGroup)rr.r/�propagate_cancellation_error�exs rr-zTaskGroup._aexitRs������� ��O��#�#�C�(�� � �(�"�D����2�2�2�C�� %��(�(�� � �)�)�+�q�0�04�,� �>��>�>���� ��k�k��%�%�-�)-���)A�)A�)C��&� "��,�,�,�,�&*�D�"�'�k�k�*�;�;������'� ��&�&�&� 0�+�D�L�L��6�6�,0�(� �>�b� �(A�(A�A��L�L����$��<�<� �(�5��L�L�����M-���,�,� "��~�~�46�0��K�K�M��� "��*����C��+/�(����s��CG�F�E>�F�G�/G� F>�G�&G�(=G�&G�=G�>F�F;�F6�1G�6F;�;G�>G�G�G � G�G�G�G�GN)�name�contextc���|jstd|�d���|jr|jstd|�d���|jrtd|�d���|�|j j |�}n|j j ||��}tj||�|jj|�|j|j� |~S#~wxYw)zbCreate a new task in this group and return it. Similar to `asyncio.create_task`. r&z has not been enteredz is finishedz is shutting down)r=)r r'r rrr�create_taskr�_set_task_name�add�add_done_callback� _on_task_done)r�coror<r=�tasks rr?zTaskGroup.create_task�s��� �}�}���D�8�3H�I�J�J��=�=������D�8�<�@�A�A��>�>���D�8�3D�E�F�F��?��:�:�)�)�$�/�D��:�:�)�)�$��)�@�D� ���T�4�(� ����������t�1�1�2� �����s�&C)�)C,r/�returnc�R�t|t�sJ�t|ttf�Sr,)� isinstance� BaseException� SystemExit�KeyboardInterrupt)rr/s rr4zTaskGroup._is_base_error�s%���#�}�-�-�-��#� �,=�>�?�?rc�v�d|_|jD]#}|j�r�|j��%y)NT)rr�done�cancel)r�ts rr7zTaskGroup._abort�s)��������A��6�6�8���� �rc���|jj|�|j�A|js5|jj�s|jj d�|j�ry|j �}|�y|jj|�|j|�r|j�||_ |jj�r1|jjd|�d|j�d�||d��y|js?|js2|j!�d|_|jj#�yyy)NTzTask z% has errored out but its parent task z is already completed)�message� exceptionrE)r�discardrrM� set_result� cancelledrRrrr4rr r�call_exception_handlerrrr7rN)rrEr/s rrCzTaskGroup._on_task_done�s3�������D�!��!�!�-�d�k�k��)�)�.�.�0��&�&�1�1�$�7��>�>����n�n����;�������C� ����s�#��(8�(8�(@�"�D�����!�!�#� �J�J�-�-�"�4�(�+#�#'�#4�#4�"5�5J�L� �� /� � ��~�~�d�&C�&C�& �K�K�M�,0�D�)����$�$�&�+'D�~r)�__name__� __module__�__qualname__�__doc__rr$r*r1r-r?rI�boolr4r7rC�rrrrsO��� &�(���W�t)-�d��F@�-�@�D�@��2'rrN)�__all__rrrrrr\rr�<module>r^s!�� �����@'�@'r__pycache__/tasks.cpython-312.opt-1.pyc000064400000116372151706172560013567 0ustar00� T��h����dZdZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlmZddlm Z ddlmZddlmZdd lmZdd lmZddlmZej&d�j(Zd/d�Zd/d �Zd�ZGd�dej2�ZeZ ddlZej4xZZddd�d�Zej"j@Z ej"jBZ!ej"jDZ"de"d�d�Z#d�Z$d�Z%d�Z&d�Z'dd�d�Z(ejRd��Z*d/d�Z+dd�d�Z,Gd�d ejZ�Z.d!d"�d#�Z/d$�Z0d%�Z1d&�Z2e2e�Z3e jh�Z5e6�Z7iZ8d'�Z9d(�Z:d)�Z;d*�Z<d+�Z=d,�Z>d-�Z?eZ@e9ZAe:ZBe>ZCe?ZDe;ZEe<ZFe=ZG dd.lm9Z9m:Z:m>Z>m?Z?m;Z;m<Z<m=Z=m5Z5m7Z7m8Z8mZeZHe9ZIe:ZJe>ZKe?ZLe;ZMe<ZNe=ZOy#e$rY��wxYw#e$rYywxYw)0z0Support for tasks, coroutines and the scheduler.)�Task�create_task�FIRST_COMPLETED�FIRST_EXCEPTION� ALL_COMPLETED�wait�wait_for�as_completed�sleep�gather�shield� ensure_future�run_coroutine_threadsafe�current_task� all_tasks�create_eager_task_factory�eager_task_factory�_register_task�_unregister_task�_enter_task�_leave_task�N)�GenericAlias�)� base_tasks)� coroutines)�events)� exceptions)�futures)�timeoutsc�X�|�tj�}tj|�S)z!Return a currently executed task.)r�get_running_loop�_current_tasks�get��loops �&/usr/lib64/python3.12/asyncio/tasks.pyrr$s&���|��&�&�(�����d�#�#�c�N�|�tj�}tt�}d}d} tt�} t j||�D�chc]+}tj|�|ur|j�s|��-c}S#t $r|dz }|dk\r�YnwxYw�wcc}w)z'Return a set of all tasks for the loop.Nrri�)rr!�list�_eager_tasks�_scheduled_tasks�RuntimeError� itertools�chainr� _get_loop�done)r%�eager_tasks�scheduled_tasks�i�ts r&rr+s����|��&�&�(���|�$�K��O� �A� � �"�#3�4�O� � �����D�>�D�!�� � ��#�t�+�A�F�F�H� �D�>�>�� � � ��F�A��D�y��� ����>s�B�0B"�B�Bc��|� |j}||�yy#t$rtjdtd��YywxYw)Nz~Task.set_name() was added in Python 3.8, the method support will be mandatory for third-party task implementations since 3.13.�)� stacklevel)�set_name�AttributeError�warnings�warn�DeprecationWarning)�task�namer8s r&�_set_task_namer?FsM���� ��}�}�H� �T�N���� 8��M�M�9�)�Q� 8� 8�s��%A�Ac����eZdZdZdZddddd��fd� Z�fd�Zee�Z d�Z d �Zd �Zd�Z d�Zd �Zd�Zdd�d�Zddd�d�Zdd�Zd�Zd�Zd�Zdd�Z�fd�Zd�Z�xZS)rz A coroutine wrapped in a Future.TNF�r%r>�context�eager_startc�F��t�|�|��|jr |jd=tj|�sd|_t d|����|�dt���|_nt|�|_d|_ d|_d|_||_ |�tj�|_n||_|r+|j"j%�r|j'�y|j"j)|j*|j ��t-|�y)Nr$���Fza coroutine was expected, got zTask-r�rB)�super�__init__�_source_tracebackr�iscoroutine�_log_destroy_pending� TypeError�_task_name_counter�_name�str�_num_cancels_requested�_must_cancel�_fut_waiter�_coro�contextvars�copy_context�_context�_loop� is_running�_Task__eager_start� call_soon�_Task__stepr)�self�coror%r>rBrC� __class__s �r&rHz Task.__init__os���� ���d��#��!�!��&�&�r�*��%�%�d�+�).�D�%��<�T�H�E�F�F��<� �!3�!5� 6�7�D�J��T��D�J�&'��#�!�������� ��?�'�4�4�6�D�M�#�D�M��4�:�:�0�0�2���� ��J�J� � ����d�m�m� �D��4� r'c����|jtjk(rG|jr;|dd�}|jr|j|d<|j j |�t�|�!�y)Nz%Task was destroyed but it is pending!)r=�message�source_traceback) �_stater�_PENDINGrKrIrW�call_exception_handlerrG�__del__)r\rBr^s �r&rezTask.__del__�sb����;�;�'�*�*�*�t�/H�/H��B��G��%�%�.2�.D�.D��*�+��J�J�-�-�g�6� ���r'c�,�tj|�S�N)r� _task_repr�r\s r&�__repr__z Task.__repr__�s���$�$�T�*�*r'c��|jSrg)rSris r&�get_coroz Task.get_coro�����z�z�r'c��|jSrg)rVris r&�get_contextzTask.get_context�s���}�}�r'c��|jSrg)rNris r&�get_namez Task.get_name�rmr'c�$�t|�|_yrg)rOrN)r\�values r&r8z Task.set_name�s ����Z�� r'c��td��)Nz*Task does not support set_result operation�r,)r\�results r&� set_resultzTask.set_result�s���G�H�Hr'c��td��)Nz-Task does not support set_exception operationru)r\� exceptions r&� set_exceptionzTask.set_exception�s���J�K�Kr')�limitc�.�tj||�S)a�Return the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. )r�_task_get_stack)r\r{s r&� get_stackzTask.get_stack�s��*�)�)�$��6�6r')r{�filec�0�tj|||�S)anPrint the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. )r�_task_print_stack)r\r{rs r&�print_stackzTask.print_stack�s���+�+�D�%��>�>r'c���d|_|j�ry|xjdz c_|j�|jj |��ryd|_||_y)a�Request that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). This also increases the task's count of cancellation requests. Fr��msgT)�_log_tracebackr0rPrR�cancelrQ�_cancel_message)r\r�s r&r�zTask.cancel�sf��,$����9�9�;���#�#�q�(�#����'����&�&�3�&�/�� ���"���r'c��|jS)z�Return the count of the task's cancellation requests. This count is incremented when .cancel() is called and may be decremented using .uncancel(). �rPris r&� cancellingzTask.cancelling�s���*�*�*r'c�b�|jdkDr|xjdzc_|jS)z�Decrement the task's count of cancellation requests. This should be called by the party that called `cancel()` on the task beforehand. Returns the remaining number of cancellation requests. rrr�ris r&�uncancelz Task.uncancels/���&�&��*��'�'�1�,�'��*�*�*r'c�p�t|j|�} t|� |jj |j d�t |� t|j|�}|j�r d|_d}yt|�y#t |�wxYw#|j�r d|_d}wt|�wxYw# t|j|�}|j�r d|_d}wt|�w#|j�r d|_d}wt|�wxYwxYwrg) �_swap_current_taskrW�_register_eager_taskrV�run�!_Task__step_run_and_handle_result�_unregister_eager_taskr0rSr)r\� prev_task�curtasks r&� __eager_startzTask.__eager_starts���&�t�z�z�4�8� � )� ��&� -�� � �!�!�$�"C�"C�T�J�&�t�,� )�,�T�Z�Z��C���9�9�;�!%�D�J��D�"�4�(��'�t�,���9�9�;�!%�D�J��D�"�4�(�� )�,�T�Z�Z��C���9�9�;�!%�D�J��D�"�4�(�� �9�9�;�!%�D�J��D�"�4�(�sF�C �&B� C �B#� B � C �#'C � D5�D�%&D5�'D2�2D5c��|j�rtjd|�d|����|jr1t |tj �s|j �}d|_d|_t|j|� |j|�t|j|�d}y#t|j|�d}wxYw)Nz_step(): already done: z, F)r0r�InvalidStateErrorrQ� isinstance�CancelledError�_make_cancelled_errorrRrrWr�r)r\�excs r&�__stepzTask.__step#s����9�9�;��.�.�)�$���C�7�;�=� =�����c�:�#<�#<�=��0�0�2�� %�D������D�J�J��%� ��-�-�c�2��� � �D�)��D�� �� � �D�)��D�s�B1�1Cc����|j} |�|jd�}n|j|�}t|dd�}|��lt j |�|jurGtd|�d|�d��}|jj|j||j��d}y|r�||urCtd|���}|jj|j||j��d}yd|_|j|j|j��||_|j�rN|jj!|j"���r'd|_ d}ytd |�d |���}|jj|j||j�� d}y|�4|jj|j|j��d}yt%j&|�rFtd|�d |���}|jj|j||j��d}ytd|���}|jj|j||j�� d}yd}y#t($rS}|jr"d|_t*�|�A|j"��nt*�|�Y|j.�Yd}~d}yd}~wt0j2$r!}||_t*�|�A�Yd}~d}yd}~wt6t8f$r}t*�|�u|��d}~wt<$r}t*�|�u|�Yd}~d}yd}~wwxYw#d}wxYw) N�_asyncio_future_blockingzTask z got Future z attached to a different looprFzTask cannot await on itself: Fr�z-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )rS�send�throw�getattrrr/rWr,rZr[rVr��add_done_callback� _Task__wakeuprRrQr�r��inspect�isgenerator� StopIterationrGrwrsrr��_cancelled_exc�KeyboardInterrupt� SystemExitrz� BaseException)r\r�r]rv�blocking�new_excr^s �r&�__step_run_and_handle_resultz!Task.__step_run_and_handle_result4se����z�z��G ��{����4������C���$�v�'A�4�H�H��#��$�$�V�,�D�J�J�>�*���x�|�!�*�$A�C�D�G��J�J�(�(����W�d�m�m�)�E�P�D�M���~�".�;�D�8�D�#F��� � �,�,� �K�K��$�-�-�-�I�D�D�?;@��7��0�0� �M�M�4�=�=�1�B�+1��(��,�,�#�/�/�6�6�(,�(<�(<� 7� >�49�� 1�0�D�-+�#�#'�(�&�� �<�=�G��J�J�(�(����W�d�m�m�)�E�&�D�!��� � �$�$�T�[�[�$�-�-�$�H��D��$�$�V�,�&�)�)-���v�j�B�C��� � �$�$��K�K��$�-�-�%�A��D� '�)=�f�Z�'H�I��� � �$�$��K�K��$�-�-�%�A��D�4�D��A� .�� � �$)��!����4�#7�#7��8���"�3�9�9�-��t�D��s�(�(� �"%�D���G�N���l�D��k"�:�.� ��G�!�#�&���� '��G�!�#�&�&�b�D��e '��d�D�s��%J�A5M�,AM�5A0M�)AM�03M�&AM�AM� M�AK�M�M�5L� M�M�#L3�3M�?M�M�M�M�M!c�� |j�|j�d}y#t$r}|j|�Yd}~d}yd}~wwxYwrg)rvr[r�)r\�futurer�s r&�__wakeupz Task.__wakeupsH�� ��M�M�O� �K�K�M����� ��K�K������� �s�%� A�A�Arg)�__name__� __module__�__qualname__�__doc__rKrHre�classmethodr�__class_getitem__rjrlrorqr8rwrzr~r�r�r�r�rYr[r�r�� __classcell__�r^s@r&rrSs����+�. ��%)��d�"�!�> �$�L�1��+���� �I�L�"&�7�.$(�d� ?�(�T+� +�)�&�"I�Vr'r�r>rBc��tj�}|�|j|�}n|j||��}t||�|S)z]Schedule the execution of a coroutine object in a spawn task. Return a Task object. rF)rr!rr?)r]r>rBr%r=s r&rr�sK�� �"�"�$�D�������%������g��6���4����Kr')�timeout�return_whenc��K�tj|�stj|�r!t dt|�j����|std��|tttfvrtd|����t|�}td�|D��rt d��tj�}t||||��d{���S7��w)a}Wait for the Futures or Tasks given by fs to complete. The fs iterable must not be empty. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending). Usage: done, pending = await asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. zexpect a list of futures, not zSet of Tasks/Futures is empty.zInvalid return_when value: c3�FK�|]}tj|����y�wrg)rrJ)�.0�fs r&� <genexpr>zwait.<locals>.<genexpr>�s���� 1�b��:�!�!�!�$�b�s�!z6Passing coroutines is forbidden, use tasks explicitly.N)r�isfuturerrJrL�typer�� ValueErrorrrr�set�anyrr!�_wait)�fsr�r�r%s r&rr�s����� �����z�5�5�b�9��8��b��9J�9J�8K�L�M�M� ��9�:�:��?�O�]�K�K��6�{�m�D�E�E� �R��B� � 1�b� 1�1��P�Q�Q��"�"�$�D��r�7�K��6�6�6�6�s�CC� C� Cc�H�|j�s|jd�yyrg)r0rw)�waiter�argss r&�_release_waiterr��s���;�;�=����$��r'c��K�|�T|dkrOt|�}|j�r|j�St|��d{��� |j�Stj|�4�d{���|�d{���cddd��d{���S7�N#tj $r}t|�d}~wwxYw7�C7�;7�-#1�d{���7swYyxYw�w)a�Wait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. If the task suppresses the cancellation and returns a value instead, that value is returned. This function is a coroutine. Nr) r r0rv�_cancel_and_waitrr��TimeoutErrorrr�)�futr�r�s r&rr�s�����F��w�!�|��C� ���8�8�:��:�:�<���s�#�#�#� (��:�:�<������(�(��y�)�(�(� $���(�(� (��C�'�� (��)����)��(�(�(�s��AC�B�C� B�C�2B6�3C�6B<�<B8�=B<�C�B:� C�B3�'B.�.B3�3C�8B<�:C�<C�C�C� Cc��0��� � K�|j�� d� |�|j|t� �� t|����� � fd�}|D]}|j |�� � �d{���� �� j�|D]}|j |�� t�t�}}|D]5}|j�r|j|��%|j|��7||fS7��#� �� j�|D]}|j |��wxYw�w)zVInternal helper for wait(). The fs argument must be a collection of Futures. Nc�����dz��dks2�tk(s)�tk(rW|j�sF|j��5���j ��j�s�j d�yyyyy)Nrr)rr� cancelledryr�r0rw)r��counterr��timeout_handler�s ����r&�_on_completionz_wait.<locals>._on_completionst����1����q�L��?�*��?�*�A�K�K�M�01��� �0I��)��%�%�'��;�;�=��!�!�$�'�!�1J�5B�*r') � create_future� call_laterr��lenr�r��remove_done_callbackr�r0�add)r�r�r�r%r�r�r0�pendingr�r�r�s ` @@@r&r�r� s������ � � !�F��N�������/�6�J���"�g�G� (��� ���N�+��3�����%��!�!�#��A� �"�"�>�2���E�3�5�'�D� ���6�6�8��H�H�Q�K��K�K��N� � ��=�� ���%��!�!�#��A� �"�"�>�2��s1�AD�C'�#C%�$C'�(A=D�%C'�',D�Dc��2K�tj�}|j�}tjt |�}|j |� |j�|�d{���|j|�y7�#|j|�wxYw�w)z<Cancel the *fut* future or task and wait until it completes.N) rr!r�� functools�partialr�r�r�r�)r�r%r��cbs r&r�r�6s}�����"�"�$�D� � � � !�F� � � �?�F� 3�B����"��%�� � ������ � ��$� ��� � ��$�s0�AB�B�(A?�)B�-B�?B�B�B)r�c#��� � �K�tj|�stj|�r!t dt|�j����ddlm}|�� tj�}t|�D�chc]}t||����c}�d� �� �fd�}� � �fd��� fd�}�D]}|j����r|�|j||�� tt!���D]}|���� ycc}w�w) a^Return an iterator whose values are coroutines. When waiting for the yielded coroutines you'll get the results (or exceptions!) of the original Futures (or coroutines), in the order in which and as soon as they complete. This differs from PEP 3148; the proper way to use this is: for f in as_completed(fs): result = await f # The 'await' may raise. # Use result. If a timeout is specified, the 'await' will raise TimeoutError when the timeout occurs before all Futures are done. Note: The futures 'f' are not necessarily members of fs. z#expect an iterable of futures, not r)�Queuer$Nc�x���D]$}|j���jd��&�j�yrg)r�� put_nowait�clear)r�r�r0�todos ���r&�_on_timeoutz!as_completed.<locals>._on_timeoutds2����A� �"�"�>�2��O�O�D�!�� � � �r'c�|���sy�j|��j|��s���j�yyyrg)�remover�r�)r�r0r�r�s ���r&r�z$as_completed.<locals>._on_completionjs;��������A���������2��!�!�#�3�tr'c���K��j��d{���}|�tj�|j�S7�&�wrg)r#rr�rv)r�r0s �r&� _wait_for_onez#as_completed.<locals>._wait_for_oners7������(�(�*����9��)�)�)��x�x�z�� �s�A�>�'A)rr�rrJrLr�r��queuesr�r�get_event_loopr�r r�r��ranger�)r�r�r�r%r�r�r��_r�r0r�r�s @@@@r&r r Hs������$�����z�5�5�b�9��=�d�2�h�>O�>O�=P�Q�R�R���7�D�� � �"�D�14�R��9��A�M�!�$�'��9�D��N��$���� ���N�+����#�����+�>�� �3�t�9� ���o����9:�s�A:D�C=�A.Dc#�K�d��y�w)z�Skip one event loop run cycle. This is a private helper for 'asyncio.sleep()', used when the 'delay' is set to 0. It uses a bare 'yield' expression (which Task.__step knows how to handle) instead of creating a Future object. N�r�r'r&�__sleep0r��s���� �s�c��0K�|dkrt��d{���|Stj�}|j�}|j |t j||�} |�d{���|j�S7�g7�#|j�wxYw�w)z9Coroutine that completes after a given time (in seconds).rN)r�rr!r�r�r�_set_result_unless_cancelledr�)�delayrvr%r��hs r&r r �s������z��j���� ��"�"�$�D� � � � !�F������<�<��� (�A���|� ��� � ���� ��� �s:�B�A=�AB�#B�(A?�)B�,B�?B�B�Br$c��tj|�r&|�"|tj|�urtd��|Sd}t j |�s.t j|�rd�}||�}d}ntd��|�tj�} |j|�S#t$r|r|j��wxYw)zmWrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. zRThe future belongs to a different loop than the one specified as the loop argumentTc��"K�|�d{���S7��wrgr�)� awaitables r&�_wrap_awaitablez&ensure_future.<locals>._wrap_awaitable�s����&��&��s�� �Fz:An asyncio.Future, a coroutine or an awaitable is required)rr�r/r�rrJr��isawaitablerLrr�rr,�close)�coro_or_futurer%�should_closer�s r&r r �s��� ����'����G�,=�,=�n�,M� M��E�F� F����L��!�!�.�1����~�.� '�-�^�<�N� �L��*�+� +��|��$�$�&�������/�/������ � �"� ��s�B)�)Cc�*��eZdZdZ�fd�Zdd�Z�xZS)�_GatheringFuturez�Helper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. c�B��t�|�|��||_d|_y)Nr$F)rGrH� _children�_cancel_requested)r\�childrenr%r^s �r&rHz_GatheringFuture.__init__�s"��� ���d��#�!���!&��r'c��|j�ryd}|jD]}|j|��s�d}�|rd|_|S)NFr�T)r0rr�r)r\r��ret�childs r&r�z_GatheringFuture.cancel�sH���9�9�;�����^�^�E��|�|��|�$���$��&*�D�"�� r'rg)r�r�r�r�rHr�r�r�s@r&rr�s����'�r'rF)�return_exceptionsc���� � ��|s7tj�}|j���jg��S�� � ��fd�}i}g�d� d� g}d}d�|D]�}||vrmt ||��}|�tj|�}||urd|_� dz � |||<|j�r|j|�n|j|�n||}�j|���t�|���|D] }||���S)a�Return a future aggregating results from the given coroutines/futures. Coroutines will be wrapped in a future and scheduled in the event loop. They will not necessarily be scheduled in the same order as passed in. All futures must share the same event loop. If all the tasks are done successfully, the returned future's result is the list of results (in the order of the original sequence, not necessarily the order of results arrival). If *return_exceptions* is True, exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first raised exception will be immediately propagated to the returned future. Cancellation: if the outer Future is cancelled, all children (that have not completed yet) are also cancelled. If any child is cancelled, this is treated as if it raised CancelledError -- the outer Future is *not* cancelled in this case. (This is to prevent the cancellation of one child to cause other children to be cancelled.) If *return_exceptions* is False, cancelling gather() after it has been marked done won't cancel any submitted awaitables. For instance, gather can be marked done after propagating an exception to the caller, therefore, calling ``gather.cancel()`` after catching an exception (raised by one of the awaitables) from gather won't cancel any other awaitables. c����dz ����j�r!|j�s|j�y�sV|j�r"|j�}�j |�y|j�}|��j |�y��k(r�g}�D]s}|j�r.tj|j�dn|j�}n"|j�}|�|j�}|j|��u�jr"|j�}�j |�y�j|�yy)Nr�)r0r�ryr�rzrr�r�rv�appendrrw) r�r��results�resr� nfinished�nfuts�outerr s �����r&�_done_callbackzgather.<locals>._done_callback�s,����Q�� ��=�E�J�J�L��=�=�?�� � ��� ��}�}���/�/�1���#�#�C�(���m�m�o���?��'�'��,������G����=�=�?�%�3�3�!�1�1�9���+�+�-�C��-�-�/�C��{�!�j�j�l�����s�#� �"�&�&��/�/�1���#�#�C�(�� � ��)�;r'rNr$Fr)rr�r�rwr rr/rKr0r r�r)r �coros_or_futuresr%r� arg_to_fut� done_futs�argr�rrrrs` @@@@r&rr�s ���<��$�$�&���"�"�$�� �������5*�5*�n�J��H� �E��I��I��D��E����j� ���$�/�C��|��(�(��-���#�~� ,1��(��Q�J�E�!�J�s�O��x�x�z�� � ��%��%�%�n�5��S�/�C������/ �2 �X�D�1�E����s����Lr'c������t|���j�r�Stj��}|j ���fd����fd�}�j���j|��S)a�Wait for a future, shielding it from cancellation. The statement task = asyncio.create_task(something()) res = await shield(task) is exactly equivalent to the statement res = await something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: task = asyncio.create_task(something()) try: res = await shield(task) except CancelledError: res = None Save a reference to tasks passed to this function, to avoid a task disappearing mid-execution. The event loop only keeps weak references to tasks. A task that isn't referenced elsewhere may get garbage collected at any time, even before it's done. c�0���j�r!|j�s|j�y|j�r�j�y|j�}|��j|�y�j |j��yrg)r�ryr�rzrwrv)�innerr�rs �r&�_inner_done_callbackz$shield.<locals>._inner_done_callback�sj����?�?���?�?�$����!���?�?���L�L�N��/�/�#�C����#�#�C�(�� � �����0r'c�J���j�s�j��yyrg)r0r�)rrrs ��r&�_outer_done_callbackz$shield.<locals>._outer_done_callback�s ����z�z�|��&�&�';�<�r')r r0rr/r�r�)rr%rrrrs @@@r&rrask���B �#��E��z�z�|������U�#�D���� �E�1�"=� ���0�1� ���0�1��Lr'c�����tj��std��tjj�����fd�}�j |��S)zsSubmit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. zA coroutine object is requiredc���� tjt������y#ttf$r�t $r'}�j �r�j|��d}~wwxYw)Nr$)r� _chain_futurer r�r�r��set_running_or_notify_cancelrz)r�r]r�r%s ���r&�callbackz*run_coroutine_threadsafe.<locals>.callback�s]��� ��!�!�-��4�"@�&�I���-�.� ��� ��2�2�4��$�$�S�)��� �s�!%�A$�"A�A$)rrJrL� concurrentr�Future�call_soon_threadsafe)r]r%r"r�s`` @r&rr�sM��� �!�!�$�'��8�9�9� � � � &� &� (�F�� ���h�'��Mr'c���ddd��fd� }|S)a=Create a function suitable for use as a task factory on an event-loop. Example usage: loop.set_task_factory( asyncio.create_eager_task_factory(my_task_constructor)) Now, tasks created will be started immediately (rather than being first scheduled to an event loop). The constructor argument can be any callable that returns a Task-compatible object and has a signature compatible with `Task.__init__`; it must have the `eager_start` keyword argument. Most applications will use `Task` for `custom_task_constructor` and in this case there's no need to call `create_eager_task_factory()` directly. Instead the global `eager_task_factory` instance can be used. E.g. `loop.set_task_factory(asyncio.eager_task_factory)`. Nr�c����||||d��S)NTrAr�)r%r]r>rB�custom_task_constructors �r&�factoryz*create_eager_task_factory.<locals>.factory�s���&��t�$��T�K� Kr'r�)r(r)s` r&rr�s���&%)�$�K��Nr'c�.�tj|�y)z;Register an asyncio Task scheduled to run on an event loop.N)r+r��r=s r&rr�s������r'c�.�tj|�y)z6Register an asyncio Task about to be eagerly executed.N)r*r�r+s r&r�r��s�����T�r'c�h�tj|�}|�td|�d|�d���|t|<y)NzCannot enter into task z while another task z is being executed.�r"r#r,�r%r=rs r&rr�sL��!�%�%�d�+�L����4�T�H�=#�#/�"2�2E�G�H� H��N�4�r'c�h�tj|�}||urtd|�d|�d���t|=y)Nz Leaving task z! does not match the current task �.r.r/s r&rr�sJ��!�%�%�d�+�L��4���]�4�(�3/�/;�.>�a�A�B� B��t�r'c�X�tj|�}|� t|=|S|t|<|Srg)r"r#)r%r=r�s r&r�r��s9���"�"�4�(�I��|��4� ��� $��t���r'c�.�tj|�y)z'Unregister a completed, scheduled Task.N)r+�discardr+s r&rrs�����T�"r'c�.�tj|�y)z6Unregister a task which finished its first eager step.N)r*r4r+s r&r�r� s������r')rr�rr�rrr�r+r*r"rrg)Pr��__all__�concurrent.futuresr#rTr�r�r-�typesr:�weakrefrrrrrrrr�count�__next__rMrrr?� _PyFuturer�_PyTask�_asyncio�_CTask�ImportErrorrrrrrr�rr�r�r � coroutiner�r r r$rrrrrr�WeakSetr+r�r*r"rr�rrr�rr��_py_current_task�_py_register_task�_py_register_eager_task�_py_unregister_task�_py_unregister_eager_task�_py_enter_task�_py_leave_task�_py_swap_current_task�_c_current_task�_c_register_task�_c_register_eager_task�_c_unregister_task�_c_unregister_eager_task� _c_enter_task� _c_leave_task�_c_swap_current_taskr�r'r&�<module>rSsM��6������������������ %�Y�_�_�Q�'�0�0��$�>�6 �z�7���z�z ��"�� �M�M�!�D�6�#�D� �$�$�$�4�4���$�$�4�4���"�"�0�0� �#� �7�@ � 0�d)�X%�$!%�6�r��� �� ��"+/��@�w�~�~��:16�C�L?�D�.�4/�t�4��#�7�?�?�$���u����� � ���#� � ��"��.��&��2������*��.�(�(�(�(�#�O�%��1��)��5���M��M�-���i� �� ��T� �� �s$�F5� G�5F>�=F>�G �G __pycache__/tasks.cpython-312.opt-2.pyc000064400000075231151706172560013566 0ustar00� T��h���� dZddlZddlZddlZddlZddlZddlZddlZddl Z ddlm Z ddlmZddlm Z ddlmZddlmZdd lmZdd lmZej$d�j&Zd.d�Zd.d�Zd �ZGd�dej0�ZeZ ddlZej2xZZddd�d�Zej j>Zej j@Z ej jBZ!de!d�d�Z"d�Z#d�Z$d�Z%d�Z&dd�d�Z'ejPd��Z)d.d�Z*dd�d�Z+Gd�dejX�Z-d d!�d"�Z.d#�Z/d$�Z0d%�Z1e1e�Z2e jf�Z4e5�Z6iZ7d&�Z8d'�Z9d(�Z:d)�Z;d*�Z<d+�Z=d,�Z>eZ?e8Z@e9ZAe=ZBe>ZCe:ZDe;ZEe<ZF dd-lm8Z8m9Z9m=Z=m>Z>m:Z:m;Z;m<Z<m4Z4m6Z6m7Z7mZeZGe8ZHe9ZIe=ZJe>ZKe:ZLe;ZMe<ZNy#e$rY��wxYw#e$rYywxYw)/)�Task�create_task�FIRST_COMPLETED�FIRST_EXCEPTION� ALL_COMPLETED�wait�wait_for�as_completed�sleep�gather�shield� ensure_future�run_coroutine_threadsafe�current_task� all_tasks�create_eager_task_factory�eager_task_factory�_register_task�_unregister_task�_enter_task�_leave_task�N)�GenericAlias�)� base_tasks)� coroutines)�events)� exceptions)�futures)�timeoutsc�Z� |�tj�}tj|�S�N)r�get_running_loop�_current_tasks�get��loops �&/usr/lib64/python3.12/asyncio/tasks.pyrr$s)��+��|��&�&�(�����d�#�#�c�P� |�tj�}tt�}d}d} tt�} t j||�D�chc]+}tj|�|ur|j�s|��-c}S#t $r|dz }|dk\r�YnwxYw�wcc}w)Nrri�)rr"�list�_eager_tasks�_scheduled_tasks�RuntimeError� itertools�chainr� _get_loop�done)r&�eager_tasks�scheduled_tasks�i�ts r'rr+s���1��|��&�&�(���|�$�K��O� �A� � �"�#3�4�O� � �����D�>�D�!�� � ��#�t�+�A�F�F�H� �D�>�>�� � � ��F�A��D�y��� ����>s�B�0B#�B�Bc��|� |j}||�yy#t$rtjdtd��YywxYw)Nz~Task.set_name() was added in Python 3.8, the method support will be mandatory for third-party task implementations since 3.13.�)� stacklevel)�set_name�AttributeError�warnings�warn�DeprecationWarning)�task�namer9s r'�_set_task_namer@FsM���� ��}�}�H� �T�N���� 8��M�M�9�)�Q� 8� 8�s��%A�Ac���eZdZ dZddddd��fd� Z�fd�Zee�Zd�Z d�Z d �Zd �Zd�Z d�Zd �Zdd�d�Zddd�d�Zdd�Zd�Zd�Zd�Zdd�Z�fd�Zd�Z�xZS)rTNF�r&r?�context�eager_startc�F��t�|�|��|jr |jd=tj|�sd|_t d|����|�dt���|_nt|�|_d|_ d|_d|_||_ |�tj�|_n||_|r+|j"j%�r|j'�y|j"j)|j*|j ��t-|�y)Nr%���Fza coroutine was expected, got zTask-r�rC)�super�__init__�_source_tracebackr�iscoroutine�_log_destroy_pending� TypeError�_task_name_counter�_name�str�_num_cancels_requested�_must_cancel�_fut_waiter�_coro�contextvars�copy_context�_context�_loop� is_running�_Task__eager_start� call_soon�_Task__stepr)�self�coror&r?rCrD� __class__s �r'rIz Task.__init__os���� ���d��#��!�!��&�&�r�*��%�%�d�+�).�D�%��<�T�H�E�F�F��<� �!3�!5� 6�7�D�J��T��D�J�&'��#�!�������� ��?�'�4�4�6�D�M�#�D�M��4�:�:�0�0�2���� ��J�J� � ����d�m�m� �D��4� r(c����|jtjk(rG|jr;|dd�}|jr|j|d<|j j |�t�|�!�y)Nz%Task was destroyed but it is pending!)r>�message�source_traceback) �_stater�_PENDINGrLrJrX�call_exception_handlerrH�__del__)r]rCr_s �r'rfzTask.__del__�sb����;�;�'�*�*�*�t�/H�/H��B��G��%�%�.2�.D�.D��*�+��J�J�-�-�g�6� ���r(c�,�tj|�Sr!)r� _task_repr�r]s r'�__repr__z Task.__repr__�s���$�$�T�*�*r(c��|jSr!)rTris r'�get_coroz Task.get_coro�����z�z�r(c��|jSr!)rWris r'�get_contextzTask.get_context�s���}�}�r(c��|jSr!)rOris r'�get_namez Task.get_name�rmr(c�$�t|�|_yr!)rPrO)r]�values r'r9z Task.set_name�s ����Z�� r(c��td��)Nz*Task does not support set_result operation�r-)r]�results r'� set_resultzTask.set_result�s���G�H�Hr(c��td��)Nz-Task does not support set_exception operationru)r]� exceptions r'� set_exceptionzTask.set_exception�s���J�K�Kr()�limitc�0� tj||�Sr!)r�_task_get_stack)r]r{s r'� get_stackzTask.get_stack�s�� �(�)�)�$��6�6r()r{�filec�2� tj|||�Sr!)r�_task_print_stack)r]r{rs r'�print_stackzTask.print_stack�s�� ��+�+�D�%��>�>r(c��� d|_|j�ry|xjdz c_|j�|jj |��ryd|_||_y)NFr��msgT)�_log_tracebackr1rQrS�cancelrR�_cancel_message)r]r�s r'r�zTask.cancel�sk�� �*$����9�9�;���#�#�q�(�#����'����&�&�3�&�/�� ���"���r(c�� |jSr!�rQris r'� cancellingzTask.cancelling�s�� � �*�*�*r(c�d� |jdkDr|xjdzc_|jS)Nrrr�ris r'�uncancelz Task.uncancels4�� ��&�&��*��'�'�1�,�'��*�*�*r(c�p�t|j|�} t|� |jj |j d�t |� t|j|�}|j�r d|_d}yt|�y#t |�wxYw#|j�r d|_d}wt|�wxYw# t|j|�}|j�r d|_d}wt|�w#|j�r d|_d}wt|�wxYwxYwr!) �_swap_current_taskrX�_register_eager_taskrW�run�!_Task__step_run_and_handle_result�_unregister_eager_taskr1rTr)r]� prev_task�curtasks r'� __eager_startzTask.__eager_starts���&�t�z�z�4�8� � )� ��&� -�� � �!�!�$�"C�"C�T�J�&�t�,� )�,�T�Z�Z��C���9�9�;�!%�D�J��D�"�4�(��'�t�,���9�9�;�!%�D�J��D�"�4�(�� )�,�T�Z�Z��C���9�9�;�!%�D�J��D�"�4�(�� �9�9�;�!%�D�J��D�"�4�(�sF�C �&B� C �B#� B � C �#'C � D5�D�%&D5�'D2�2D5c��|j�rtjd|�d|����|jr1t |tj �s|j �}d|_d|_t|j|� |j|�t|j|�d}y#t|j|�d}wxYw)Nz_step(): already done: z, F)r1r�InvalidStateErrorrR� isinstance�CancelledError�_make_cancelled_errorrSrrXr�r)r]�excs r'�__stepzTask.__step#s����9�9�;��.�.�)�$���C�7�;�=� =�����c�:�#<�#<�=��0�0�2�� %�D������D�J�J��%� ��-�-�c�2��� � �D�)��D�� �� � �D�)��D�s�B1�1Cc����|j} |�|jd�}n|j|�}t|dd�}|��lt j |�|jurGtd|�d|�d��}|jj|j||j��d}y|r�||urCtd|���}|jj|j||j��d}yd|_|j|j|j��||_|j�rN|jj!|j"���r'd|_ d}ytd |�d |���}|jj|j||j�� d}y|�4|jj|j|j��d}yt%j&|�rFtd|�d |���}|jj|j||j��d}ytd|���}|jj|j||j�� d}yd}y#t($rS}|jr"d|_t*�|�A|j"��nt*�|�Y|j.�Yd}~d}yd}~wt0j2$r!}||_t*�|�A�Yd}~d}yd}~wt6t8f$r}t*�|�u|��d}~wt<$r}t*�|�u|�Yd}~d}yd}~wwxYw#d}wxYw) N�_asyncio_future_blockingzTask z got Future z attached to a different looprGzTask cannot await on itself: Fr�z-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )rT�send�throw�getattrrr0rXr-r[r\rWr��add_done_callback� _Task__wakeuprSrRr�r��inspect�isgenerator� StopIterationrHrwrsrr��_cancelled_exc�KeyboardInterrupt� SystemExitrz� BaseException)r]r�r^rv�blocking�new_excr_s �r'�__step_run_and_handle_resultz!Task.__step_run_and_handle_result4se����z�z��G ��{����4������C���$�v�'A�4�H�H��#��$�$�V�,�D�J�J�>�*���x�|�!�*�$A�C�D�G��J�J�(�(����W�d�m�m�)�E�P�D�M���~�".�;�D�8�D�#F��� � �,�,� �K�K��$�-�-�-�I�D�D�?;@��7��0�0� �M�M�4�=�=�1�B�+1��(��,�,�#�/�/�6�6�(,�(<�(<� 7� >�49�� 1�0�D�-+�#�#'�(�&�� �<�=�G��J�J�(�(����W�d�m�m�)�E�&�D�!��� � �$�$�T�[�[�$�-�-�$�H��D��$�$�V�,�&�)�)-���v�j�B�C��� � �$�$��K�K��$�-�-�%�A��D� '�)=�f�Z�'H�I��� � �$�$��K�K��$�-�-�%�A��D�4�D��A� .�� � �$)��!����4�#7�#7��8���"�3�9�9�-��t�D��s�(�(� �"%�D���G�N���l�D��k"�:�.� ��G�!�#�&���� '��G�!�#�&�&�b�D��e '��d�D�s��%J�A5M�,AM�5A0M�)AM�03M�&AM�AM� M�AK�M�M�5L� M�M�#L3�3M�?M�M�M�M�M!c�� |j�|j�d}y#t$r}|j|�Yd}~d}yd}~wwxYwr!)rvr\r�)r]�futurer�s r'�__wakeupz Task.__wakeupsH�� ��M�M�O� �K�K�M����� ��K�K������� �s�%� A�A�Ar!)�__name__� __module__�__qualname__rLrIrf�classmethodr�__class_getitem__rjrlrorqr9rwrzr~r�r�r�r�rZr\r�r�� __classcell__�r_s@r'rrSs����+�. ��%)��d�"�!�> �$�L�1��+���� �I�L�"&�7�.$(�d� ?�(�T+� +�)�&�"I�Vr(r�r?rCc�� tj�}|�|j|�}n|j||��}t||�|S)NrG)rr"rr@)r^r?rCr&r>s r'rr�sP����"�"�$�D�������%������g��6���4����Kr()�timeout�return_whenc��K� tj|�stj|�r!t dt|�j����|std��|tttfvrtd|����t|�}td�|D��rt d��tj�}t||||��d{���S7��w)Nzexpect a list of futures, not zSet of Tasks/Futures is empty.zInvalid return_when value: c3�FK�|]}tj|����y�wr!)rrK)�.0�fs r'� <genexpr>zwait.<locals>.<genexpr>�s���� 1�b��:�!�!�!�$�b�s�!z6Passing coroutines is forbidden, use tasks explicitly.)r�isfuturerrKrM�typer�� ValueErrorrrr�set�anyrr"�_wait)�fsr�r�r&s r'rr�s�����������z�5�5�b�9��8��b��9J�9J�8K�L�M�M� ��9�:�:��?�O�]�K�K��6�{�m�D�E�E� �R��B� � 1�b� 1�1��P�Q�Q��"�"�$�D��r�7�K��6�6�6�6�s�CC� C�Cc�H�|j�s|jd�yyr!)r1rw)�waiter�argss r'�_release_waiterr��s���;�;�=����$��r(c��K� |�T|dkrOt|�}|j�r|j�St|��d{��� |j�Stj|�4�d{���|�d{���cddd��d{���S7�N#tj $r}t|�d}~wwxYw7�C7�;7�-#1�d{���7swYyxYw�w�Nr) r r1rv�_cancel_and_waitrr��TimeoutErrorrr�)�futr�r�s r'rr�s������D��w�!�|��C� ���8�8�:��:�:�<���s�#�#�#� (��:�:�<������(�(��y�)�(�(� $���(�(� (��C�'�� (��)����)��(�(�(�s��AC�B�C� B�C�3B7�4C�7B=�=B9�>B=�C� B;�C�B4�(B/�/B4�4C�9B=�;C�=C�C�C�Cc��2��� � K� |j�� d� |�|j|t� �� t|����� � fd�}|D]}|j |�� � �d{���� �� j�|D]}|j |�� t�t�}}|D]5}|j�r|j|��%|j|��7||fS7��#� �� j�|D]}|j |��wxYw�w)Nc�����dz��dks2�tk(s)�tk(rW|j�sF|j��5���j ��j�s�j d�yyyyy)Nrr)rr� cancelledryr�r1rw)r��counterr��timeout_handler�s ����r'�_on_completionz_wait.<locals>._on_completionst����1����q�L��?�*��?�*�A�K�K�M�01��� �0I��)��%�%�'��;�;�=��!�!�$�'�!�1J�5B�*r() � create_future� call_laterr��lenr�r��remove_done_callbackr�r1�add)r�r�r�r&r�r�r1�pendingr�r�r�s ` @@@r'r�r� s������ � � � !�F��N�������/�6�J���"�g�G� (��� ���N�+��3�����%��!�!�#��A� �"�"�>�2���E�3�5�'�D� ���6�6�8��H�H�Q�K��K�K��N� � ��=�� ���%��!�!�#��A� �"�"�>�2��s1�AD�C(�$C&�%C(�)A=D�&C(�(,D�Dc��4K� tj�}|j�}tjt |�}|j |� |j�|�d{���|j|�y7�#|j|�wxYw�wr!) rr"r�� functools�partialr�r�r�r�)r�r&r��cbs r'r�r�6s~����F��"�"�$�D� � � � !�F� � � �?�F� 3�B����"��%�� � ������ � ��$� ��� � ��$�s0�AB�B�)B�*B�.B�B�B�B)r�c#� �� � �K� tj|�stj|�r!t dt|�j����ddlm}|�� tj�}t|�D�chc]}t||����c}�d� �� �fd�}� � �fd��� fd�}�D]}|j����r|�|j||�� tt!���D]}|���� ycc}w�w)Nz#expect an iterable of futures, not r)�Queuer%c�x���D]$}|j���jd��&�j�yr!)r�� put_nowait�clear)r�r�r1�todos ���r'�_on_timeoutz!as_completed.<locals>._on_timeoutds2����A� �"�"�>�2��O�O�D�!�� � � �r(c�|���sy�j|��j|��s���j�yyyr!)�remover�r�)r�r1r�r�s ���r'r�z$as_completed.<locals>._on_completionjs;��������A���������2��!�!�#�3�tr(c���K��j��d{���}|�tj�|j�S7�&�wr!)r$rr�rv)r�r1s �r'� _wait_for_onez#as_completed.<locals>._wait_for_oners7������(�(�*����9��)�)�)��x�x�z�� �s�A�>�'A)rr�rrKrMr�r��queuesr�r�get_event_loopr�r r�r��ranger�)r�r�r�r&r�r�r��_r�r1r�r�s @@@@r'r r Hs�������"�����z�5�5�b�9��=�d�2�h�>O�>O�=P�Q�R�R���7�D�� � �"�D�14�R��9��A�M�!�$�'��9�D��N��$���� ���N�+����#�����+�>�� �3�t�9� ���o����9:�s�A;D�C>�A.Dc#�K� d��y�wr!�r�r(r'�__sleep0r��s����� �s� c��2K� |dkrt��d{���|Stj�}|j�}|j |t j||�} |�d{���|j�S7�g7�#|j�wxYw�wr�)r�rr"r�r�r�_set_result_unless_cancelledr�)�delayrvr&r��hs r'r r �s�����C���z��j���� ��"�"�$�D� � � � !�F������<�<��� (�A���|� ��� � ���� ��� �s:�B�A>�AB�$B�)B�*B�-B�B�B�Br%c�� tj|�r&|�"|tj|�urtd��|Sd}t j |�s.t j|�rd�}||�}d}ntd��|�tj�} |j|�S#t$r|r|j��wxYw)NzRThe future belongs to a different loop than the one specified as the loop argumentTc��"K�|�d{���S7��wr!r�)� awaitables r'�_wrap_awaitablez&ensure_future.<locals>._wrap_awaitable�s����&��&��s�� �Fz:An asyncio.Future, a coroutine or an awaitable is required)rr�r0r�rrKr��isawaitablerMrr�rr-�close)�coro_or_futurer&�should_closer�s r'r r �s��������'����G�,=�,=�n�,M� M��E�F� F����L��!�!�.�1����~�.� '�-�^�<�N� �L��*�+� +��|��$�$�&�������/�/������ � �"� ��s�B*�*Cc�(��eZdZ �fd�Zdd�Z�xZS)�_GatheringFuturec�B��t�|�|��||_d|_y)Nr%F)rHrI� _children�_cancel_requested)r]�childrenr&r_s �r'rIz_GatheringFuture.__init__�s"��� ���d��#�!���!&��r(c��|j�ryd}|jD]}|j|��s�d}�|rd|_|S)NFr�T)r1rr�r)r]r��ret�childs r'r�z_GatheringFuture.cancel�sH���9�9�;�����^�^�E��|�|��|�$���$��&*�D�"�� r(r!)r�r�r�rIr�r�r�s@r'rr�s����'�r(rF)�return_exceptionsc���� � �� |s7tj�}|j���jg��S�� � ��fd�}i}g�d� d� g}d}d�|D]�}||vrmt ||��}|�tj|�}||urd|_� dz � |||<|j�r|j|�n|j|�n||}�j|���t�|���|D] }||���S)Nc����dz ����j�r!|j�s|j�y�sV|j�r"|j�}�j |�y|j�}|��j |�y��k(r�g}�D]s}|j�r.tj|j�dn|j�}n"|j�}|�|j�}|j|��u�jr"|j�}�j |�y�j|�yy)Nr�)r1r�ryr�rzrr�r�rv�appendrrw) r�r��results�resr� nfinished�nfuts�outerr s �����r'�_done_callbackzgather.<locals>._done_callback�s,����Q�� ��=�E�J�J�L��=�=�?�� � ��� ��}�}���/�/�1���#�#�C�(���m�m�o���?��'�'��,������G����=�=�?�%�3�3�!�1�1�9���+�+�-�C��-�-�/�C��{�!�j�j�l�����s�#� �"�&�&��/�/�1���#�#�C�(�� � ��)�;r(rr%Fr)rr�r�rwr rr0rLr1r r�r)r �coros_or_futuresr&r� arg_to_fut� done_futs�argr�rrrrs` @@@@r'rr�s%����:��$�$�&���"�"�$�� �������5*�5*�n�J��H� �E��I��I��D��E����j� ���$�/�C��|��(�(��-���#�~� ,1��(��Q�J�E�!�J�s�O��x�x�z�� � ��%��%�%�n�5��S�/�C������/ �2 �X�D�1�E����s����Lr(c������ t|���j�r�Stj��}|j ���fd����fd�}�j���j|��S)Nc�0���j�r!|j�s|j�y|j�r�j�y|j�}|��j|�y�j |j��yr!)r�ryr�rzrwrv)�innerr�rs �r'�_inner_done_callbackz$shield.<locals>._inner_done_callback�sj����?�?���?�?�$����!���?�?���L�L�N��/�/�#�C����#�#�C�(�� � �����0r(c�J���j�s�j��yyr!)r1r�)rrrs ��r'�_outer_done_callbackz$shield.<locals>._outer_done_callback�s ����z�z�|��&�&�';�<�r()r r1rr0r�r�)rr&rrrrs @@@r'rrasp����@ �#��E��z�z�|������U�#�D���� �E�1�"=� ���0�1� ���0�1��Lr(c����� tj��std��tjj�����fd�}�j |��S)NzA coroutine object is requiredc���� tjt������y#ttf$r�t $r'}�j �r�j|��d}~wwxYw)Nr%)r� _chain_futurer r�r�r��set_running_or_notify_cancelrz)r�r^r�r&s ���r'�callbackz*run_coroutine_threadsafe.<locals>.callback�s]��� ��!�!�-��4�"@�&�I���-�.� ��� ��2�2�4��$�$�S�)��� �s�!%�A$�"A�A$)rrKrM� concurrentr�Future�call_soon_threadsafe)r^r&r"r�s`` @r'rr�sR�����!�!�$�'��8�9�9� � � � &� &� (�F�� ���h�'��Mr(c��� ddd��fd� }|S)Nr�c����||||d��S)NTrBr�)r&r^r?rC�custom_task_constructors �r'�factoryz*create_eager_task_factory.<locals>.factory�s���&��t�$��T�K� Kr(r�)r(r)s` r'rr�s����$%)�$�K��Nr(c�0� tj|�yr!)r,r��r>s r'rr�s��E�����r(c�0� tj|�yr!)r+r�r+s r'r�r��s��@����T�r(c�h�tj|�}|�td|�d|�d���|t|<y)NzCannot enter into task z while another task z is being executed.�r#r$r-�r&r>rs r'rr�sL��!�%�%�d�+�L����4�T�H�=#�#/�"2�2E�G�H� H��N�4�r(c�h�tj|�}||urtd|�d|�d���t|=y)Nz Leaving task z! does not match the current task �.r.r/s r'rr�sJ��!�%�%�d�+�L��4���]�4�(�3/�/;�.>�a�A�B� B��t�r(c�X�tj|�}|� t|=|S|t|<|Sr!)r#r$)r&r>r�s r'r�r��s9���"�"�4�(�I��|��4� ��� $��t���r(c�0� tj|�yr!)r,�discardr+s r'rrs��1����T�"r(c�0� tj|�yr!)r+r4r+s r'r�r� s��@�����r()rr�rr�rrr�r,r+r#rr!)O�__all__�concurrent.futuresr#rUr�r�r.�typesr;�weakrefrrrrrrrr�count�__next__rNrrr@� _PyFuturer�_PyTask�_asyncio�_CTask�ImportErrorrrrrrr�rr�r�r � coroutiner�r r r$rrrrrr�WeakSetr,r�r+r#rr�rrr�rr��_py_current_task�_py_register_task�_py_register_eager_task�_py_unregister_task�_py_unregister_eager_task�_py_enter_task�_py_leave_task�_py_swap_current_task�_c_current_task�_c_register_task�_c_register_eager_task�_c_unregister_task�_c_unregister_eager_task� _c_enter_task� _c_leave_task�_c_swap_current_taskr�r(r'�<module>rSsM��6������������������ %�Y�_�_�Q�'�0�0��$�>�6 �z�7���z�z ��"�� �M�M�!�D�6�#�D� �$�$�$�4�4���$�$�4�4���"�"�0�0� �#� �7�@ � 0�d)�X%�$!%�6�r��� �� ��"+/��@�w�~�~��:16�C�L?�D�.�4/�t�4��#�7�?�?�$���u����� � ���#� � ��"��.��&��2������*��.�(�(�(�(�#�O�%��1��)��5���M��M�-���i� �� ��T� �� �s$� F4� G�4F=�<F=�G�G__pycache__/tasks.cpython-312.pyc000064400000116570151706172560012630 0ustar00� T��h����dZdZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlmZddlm Z ddlmZddlmZdd lmZdd lmZddlmZej&d�j(Zd/d�Zd/d �Zd�ZGd�dej2�ZeZ ddlZej4xZZddd�d�Zej"j@Z ej"jBZ!ej"jDZ"de"d�d�Z#d�Z$d�Z%d�Z&d�Z'dd�d�Z(ejRd��Z*d/d�Z+dd�d�Z,Gd�d ejZ�Z.d!d"�d#�Z/d$�Z0d%�Z1d&�Z2e2e�Z3e jh�Z5e6�Z7iZ8d'�Z9d(�Z:d)�Z;d*�Z<d+�Z=d,�Z>d-�Z?eZ@e9ZAe:ZBe>ZCe?ZDe;ZEe<ZFe=ZG dd.lm9Z9m:Z:m>Z>m?Z?m;Z;m<Z<m=Z=m5Z5m7Z7m8Z8mZeZHe9ZIe:ZJe>ZKe?ZLe;ZMe<ZNe=ZOy#e$rY��wxYw#e$rYywxYw)0z0Support for tasks, coroutines and the scheduler.)�Task�create_task�FIRST_COMPLETED�FIRST_EXCEPTION� ALL_COMPLETED�wait�wait_for�as_completed�sleep�gather�shield� ensure_future�run_coroutine_threadsafe�current_task� all_tasks�create_eager_task_factory�eager_task_factory�_register_task�_unregister_task�_enter_task�_leave_task�N)�GenericAlias�)� base_tasks)� coroutines)�events)� exceptions)�futures)�timeoutsc�X�|�tj�}tj|�S)z!Return a currently executed task.)r�get_running_loop�_current_tasks�get��loops �&/usr/lib64/python3.12/asyncio/tasks.pyrr$s&���|��&�&�(�����d�#�#�c�N�|�tj�}tt�}d}d} tt�} t j||�D�chc]+}tj|�|ur|j�s|��-c}S#t $r|dz }|dk\r�YnwxYw�wcc}w)z'Return a set of all tasks for the loop.Nrri�)rr!�list�_eager_tasks�_scheduled_tasks�RuntimeError� itertools�chainr� _get_loop�done)r%�eager_tasks�scheduled_tasks�i�ts r&rr+s����|��&�&�(���|�$�K��O� �A� � �"�#3�4�O� � �����D�>�D�!�� � ��#�t�+�A�F�F�H� �D�>�>�� � � ��F�A��D�y��� ����>s�B�0B"�B�Bc��|� |j}||�yy#t$rtjdtd��YywxYw)Nz~Task.set_name() was added in Python 3.8, the method support will be mandatory for third-party task implementations since 3.13.�)� stacklevel)�set_name�AttributeError�warnings�warn�DeprecationWarning)�task�namer8s r&�_set_task_namer?FsM���� ��}�}�H� �T�N���� 8��M�M�9�)�Q� 8� 8�s��%A�Ac����eZdZdZdZddddd��fd� Z�fd�Zee�Z d�Z d �Zd �Zd�Z d�Zd �Zd�Zdd�d�Zddd�d�Zdd�Zd�Zd�Zd�Zdd�Z�fd�Zd�Z�xZS)rz A coroutine wrapped in a Future.TNF�r%r>�context�eager_startc�F��t�|�|��|jr |jd=tj|�sd|_t d|����|�dt���|_nt|�|_d|_ d|_d|_||_ |�tj�|_n||_|r+|j"j%�r|j'�y|j"j)|j*|j ��t-|�y)Nr$���Fza coroutine was expected, got zTask-r�rB)�super�__init__�_source_tracebackr�iscoroutine�_log_destroy_pending� TypeError�_task_name_counter�_name�str�_num_cancels_requested�_must_cancel�_fut_waiter�_coro�contextvars�copy_context�_context�_loop� is_running�_Task__eager_start� call_soon�_Task__stepr)�self�coror%r>rBrC� __class__s �r&rHz Task.__init__os���� ���d��#��!�!��&�&�r�*��%�%�d�+�).�D�%��<�T�H�E�F�F��<� �!3�!5� 6�7�D�J��T��D�J�&'��#�!�������� ��?�'�4�4�6�D�M�#�D�M��4�:�:�0�0�2���� ��J�J� � ����d�m�m� �D��4� r'c����|jtjk(rG|jr;|dd�}|jr|j|d<|j j |�t�|�!�y)Nz%Task was destroyed but it is pending!)r=�message�source_traceback) �_stater�_PENDINGrKrIrW�call_exception_handlerrG�__del__)r\rBr^s �r&rezTask.__del__�sb����;�;�'�*�*�*�t�/H�/H��B��G��%�%�.2�.D�.D��*�+��J�J�-�-�g�6� ���r'c�,�tj|�S�N)r� _task_repr�r\s r&�__repr__z Task.__repr__�s���$�$�T�*�*r'c��|jSrg)rSris r&�get_coroz Task.get_coro�����z�z�r'c��|jSrg)rVris r&�get_contextzTask.get_context�s���}�}�r'c��|jSrg)rNris r&�get_namez Task.get_name�rmr'c�$�t|�|_yrg)rOrN)r\�values r&r8z Task.set_name�s ����Z�� r'c��td��)Nz*Task does not support set_result operation�r,)r\�results r&� set_resultzTask.set_result�s���G�H�Hr'c��td��)Nz-Task does not support set_exception operationru)r\� exceptions r&� set_exceptionzTask.set_exception�s���J�K�Kr')�limitc�.�tj||�S)a�Return the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. )r�_task_get_stack)r\r{s r&� get_stackzTask.get_stack�s��*�)�)�$��6�6r')r{�filec�0�tj|||�S)anPrint the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. )r�_task_print_stack)r\r{rs r&�print_stackzTask.print_stack�s���+�+�D�%��>�>r'c���d|_|j�ry|xjdz c_|j�|jj |��ryd|_||_y)a�Request that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). This also increases the task's count of cancellation requests. Fr��msgT)�_log_tracebackr0rPrR�cancelrQ�_cancel_message)r\r�s r&r�zTask.cancel�sf��,$����9�9�;���#�#�q�(�#����'����&�&�3�&�/�� ���"���r'c��|jS)z�Return the count of the task's cancellation requests. This count is incremented when .cancel() is called and may be decremented using .uncancel(). �rPris r&� cancellingzTask.cancelling�s���*�*�*r'c�b�|jdkDr|xjdzc_|jS)z�Decrement the task's count of cancellation requests. This should be called by the party that called `cancel()` on the task beforehand. Returns the remaining number of cancellation requests. rrr�ris r&�uncancelz Task.uncancels/���&�&��*��'�'�1�,�'��*�*�*r'c��t|j|�} t|� |jj |j d�t |� t|j|�}||usJ� |j�r d|_d}yt|�y#t |�wxYw#|j�r d|_d}wt|�wxYw# t|j|�}||usJ� |j�r d|_d}wt|�w#|j�r d|_d}wt|�wxYwxYwrg) �_swap_current_taskrW�_register_eager_taskrV�run�!_Task__step_run_and_handle_result�_unregister_eager_taskr0rSr)r\� prev_task�curtasks r&� __eager_startzTask.__eager_starts��&�t�z�z�4�8� � )� ��&� -�� � �!�!�$�"C�"C�T�J�&�t�,� )�,�T�Z�Z��C���$��&���9�9�;�!%�D�J��D�"�4�(��'�t�,���9�9�;�!%�D�J��D�"�4�(�� )�,�T�Z�Z��C���$��&���9�9�;�!%�D�J��D�"�4�(�� �9�9�;�!%�D�J��D�"�4�(�sF�C�&B� C�B*� B'�'C�*'C�E�D�3&E�'E�Ec��|j�rtjd|�d|����|jr1t |tj �s|j �}d|_d|_t|j|� |j|�t|j|�d}y#t|j|�d}wxYw)Nz_step(): already done: z, F)r0r�InvalidStateErrorrQ� isinstance�CancelledError�_make_cancelled_errorrRrrWr�r)r\�excs r&�__stepzTask.__step#s����9�9�;��.�.�)�$���C�7�;�=� =�����c�:�#<�#<�=��0�0�2�� %�D������D�J�J��%� ��-�-�c�2��� � �D�)��D�� �� � �D�)��D�s�B1�1Cc����|j} |�|jd�}n|j|�}t|dd�}|��lt j |�|jurGtd|�d|�d��}|jj|j||j��d}y|r�||urCtd|���}|jj|j||j��d}yd|_|j|j|j��||_|j�rN|jj!|j"���r'd|_ d}ytd |�d |���}|jj|j||j�� d}y|�4|jj|j|j��d}yt%j&|�rFtd|�d |���}|jj|j||j��d}ytd|���}|jj|j||j�� d}yd}y#t($rS}|jr"d|_t*�|�A|j"��nt*�|�Y|j.�Yd}~d}yd}~wt0j2$r!}||_t*�|�A�Yd}~d}yd}~wt6t8f$r}t*�|�u|��d}~wt<$r}t*�|�u|�Yd}~d}yd}~wwxYw#d}wxYw) N�_asyncio_future_blockingzTask z got Future z attached to a different looprFzTask cannot await on itself: Fr�z-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )rS�send�throw�getattrrr/rWr,rZr[rVr��add_done_callback� _Task__wakeuprRrQr�r��inspect�isgenerator� StopIterationrGrwrsrr��_cancelled_exc�KeyboardInterrupt� SystemExitrz� BaseException)r\r�r]rv�blocking�new_excr^s �r&�__step_run_and_handle_resultz!Task.__step_run_and_handle_result4se����z�z��G ��{����4������C���$�v�'A�4�H�H��#��$�$�V�,�D�J�J�>�*���x�|�!�*�$A�C�D�G��J�J�(�(����W�d�m�m�)�E�P�D�M���~�".�;�D�8�D�#F��� � �,�,� �K�K��$�-�-�-�I�D�D�?;@��7��0�0� �M�M�4�=�=�1�B�+1��(��,�,�#�/�/�6�6�(,�(<�(<� 7� >�49�� 1�0�D�-+�#�#'�(�&�� �<�=�G��J�J�(�(����W�d�m�m�)�E�&�D�!��� � �$�$�T�[�[�$�-�-�$�H��D��$�$�V�,�&�)�)-���v�j�B�C��� � �$�$��K�K��$�-�-�%�A��D� '�)=�f�Z�'H�I��� � �$�$��K�K��$�-�-�%�A��D�4�D��A� .�� � �$)��!����4�#7�#7��8���"�3�9�9�-��t�D��s�(�(� �"%�D���G�N���l�D��k"�:�.� ��G�!�#�&���� '��G�!�#�&�&�b�D��e '��d�D�s��%J�A5M�,AM�5A0M�)AM�03M�&AM�AM� M�AK�M�M�5L� M�M�#L3�3M�?M�M�M�M�M!c�� |j�|j�d}y#t$r}|j|�Yd}~d}yd}~wwxYwrg)rvr[r�)r\�futurer�s r&�__wakeupz Task.__wakeupsH�� ��M�M�O� �K�K�M����� ��K�K������� �s�%� A�A�Arg)�__name__� __module__�__qualname__�__doc__rKrHre�classmethodr�__class_getitem__rjrlrorqr8rwrzr~r�r�r�r�rYr[r�r�� __classcell__�r^s@r&rrSs����+�. ��%)��d�"�!�> �$�L�1��+���� �I�L�"&�7�.$(�d� ?�(�T+� +�)�&�"I�Vr'r�r>rBc��tj�}|�|j|�}n|j||��}t||�|S)z]Schedule the execution of a coroutine object in a spawn task. Return a Task object. rF)rr!rr?)r]r>rBr%r=s r&rr�sK�� �"�"�$�D�������%������g��6���4����Kr')�timeout�return_whenc��K�tj|�stj|�r!t dt|�j����|std��|tttfvrtd|����t|�}td�|D��rt d��tj�}t||||��d{���S7��w)a}Wait for the Futures or Tasks given by fs to complete. The fs iterable must not be empty. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending). Usage: done, pending = await asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. zexpect a list of futures, not zSet of Tasks/Futures is empty.zInvalid return_when value: c3�FK�|]}tj|����y�wrg)rrJ)�.0�fs r&� <genexpr>zwait.<locals>.<genexpr>�s���� 1�b��:�!�!�!�$�b�s�!z6Passing coroutines is forbidden, use tasks explicitly.N)r�isfuturerrJrL�typer�� ValueErrorrrr�set�anyrr!�_wait)�fsr�r�r%s r&rr�s����� �����z�5�5�b�9��8��b��9J�9J�8K�L�M�M� ��9�:�:��?�O�]�K�K��6�{�m�D�E�E� �R��B� � 1�b� 1�1��P�Q�Q��"�"�$�D��r�7�K��6�6�6�6�s�CC� C� Cc�H�|j�s|jd�yyrg)r0rw)�waiter�argss r&�_release_waiterr��s���;�;�=����$��r'c��K�|�T|dkrOt|�}|j�r|j�St|��d{��� |j�Stj|�4�d{���|�d{���cddd��d{���S7�N#tj $r}t|�d}~wwxYw7�C7�;7�-#1�d{���7swYyxYw�w)a�Wait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. If the task suppresses the cancellation and returns a value instead, that value is returned. This function is a coroutine. Nr) r r0rv�_cancel_and_waitrr��TimeoutErrorrr�)�futr�r�s r&rr�s�����F��w�!�|��C� ���8�8�:��:�:�<���s�#�#�#� (��:�:�<������(�(��y�)�(�(� $���(�(� (��C�'�� (��)����)��(�(�(�s��AC�B�C� B�C�2B6�3C�6B<�<B8�=B<�C�B:� C�B3�'B.�.B3�3C�8B<�:C�<C�C�C� Cc��B��� � K�|sJd��|j�� d� |�|j|t� �� t|����� � fd�}|D]}|j |�� � �d{���� �� j�|D]}|j |�� t�t�}}|D]5}|j�r|j|��%|j|��7||fS7��#� �� j�|D]}|j |��wxYw�w)zVInternal helper for wait(). The fs argument must be a collection of Futures. zSet of Futures is empty.Nc�����dz��dks2�tk(s)�tk(rW|j�sF|j��5���j ��j�s�j d�yyyyy)Nrr)rr� cancelledryr�r0rw)r��counterr��timeout_handler�s ����r&�_on_completionz_wait.<locals>._on_completionst����1����q�L��?�*��?�*�A�K�K�M�01��� �0I��)��%�%�'��;�;�=��!�!�$�'�!�1J�5B�*r') � create_future� call_laterr��lenr�r��remove_done_callbackr�r0�add)r�r�r�r%r�r�r0�pendingr�r�r�s ` @@@r&r�r� s����� �)�)�)�2� � � � !�F��N�������/�6�J���"�g�G� (��� ���N�+��3�����%��!�!�#��A� �"�"�>�2���E�3�5�'�D� ���6�6�8��H�H�Q�K��K�K��N� � ��=�� ���%��!�!�#��A� �"�"�>�2��s1�A D�'C0�,C.�-C0�1A=D�.C0�0,D�Dc��2K�tj�}|j�}tjt |�}|j |� |j�|�d{���|j|�y7�#|j|�wxYw�w)z<Cancel the *fut* future or task and wait until it completes.N) rr!r�� functools�partialr�r�r�r�)r�r%r��cbs r&r�r�6s}�����"�"�$�D� � � � !�F� � � �?�F� 3�B����"��%�� � ������ � ��$� ��� � ��$�s0�AB�B�(A?�)B�-B�?B�B�B)r�c#��� � �K�tj|�stj|�r!t dt|�j����ddlm}|�� tj�}t|�D�chc]}t||����c}�d� �� �fd�}� � �fd��� fd�}�D]}|j����r|�|j||�� tt!���D]}|���� ycc}w�w) a^Return an iterator whose values are coroutines. When waiting for the yielded coroutines you'll get the results (or exceptions!) of the original Futures (or coroutines), in the order in which and as soon as they complete. This differs from PEP 3148; the proper way to use this is: for f in as_completed(fs): result = await f # The 'await' may raise. # Use result. If a timeout is specified, the 'await' will raise TimeoutError when the timeout occurs before all Futures are done. Note: The futures 'f' are not necessarily members of fs. z#expect an iterable of futures, not r)�Queuer$Nc�x���D]$}|j���jd��&�j�yrg)r�� put_nowait�clear)r�r�r0�todos ���r&�_on_timeoutz!as_completed.<locals>._on_timeoutds2����A� �"�"�>�2��O�O�D�!�� � � �r'c�|���sy�j|��j|��s���j�yyyrg)�remover�r�)r�r0r�r�s ���r&r�z$as_completed.<locals>._on_completionjs;��������A���������2��!�!�#�3�tr'c���K��j��d{���}|�tj�|j�S7�&�wrg)r#rr�rv)r�r0s �r&� _wait_for_onez#as_completed.<locals>._wait_for_oners7������(�(�*����9��)�)�)��x�x�z�� �s�A�>�'A)rr�rrJrLr�r��queuesr�r�get_event_loopr�r r�r��ranger�)r�r�r�r%r�r�r��_r�r0r�r�s @@@@r&r r Hs������$�����z�5�5�b�9��=�d�2�h�>O�>O�=P�Q�R�R���7�D�� � �"�D�14�R��9��A�M�!�$�'��9�D��N��$���� ���N�+����#�����+�>�� �3�t�9� ���o����9:�s�A:D�C=�A.Dc#�K�d��y�w)z�Skip one event loop run cycle. This is a private helper for 'asyncio.sleep()', used when the 'delay' is set to 0. It uses a bare 'yield' expression (which Task.__step knows how to handle) instead of creating a Future object. N�r�r'r&�__sleep0r��s���� �s�c��0K�|dkrt��d{���|Stj�}|j�}|j |t j||�} |�d{���|j�S7�g7�#|j�wxYw�w)z9Coroutine that completes after a given time (in seconds).rN)r�rr!r�r�r�_set_result_unless_cancelledr�)�delayrvr%r��hs r&r r �s������z��j���� ��"�"�$�D� � � � !�F������<�<��� (�A���|� ��� � ���� ��� �s:�B�A=�AB�#B�(A?�)B�,B�?B�B�Br$c��tj|�r&|�"|tj|�urtd��|Sd}t j |�s.t j|�rd�}||�}d}ntd��|�tj�} |j|�S#t$r|r|j��wxYw)zmWrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. zRThe future belongs to a different loop than the one specified as the loop argumentTc��"K�|�d{���S7��wrgr�)� awaitables r&�_wrap_awaitablez&ensure_future.<locals>._wrap_awaitable�s����&��&��s�� �Fz:An asyncio.Future, a coroutine or an awaitable is required)rr�r/r�rrJr��isawaitablerLrr�rr,�close)�coro_or_futurer%�should_closer�s r&r r �s��� ����'����G�,=�,=�n�,M� M��E�F� F����L��!�!�.�1����~�.� '�-�^�<�N� �L��*�+� +��|��$�$�&�������/�/������ � �"� ��s�B)�)Cc�*��eZdZdZ�fd�Zdd�Z�xZS)�_GatheringFuturez�Helper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. c�J��|�J�t�|�|��||_d|_y)Nr$F)rGrH� _children�_cancel_requested)r\�childrenr%r^s �r&rHz_GatheringFuture.__init__�s.������� ���d��#�!���!&��r'c��|j�ryd}|jD]}|j|��s�d}�|rd|_|S)NFr�T)r0rr�r)r\r��ret�childs r&r�z_GatheringFuture.cancel�sH���9�9�;�����^�^�E��|�|��|�$���$��&*�D�"�� r'rg)r�r�r�r�rHr�r�r�s@r&rr�s����'�r'rF)�return_exceptionsc���� � ��|s7tj�}|j���jg��S�� � ��fd�}i}g�d� d� g}d}d�|D]�}||vrmt ||��}|�tj|�}||urd|_� dz � |||<|j�r|j|�n|j|�n||}�j|���t�|���|D] }||���S)a�Return a future aggregating results from the given coroutines/futures. Coroutines will be wrapped in a future and scheduled in the event loop. They will not necessarily be scheduled in the same order as passed in. All futures must share the same event loop. If all the tasks are done successfully, the returned future's result is the list of results (in the order of the original sequence, not necessarily the order of results arrival). If *return_exceptions* is True, exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first raised exception will be immediately propagated to the returned future. Cancellation: if the outer Future is cancelled, all children (that have not completed yet) are also cancelled. If any child is cancelled, this is treated as if it raised CancelledError -- the outer Future is *not* cancelled in this case. (This is to prevent the cancellation of one child to cause other children to be cancelled.) If *return_exceptions* is False, cancelling gather() after it has been marked done won't cancel any submitted awaitables. For instance, gather can be marked done after propagating an exception to the caller, therefore, calling ``gather.cancel()`` after catching an exception (raised by one of the awaitables) from gather won't cancel any other awaitables. c����dz ����j�r!|j�s|j�y�sV|j�r"|j�}�j |�y|j�}|��j |�y��k(r�g}�D]s}|j�r.tj|j�dn|j�}n"|j�}|�|j�}|j|��u�jr"|j�}�j |�y�j|�yy)Nr�)r0r�ryr�rzrr�r�rv�appendrrw) r�r��results�resr� nfinished�nfuts�outerr s �����r&�_done_callbackzgather.<locals>._done_callback�s,����Q�� ��=�E�J�J�L��=�=�?�� � ��� ��}�}���/�/�1���#�#�C�(���m�m�o���?��'�'��,������G����=�=�?�%�3�3�!�1�1�9���+�+�-�C��-�-�/�C��{�!�j�j�l�����s�#� �"�&�&��/�/�1���#�#�C�(�� � ��)�;r'rNr$Fr)rr�r�rwr rr/rKr0r r�r)r �coros_or_futuresr%r� arg_to_fut� done_futs�argr�rrrrs` @@@@r&rr�s ���<��$�$�&���"�"�$�� �������5*�5*�n�J��H� �E��I��I��D��E����j� ���$�/�C��|��(�(��-���#�~� ,1��(��Q�J�E�!�J�s�O��x�x�z�� � ��%��%�%�n�5��S�/�C������/ �2 �X�D�1�E����s����Lr'c������t|���j�r�Stj��}|j ���fd����fd�}�j���j|��S)a�Wait for a future, shielding it from cancellation. The statement task = asyncio.create_task(something()) res = await shield(task) is exactly equivalent to the statement res = await something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: task = asyncio.create_task(something()) try: res = await shield(task) except CancelledError: res = None Save a reference to tasks passed to this function, to avoid a task disappearing mid-execution. The event loop only keeps weak references to tasks. A task that isn't referenced elsewhere may get garbage collected at any time, even before it's done. c�0���j�r!|j�s|j�y|j�r�j�y|j�}|��j|�y�j |j��yrg)r�ryr�rzrwrv)�innerr�rs �r&�_inner_done_callbackz$shield.<locals>._inner_done_callback�sj����?�?���?�?�$����!���?�?���L�L�N��/�/�#�C����#�#�C�(�� � �����0r'c�J���j�s�j��yyrg)r0r�)rrrs ��r&�_outer_done_callbackz$shield.<locals>._outer_done_callback�s ����z�z�|��&�&�';�<�r')r r0rr/r�r�)rr%rrrrs @@@r&rrask���B �#��E��z�z�|������U�#�D���� �E�1�"=� ���0�1� ���0�1��Lr'c�����tj��std��tjj�����fd�}�j |��S)zsSubmit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. zA coroutine object is requiredc���� tjt������y#ttf$r�t $r'}�j �r�j|��d}~wwxYw)Nr$)r� _chain_futurer r�r�r��set_running_or_notify_cancelrz)r�r]r�r%s ���r&�callbackz*run_coroutine_threadsafe.<locals>.callback�s]��� ��!�!�-��4�"@�&�I���-�.� ��� ��2�2�4��$�$�S�)��� �s�!%�A$�"A�A$)rrJrL� concurrentr�Future�call_soon_threadsafe)r]r%r"r�s`` @r&rr�sM��� �!�!�$�'��8�9�9� � � � &� &� (�F�� ���h�'��Mr'c���ddd��fd� }|S)a=Create a function suitable for use as a task factory on an event-loop. Example usage: loop.set_task_factory( asyncio.create_eager_task_factory(my_task_constructor)) Now, tasks created will be started immediately (rather than being first scheduled to an event loop). The constructor argument can be any callable that returns a Task-compatible object and has a signature compatible with `Task.__init__`; it must have the `eager_start` keyword argument. Most applications will use `Task` for `custom_task_constructor` and in this case there's no need to call `create_eager_task_factory()` directly. Instead the global `eager_task_factory` instance can be used. E.g. `loop.set_task_factory(asyncio.eager_task_factory)`. Nr�c����||||d��S)NTrAr�)r%r]r>rB�custom_task_constructors �r&�factoryz*create_eager_task_factory.<locals>.factory�s���&��t�$��T�K� Kr'r�)r(r)s` r&rr�s���&%)�$�K��Nr'c�.�tj|�y)z;Register an asyncio Task scheduled to run on an event loop.N)r+r��r=s r&rr�s������r'c�.�tj|�y)z6Register an asyncio Task about to be eagerly executed.N)r*r�r+s r&r�r��s�����T�r'c�h�tj|�}|�td|�d|�d���|t|<y)NzCannot enter into task z while another task z is being executed.�r"r#r,�r%r=rs r&rr�sL��!�%�%�d�+�L����4�T�H�=#�#/�"2�2E�G�H� H��N�4�r'c�h�tj|�}||urtd|�d|�d���t|=y)Nz Leaving task z! does not match the current task �.r.r/s r&rr�sJ��!�%�%�d�+�L��4���]�4�(�3/�/;�.>�a�A�B� B��t�r'c�X�tj|�}|� t|=|S|t|<|Srg)r"r#)r%r=r�s r&r�r��s9���"�"�4�(�I��|��4� ��� $��t���r'c�.�tj|�y)z'Unregister a completed, scheduled Task.N)r+�discardr+s r&rrs�����T�"r'c�.�tj|�y)z6Unregister a task which finished its first eager step.N)r*r4r+s r&r�r� s������r')rr�rr�rrr�r+r*r"rrg)Pr��__all__�concurrent.futuresr#rTr�r�r-�typesr:�weakrefrrrrrrrr�count�__next__rMrrr?� _PyFuturer�_PyTask�_asyncio�_CTask�ImportErrorrrrrrr�rr�r�r � coroutiner�r r r$rrrrrr�WeakSetr+r�r*r"rr�rrr�rr��_py_current_task�_py_register_task�_py_register_eager_task�_py_unregister_task�_py_unregister_eager_task�_py_enter_task�_py_leave_task�_py_swap_current_task�_c_current_task�_c_register_task�_c_register_eager_task�_c_unregister_task�_c_unregister_eager_task� _c_enter_task� _c_leave_task�_c_swap_current_taskr�r'r&�<module>rSsM��6������������������ %�Y�_�_�Q�'�0�0��$�>�6 �z�7���z�z ��"�� �M�M�!�D�6�#�D� �$�$�$�4�4���$�$�4�4���"�"�0�0� �#� �7�@ � 0�d)�X%�$!%�6�r��� �� ��"+/��@�w�~�~��:16�C�L?�D�.�4/�t�4��#�7�?�?�$���u����� � ���#� � ��"��.��&��2������*��.�(�(�(�(�#�O�%��1��)��5���M��M�-���i� �� ��T� �� �s$�F5� G�5F>�=F>�G �G __pycache__/threads.cpython-312.opt-1.pyc000064400000002354151706172560014066 0ustar00� T��h��.�dZddlZddlZddlmZdZd�Zy)z6High-level support for working with threads in asyncio�N�)�events)� to_threadc���K�tj�}tj�}t j |j|g|��i|��}|jd|��d{���S7��w)a�Asynchronously run function *func* in a separate thread. Any *args and **kwargs supplied for this function are directly passed to *func*. Also, the current :class:`contextvars.Context` is propagated, allowing context variables from the main thread to be accessed in the separate thread. Return a coroutine that can be awaited to get the eventual result of *func*. N)r�get_running_loop�contextvars�copy_context� functools�partial�run�run_in_executor)�func�args�kwargs�loop�ctx� func_calls �(/usr/lib64/python3.12/asyncio/threads.pyrrs]�����"�"�$�D� � "� "� $�C��!�!�#�'�'�4�A�$�A�&�A�I��%�%�d�I�6�6�6�6�s�A"A+�$A)�%A+)�__doc__r r�r�__all__r��r�<module>rs��<������ 7r__pycache__/threads.cpython-312.opt-2.pyc000064400000001445151706172560014067 0ustar00� T��h��,� ddlZddlZddlmZdZd�Zy)�N�)�events)� to_threadc���K� tj�}tj�}t j |j|g|��i|��}|jd|��d{���S7��w)N)r�get_running_loop�contextvars�copy_context� functools�partial�run�run_in_executor)�func�args�kwargs�loop�ctx� func_calls �(/usr/lib64/python3.12/asyncio/threads.pyrrsb������"�"�$�D� � "� "� $�C��!�!�#�'�'�4�A�$�A�&�A�I��%�%�d�I�6�6�6�6�s�A#A,�%A*�&A,)r r�r�__all__r��r�<module>rs��<������ 7r__pycache__/threads.cpython-312.pyc000064400000002354151706172560013127 0ustar00� T��h��.�dZddlZddlZddlmZdZd�Zy)z6High-level support for working with threads in asyncio�N�)�events)� to_threadc���K�tj�}tj�}t j |j|g|��i|��}|jd|��d{���S7��w)a�Asynchronously run function *func* in a separate thread. Any *args and **kwargs supplied for this function are directly passed to *func*. Also, the current :class:`contextvars.Context` is propagated, allowing context variables from the main thread to be accessed in the separate thread. Return a coroutine that can be awaited to get the eventual result of *func*. N)r�get_running_loop�contextvars�copy_context� functools�partial�run�run_in_executor)�func�args�kwargs�loop�ctx� func_calls �(/usr/lib64/python3.12/asyncio/threads.pyrrs]�����"�"�$�D� � "� "� $�C��!�!�#�'�'�4�A�$�A�&�A�I��%�%�d�I�6�6�6�6�s�A"A+�$A)�%A+)�__doc__r r�r�__all__r��r�<module>rs��<������ 7r__pycache__/timeouts.cpython-312.opt-1.pyc000064400000016645151706172560014315 0ustar00� T��h�����ddlZddlmZddlmZmZmZddlmZddlm Z ddlm Z dZGd �d ej�Z eGd�d��Zd eedefd�Zdeedefd�Zy)�N)� TracebackType)�final�Optional�Type�)�events)� exceptions)�tasks)�Timeout�timeout� timeout_atc� �eZdZdZdZdZdZdZy)�_State�created�active�expiring�expired�finishedN)�__name__� __module__�__qualname__�CREATED�ENTERED�EXPIRING�EXPIRED�EXITED���)/usr/lib64/python3.12/asyncio/timeouts.pyrrs���G��G��H��G� �Frrc ��eZdZdZdeeddfd�Zdeefd�Zdeeddfd�Zde fd�Z defd �Zdd �Z deeedeed eedee fd�Zdd�Zy)rz�Asynchronous context manager for cancelling overdue coroutines. Use `timeout()` or `timeout_at()` rather than instantiating this class directly. �when�returnNc�X�tj|_d|_d|_||_y)z�Schedule a timeout that will trigger at a given loop time. - If `when` is `None`, the timeout will never trigger. - If `when < loop.time()`, the timeout will trigger on the next iteration of the event loop. N)rr�_state�_timeout_handler�_task�_when)�selfr!s r�__init__zTimeout.__init__!s%���n�n���>B���+/�� ��� rc��|jS)zReturn the current deadline.)r'�r(s rr!zTimeout.when.s���z�z�rc��|jtjurJ|jtjurt d��t d|jj �d���||_|j�|jj�|�d|_ytj�}||j�kr!|j|j�|_y|j||j�|_y)zReschedule the timeout.zTimeout has not been enteredzCannot change state of z TimeoutN)r$rrr�RuntimeError�valuer'r%�cancelr�get_running_loop�time� call_soon�_on_timeout�call_at)r(r!�loops r� reschedulezTimeout.reschedule2s����;�;�f�n�n�,��{�{�f�n�n�,�"�#A�B�B��)�$�+�+�*;�*;�)<�H�E�� ��� �� � �,��!�!�(�(�*��<�$(�D�!��*�*�,�D��t�y�y�{�"�(,���t�7G�7G�(H��%�(,���T�4�;K�;K�(L��%rc�Z�|jtjtjfvS)z$Is timeout expired during execution?)r$rrrr+s rrzTimeout.expiredIs���{�{�v������?�?�?rc��dg}|jtjur8|j�t |jd�nd}|jd|���dj |�}d|jj�d|�d�S)N��zwhen=� z <Timeout [�]�>)r$rrr'�round�append�joinr.)r(�infor!�info_strs r�__repr__zTimeout.__repr__Mss���t���;�;�&�.�.�(�+/�:�:�+A�5����Q�'�t�D��K�K�%��v��'��8�8�D�>���D�K�K�-�-�.�a��z��;�;rc��JK�|jtjurtd��t j �}|�td��tj|_||_|jj�|_ |j|j�|S�w)Nz Timeout has already been enteredz$Timeout should be used inside a task)r$rrr-r �current_taskrr&� cancelling�_cancellingr6r')r(�tasks r� __aenter__zTimeout.__aenter__Us}�����;�;�f�n�n�,��A�B�B��!�!�#���<��E�F�F��n�n����� ��:�:�0�0�2������� � �#���s�B!B#�exc_type�exc_val�exc_tbc��K�|j�!|jj�d|_|jtjurVtj |_|jj�|jkr|tjurt|�y|jtjurtj|_y�w�N)r%r/r$rrrr&�uncancelrGr �CancelledError�TimeoutErrorrr)r(rJrKrLs r� __aexit__zTimeout.__aexit__as������ � �,��!�!�(�(�*�$(�D�!��;�;�&�/�/�)� �.�.�D�K��z�z�"�"�$��(8�(8�8�X��Ib�Ib�=b�#��/���[�[�F�N�N� *� �-�-�D�K��s�CCc�p�|jj�tj|_d|_yrN)r&r/rrr$r%r+s rr3zTimeout._on_timeoutys%��� � �����o�o��� $��r)r"r)r"N)rrr�__doc__r�floatr)r!r6�boolr�strrCrIr� BaseExceptionrrRr3rrrrrs���� �X�e�_�����h�u�o��M�x���M�4�M�.@��@�<�#�<� ���4� �.�/���-�(����'� � �$���0%rr�delayr"c�r�tj�}t|�|j�|z�Sd�S)a Timeout async context manager. Useful in cases when you want to apply timeout logic around block of code or in cases when asyncio.wait_for is not suitable. For example: >>> async with asyncio.timeout(10): # 10 seconds timeout ... await long_running_task() delay - value in seconds or None to disable timeout logic long_running_task() is interrupted by raising asyncio.CancelledError, the top-most affected timeout() context manager converts CancelledError into TimeoutError. N)rr0rr1)rYr5s rrr�s5�� �"�"�$�D��%�*;�4�9�9�;��&�F�F��F�Frr!c��t|�S)abSchedule the timeout at absolute time. Like timeout() but argument gives absolute time in the same clock system as loop.time(). Please note: it is not POSIX time but a time with undefined starting base, e.g. the time of the system power on. >>> async with asyncio.timeout_at(loop.time() + 10): ... await long_running_task() when - a deadline when timeout occurs or None to disable timeout logic long_running_task() is interrupted by raising asyncio.CancelledError, the top-most affected timeout() context manager converts CancelledError into TimeoutError. )r)r!s rr r �s��&�4�=�r)�enum�typesr�typingrrrr9rr r �__all__�EnumrrrUrr rrr�<module>ras����(�(�������T�Y�Y���c%�c%��c%�LG�8�E�?�G�w�G�(�X�e�_���r__pycache__/timeouts.cpython-312.opt-2.pyc000064400000013551151706172560014307 0ustar00� T��h�����ddlZddlmZddlmZmZmZddlmZddlm Z ddlm Z dZGd �d ej�Z eGd�d��Zd eedefd�Zdeedefd�Zy)�N)� TracebackType)�final�Optional�Type�)�events)� exceptions)�tasks)�Timeout�timeout� timeout_atc� �eZdZdZdZdZdZdZy)�_State�created�active�expiring�expired�finishedN)�__name__� __module__�__qualname__�CREATED�ENTERED�EXPIRING�EXPIRED�EXITED���)/usr/lib64/python3.12/asyncio/timeouts.pyrrs���G��G��H��G� �Frrc ��eZdZ deeddfd�Zdeefd�Zdeeddfd�Zdefd�Z de fd�Zdd �Zd ee edeedeedeefd �Zdd�Zy)r�when�returnNc�Z� tj|_d|_d|_||_y�N)rr�_state�_timeout_handler�_task�_when)�selfr!s r�__init__zTimeout.__init__!s*�� ��n�n���>B���+/�� ��� rc�� |jSr$)r(�r)s rr!zTimeout.when.s��*��z�z�rc�� |jtjurJ|jtjurt d��t d|jj �d���||_|j�|jj�|�d|_ytj�}||j�kr!|j|j�|_y|j||j�|_y)NzTimeout has not been enteredzCannot change state of z Timeout)r%rrr�RuntimeError�valuer(r&�cancelr�get_running_loop�time� call_soon�_on_timeout�call_at)r)r!�loops r� reschedulezTimeout.reschedule2s���%��;�;�f�n�n�,��{�{�f�n�n�,�"�#A�B�B��)�$�+�+�*;�*;�)<�H�E�� ��� �� � �,��!�!�(�(�*��<�$(�D�!��*�*�,�D��t�y�y�{�"�(,���t�7G�7G�(H��%�(,���T�4�;K�;K�(L��%rc�\� |jtjtjfvSr$)r%rrrr,s rrzTimeout.expiredIs!��2��{�{�v������?�?�?rc��dg}|jtjur8|j�t |jd�nd}|jd|���dj |�}d|jj�d|�d�S)N��zwhen=� z <Timeout [�]�>)r%rrr(�round�append�joinr/)r)�infor!�info_strs r�__repr__zTimeout.__repr__Mss���t���;�;�&�.�.�(�+/�:�:�+A�5����Q�'�t�D��K�K�%��v��'��8�8�D�>���D�K�K�-�-�.�a��z��;�;rc��JK�|jtjurtd��t j �}|�td��tj|_||_|jj�|_ |j|j�|S�w)Nz Timeout has already been enteredz$Timeout should be used inside a task)r%rrr.r �current_taskrr'� cancelling�_cancellingr7r()r)�tasks r� __aenter__zTimeout.__aenter__Us}�����;�;�f�n�n�,��A�B�B��!�!�#���<��E�F�F��n�n����� ��:�:�0�0�2������� � �#���s�B!B#�exc_type�exc_val�exc_tbc��K�|j�!|jj�d|_|jtjurVtj |_|jj�|jkr|tjurt|�y|jtjurtj|_y�wr$)r&r0r%rrrr'�uncancelrHr �CancelledError�TimeoutErrorrr)r)rKrLrMs r� __aexit__zTimeout.__aexit__as������ � �,��!�!�(�(�*�$(�D�!��;�;�&�/�/�)� �.�.�D�K��z�z�"�"�$��(8�(8�8�X��Ib�Ib�=b�#��/���[�[�F�N�N� *� �-�-�D�K��s�CCc�p�|jj�tj|_d|_yr$)r'r0rrr%r&r,s rr4zTimeout._on_timeoutys%��� � �����o�o��� $��r)r"r)r"N)rrrr�floatr*r!r7�boolr�strrDrJr� BaseExceptionrrRr4rrrrrs���� �X�e�_�����h�u�o��M�x���M�4�M�.@��@�<�#�<� ���4� �.�/���-�(����'� � �$���0%rr�delayr"c�t� tj�}t|�|j�|z�Sd�Sr$)rr1rr2)rXr6s rrr�s:����"�"�$�D��%�*;�4�9�9�;��&�F�F��F�Frr!c�� t|�Sr$)r)r!s rr r �s���$�4�=�r)�enum�typesr�typingrrrr:rr r �__all__�EnumrrrTrr rrr�<module>r`s����(�(�������T�Y�Y���c%�c%��c%�LG�8�E�?�G�w�G�(�X�e�_���r__pycache__/timeouts.cpython-312.pyc000064400000017167151706172560013356 0ustar00� T��h�����ddlZddlmZddlmZmZmZddlmZddlm Z ddlm Z dZGd �d ej�Z eGd�d��Zd eedefd�Zdeedefd�Zy)�N)� TracebackType)�final�Optional�Type�)�events)� exceptions)�tasks)�Timeout�timeout� timeout_atc� �eZdZdZdZdZdZdZy)�_State�created�active�expiring�expired�finishedN)�__name__� __module__�__qualname__�CREATED�ENTERED�EXPIRING�EXPIRED�EXITED���)/usr/lib64/python3.12/asyncio/timeouts.pyrrs���G��G��H��G� �Frrc ��eZdZdZdeeddfd�Zdeefd�Zdeeddfd�Zde fd�Z defd �Zdd �Z deeedeed eedee fd�Zdd�Zy)rz�Asynchronous context manager for cancelling overdue coroutines. Use `timeout()` or `timeout_at()` rather than instantiating this class directly. �when�returnNc�X�tj|_d|_d|_||_y)z�Schedule a timeout that will trigger at a given loop time. - If `when` is `None`, the timeout will never trigger. - If `when < loop.time()`, the timeout will trigger on the next iteration of the event loop. N)rr�_state�_timeout_handler�_task�_when)�selfr!s r�__init__zTimeout.__init__!s%���n�n���>B���+/�� ��� rc��|jS)zReturn the current deadline.)r'�r(s rr!zTimeout.when.s���z�z�rc��|jtjurJ|jtjurt d��t d|jj �d���||_|j�|jj�|�d|_ytj�}||j�kr!|j|j�|_y|j||j�|_y)zReschedule the timeout.zTimeout has not been enteredzCannot change state of z TimeoutN)r$rrr�RuntimeError�valuer'r%�cancelr�get_running_loop�time� call_soon�_on_timeout�call_at)r(r!�loops r� reschedulezTimeout.reschedule2s����;�;�f�n�n�,��{�{�f�n�n�,�"�#A�B�B��)�$�+�+�*;�*;�)<�H�E�� ��� �� � �,��!�!�(�(�*��<�$(�D�!��*�*�,�D��t�y�y�{�"�(,���t�7G�7G�(H��%�(,���T�4�;K�;K�(L��%rc�Z�|jtjtjfvS)z$Is timeout expired during execution?)r$rrrr+s rrzTimeout.expiredIs���{�{�v������?�?�?rc��dg}|jtjur8|j�t |jd�nd}|jd|���dj |�}d|jj�d|�d�S)N��zwhen=� z <Timeout [�]�>)r$rrr'�round�append�joinr.)r(�infor!�info_strs r�__repr__zTimeout.__repr__Mss���t���;�;�&�.�.�(�+/�:�:�+A�5����Q�'�t�D��K�K�%��v��'��8�8�D�>���D�K�K�-�-�.�a��z��;�;rc��JK�|jtjurtd��t j �}|�td��tj|_||_|jj�|_ |j|j�|S�w)Nz Timeout has already been enteredz$Timeout should be used inside a task)r$rrr-r �current_taskrr&� cancelling�_cancellingr6r')r(�tasks r� __aenter__zTimeout.__aenter__Us}�����;�;�f�n�n�,��A�B�B��!�!�#���<��E�F�F��n�n����� ��:�:�0�0�2������� � �#���s�B!B#�exc_type�exc_val�exc_tbc��K�|jtjtjfvsJ�|j�!|jj�d|_|jtjurVtj|_|jj�|jkr|tjurt|�y|jtjurtj|_y�w�N)r$rrrr%r/rr&�uncancelrGr �CancelledError�TimeoutErrorr)r(rJrKrLs r� __aexit__zTimeout.__aexit__as������{�{�v�~�~�v���?�?�?�?�� � �,��!�!�(�(�*�$(�D�!��;�;�&�/�/�)� �.�.�D�K��z�z�"�"�$��(8�(8�8�X��Ib�Ib�=b�#��/���[�[�F�N�N� *� �-�-�D�K��s�DDc��|jtjusJ�|jj �tj |_d|_yrN)r$rrr&r/rr%r+s rr3zTimeout._on_timeoutys;���{�{�f�n�n�,�,�,�� � �����o�o��� $��r)r"r)r"N)rrr�__doc__r�floatr)r!r6�boolr�strrCrIr� BaseExceptionrrRr3rrrrrs���� �X�e�_�����h�u�o��M�x���M�4�M�.@��@�<�#�<� ���4� �.�/���-�(����'� � �$���0%rr�delayr"c�r�tj�}t|�|j�|z�Sd�S)a Timeout async context manager. Useful in cases when you want to apply timeout logic around block of code or in cases when asyncio.wait_for is not suitable. For example: >>> async with asyncio.timeout(10): # 10 seconds timeout ... await long_running_task() delay - value in seconds or None to disable timeout logic long_running_task() is interrupted by raising asyncio.CancelledError, the top-most affected timeout() context manager converts CancelledError into TimeoutError. N)rr0rr1)rYr5s rrr�s5�� �"�"�$�D��%�*;�4�9�9�;��&�F�F��F�Frr!c��t|�S)abSchedule the timeout at absolute time. Like timeout() but argument gives absolute time in the same clock system as loop.time(). Please note: it is not POSIX time but a time with undefined starting base, e.g. the time of the system power on. >>> async with asyncio.timeout_at(loop.time() + 10): ... await long_running_task() when - a deadline when timeout occurs or None to disable timeout logic long_running_task() is interrupted by raising asyncio.CancelledError, the top-most affected timeout() context manager converts CancelledError into TimeoutError. )r)r!s rr r �s��&�4�=�r)�enum�typesr�typingrrrr9rr r �__all__�EnumrrrUrr rrr�<module>ras����(�(�������T�Y�Y���c%�c%��c%�LG�8�E�?�G�w�G�(�X�e�_���r__pycache__/transports.cpython-312.opt-1.pyc000064400000033242151706172560014653 0ustar00� T��h�)���dZdZGd�d�ZGd�de�ZGd�de�ZGd�d ee�ZGd �de�ZGd�d e�ZGd�de�Zy)zAbstract Transport class.)� BaseTransport� ReadTransport�WriteTransport� Transport�DatagramTransport�SubprocessTransportc�<�eZdZdZdZd d�Zd d�Zd�Zd�Zd�Z d �Z y)rzBase class for transports.��_extraNc��|�i}||_y�Nr )�self�extras �+/usr/lib64/python3.12/asyncio/transports.py�__init__zBaseTransport.__init__s���=��E����c�:�|jj||�S)z#Get optional transport information.)r �get)r �name�defaults r�get_extra_infozBaseTransport.get_extra_infos���{�{���t�W�-�-rc��t�)z2Return True if the transport is closing or closed.��NotImplementedError�r s r� is_closingzBaseTransport.is_closing���!�!rc��t�)aClose the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) be called with None as its argument. rrs r�closezBaseTransport.close� ��"�!rc��t�)zSet a new protocol.r)r �protocols r�set_protocolzBaseTransport.set_protocol%rrc��t�)zReturn the current protocol.rrs r�get_protocolzBaseTransport.get_protocol)rrr)�__name__� __module__�__qualname__�__doc__� __slots__rrrrr"r$�rrrr s(��$��I�� .�"�"�"�"rrc�&�eZdZdZdZd�Zd�Zd�Zy)rz#Interface for read-only transports.r*c��t�)z*Return True if the transport is receiving.rrs r� is_readingzReadTransport.is_reading3rrc��t�)z�Pause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. rrs r� pause_readingzReadTransport.pause_reading7� ��"�!rc��t�)z�Resume the receiving end. Data received will once again be passed to the protocol's data_received() method. rrs r�resume_readingzReadTransport.resume_reading?r0rN)r%r&r'r(r)r-r/r2r*rrrr.s��-��I�"�"�"rrc�F�eZdZdZdZdd�Zd�Zd�Zd�Zd�Z d �Z d �Zd�Zy) rz$Interface for write-only transports.r*Nc��t�)a�Set the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. r�r �high�lows r�set_write_buffer_limitsz&WriteTransport.set_write_buffer_limitsMs ��&"�!rc��t�)z,Return the current size of the write buffer.rrs r�get_write_buffer_sizez$WriteTransport.get_write_buffer_sizebrrc��t�)z�Get the high and low watermarks for write flow control. Return a tuple (low, high) where low and high are positive number of bytes.rrs r�get_write_buffer_limitsz&WriteTransport.get_write_buffer_limitsfs ��"�!rc��t�)z�Write some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. r)r �datas r�writezWriteTransport.writelr0rc�H�dj|�}|j|�y)z�Write a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. rN)�joinr?)r �list_of_datar>s r� writelineszWriteTransport.writelinests���x�x��%��� � �4�rc��t�)z�Close the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. rrs r� write_eofzWriteTransport.write_eof}� ��"�!rc��t�)zAReturn True if this transport supports write_eof(), False if not.rrs r� can_write_eofzWriteTransport.can_write_eof�rrc��t��z�Close the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. rrs r�abortzWriteTransport.abort�rFr�NN) r%r&r'r(r)r8r:r<r?rCrErHrKr*rrrrHs2��.��I�"�*"�"�"��"�"�"rrc��eZdZdZdZy)raSInterface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. r*N)r%r&r'r(r)r*rrrr�s���(�Irrc�"�eZdZdZdZdd�Zd�Zy)rz(Interface for datagram (UDP) transports.r*Nc��t�)aSend data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. r)r r>�addrs r�sendtozDatagramTransport.sendto�rrc��t�rJrrs rrKzDatagramTransport.abort�rFrr)r%r&r'r(r)rQrKr*rrrr�s��2��I�"�"rrc�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z y) rr*c��t�)zGet subprocess id.rrs r�get_pidzSubprocessTransport.get_pid�rrc��t�)z�Get subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode rrs r�get_returncodez"SubprocessTransport.get_returncode�r0rc��t�)z&Get transport for pipe with number fd.r)r �fds r�get_pipe_transportz&SubprocessTransport.get_pipe_transport�rrc��t�)z�Send signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal r)r �signals r�send_signalzSubprocessTransport.send_signal�r0rc��t�)aLStop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate rrs r� terminatezSubprocessTransport.terminate�s ��"�!rc��t�)z�Kill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill rrs r�killzSubprocessTransport.kill�s ��"�!rN) r%r&r'r)rUrWrZr]r_rar*rrrr�s%���I�"�"�"�"�"� "rrc�P��eZdZdZdZd �fd� Zd�Zd�Zd�Zd d�Z d d�Z d �Z�xZS)�_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. )�_loop�_protocol_paused�_high_water� _low_waterc�`��t�|�|�||_d|_|j �y)NF)�superrrdre�_set_write_buffer_limits)r r�loop� __class__s �rrz_FlowControlMixin.__init__s+��� ������� � %����%�%�'rc�@�|j�}||jkry|js#d|_ |jj �yy#t tf$r�t$r4}|jjd|||jd��Yd}~yd}~wwxYw)NTzprotocol.pause_writing() failed��message� exception� transportr!) r:rfre� _protocol� pause_writing� SystemExit�KeyboardInterrupt� BaseExceptionrd�call_exception_handler)r �size�excs r�_maybe_pause_protocolz'_FlowControlMixin._maybe_pause_protocols����)�)�+���4�#�#�#���$�$�$(�D�!� ����,�,�.�%��� 1�2� �� � �� � �1�1�@�!$�!%� $��� 3���� �s�A�B�)*B�Bc�<�|jrA|j�|jkr#d|_ |jj �yyy#t tf$r�t$r4}|jjd|||jd��Yd}~yd}~wwxYw)NFz protocol.resume_writing() failedrn) rer:rgrr�resume_writingrtrurvrdrw)r rys r�_maybe_resume_protocolz(_FlowControlMixin._maybe_resume_protocol's����!�!��*�*�,����?�$)�D�!� ����-�-�/�@� "�� � 1�2� �� � �� � �1�1�A�!$�!%� $��� 3���� �s�A�B�'*B�Bc�2�|j|jfSr)rgrfrs rr<z)_FlowControlMixin.get_write_buffer_limits7s������!1�!1�2�2rc��|� |�d}nd|z}|�|dz}||cxk\rdk\sntd|�d|�d���||_||_y)Ni��zhigh (z) must be >= low (z) must be >= 0)� ValueErrorrfrgr5s rrjz*_FlowControlMixin._set_write_buffer_limits:sh���<��{� ���3�w���;��!�)�C��s��a������ 2�3�'��H�J� J� �����rc�J�|j||��|j�y)N)r6r7)rjrzr5s rr8z)_FlowControlMixin.set_write_buffer_limitsJs!���%�%�4�S�%�9��"�"�$rc��t�rrrs rr:z'_FlowControlMixin.get_write_buffer_sizeNs��!�!rrL) r%r&r'r(r)rrzr}r<rjr8r:� __classcell__)rls@rrcrc�s3���� K�I�(��$� 3�� %�"rrcN) r(�__all__rrrrrrrcr*rr�<module>r�sj�����""�""�J"�M�"�4I"�]�I"�X� �~��0"� �"�23"�-�3"�lT"� �T"r__pycache__/transports.cpython-312.opt-2.pyc000064400000020722151706172560014653 0ustar00� T��h�)��� dZGd�d�ZGd�de�ZGd�de�ZGd�dee�ZGd �d e�ZGd�de�ZGd �de�Zy))� BaseTransport� ReadTransport�WriteTransport� Transport�DatagramTransport�SubprocessTransportc�:�eZdZ dZd d�Zd d�Zd�Zd�Zd�Zd�Z y) r��_extraNc��|�i}||_y�Nr )�self�extras �+/usr/lib64/python3.12/asyncio/transports.py�__init__zBaseTransport.__init__s���=��E����c�<� |jj||�Sr)r �get)r �name�defaults r�get_extra_infozBaseTransport.get_extra_infos��1��{�{���t�W�-�-rc�� t�r��NotImplementedError�r s r� is_closingzBaseTransport.is_closings��@�!�!rc�� t�rrrs r�closezBaseTransport.close��� �"�!rc�� t�rr)r �protocols r�set_protocolzBaseTransport.set_protocol%s��!�!�!rc�� t�rrrs r�get_protocolzBaseTransport.get_protocol)s��*�!�!rr) �__name__� __module__�__qualname__� __slots__rrrrr!r#�rrrr s(��$��I�� .�"�"�"�"rrc�$�eZdZ dZd�Zd�Zd�Zy)rr(c�� t�rrrs r� is_readingzReadTransport.is_reading3s��8�!�!rc�� t�rrrs r� pause_readingzReadTransport.pause_reading7��� � "�!rc�� t�rrrs r�resume_readingzReadTransport.resume_reading?r.rN)r$r%r&r'r+r-r0r(rrrr.s��-��I�"�"�"rrc�D�eZdZ dZdd�Zd�Zd�Zd�Zd�Zd�Z d �Z d �Zy)rr(Nc�� t�rr�r �high�lows r�set_write_buffer_limitsz&WriteTransport.set_write_buffer_limitsMs�� �$"�!rc�� t�rrrs r�get_write_buffer_sizez$WriteTransport.get_write_buffer_sizebs��:�!�!rc�� t�rrrs r�get_write_buffer_limitsz&WriteTransport.get_write_buffer_limitsfs�� %�"�!rc�� t�rr)r �datas r�writezWriteTransport.writelr.rc�J� dj|�}|j|�y)Nr)�joinr=)r �list_of_datar<s r� writelineszWriteTransport.writelinests#�� � �x�x��%��� � �4�rc�� t�rrrs r� write_eofzWriteTransport.write_eof}��� �"�!rc�� t�rrrs r� can_write_eofzWriteTransport.can_write_eof�s��O�!�!rc�� t�rrrs r�abortzWriteTransport.abort�rDr�NN)r$r%r&r'r6r8r:r=rArCrFrHr(rrrrHs2��.��I�"�*"�"�"��"�"�"rrc��eZdZ dZy)rr(N)r$r%r&r'r(rrrr�s���(�Irrc� �eZdZ dZdd�Zd�Zy)rr(Nc�� t�rr)r r<�addrs r�sendtozDatagramTransport.sendto�rrc�� t�rrrs rrHzDatagramTransport.abort�rDrr)r$r%r&r'rNrHr(rrrr�s��2��I�"�"rrc�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z y) rr(c�� t�rrrs r�get_pidzSubprocessTransport.get_pid�s�� �!�!rc�� t�rrrs r�get_returncodez"SubprocessTransport.get_returncode�r.rc�� t�rr)r �fds r�get_pipe_transportz&SubprocessTransport.get_pipe_transport�s��4�!�!rc�� t�rr)r �signals r�send_signalzSubprocessTransport.send_signal�r.rc�� t�rrrs r� terminatezSubprocessTransport.terminate�s�� �"�!rc�� t�rrrs r�killzSubprocessTransport.kill�s�� �"�!rN) r$r%r&r'rRrTrWrZr\r^r(rrrr�s%���I�"�"�"�"�"� "rrc�N��eZdZ dZd �fd� Zd�Zd�Zd�Zd d�Zd d�Z d�Z �xZS) �_FlowControlMixin)�_loop�_protocol_paused�_high_water� _low_waterc�`��t�|�|�||_d|_|j �y)NF)�superrrarb�_set_write_buffer_limits)r r�loop� __class__s �rrz_FlowControlMixin.__init__s+��� ������� � %����%�%�'rc�@�|j�}||jkry|js#d|_ |jj �yy#t tf$r�t$r4}|jjd|||jd��Yd}~yd}~wwxYw)NTzprotocol.pause_writing() failed��message� exception� transportr ) r8rcrb� _protocol� pause_writing� SystemExit�KeyboardInterrupt� BaseExceptionra�call_exception_handler)r �size�excs r�_maybe_pause_protocolz'_FlowControlMixin._maybe_pause_protocols����)�)�+���4�#�#�#���$�$�$(�D�!� ����,�,�.�%��� 1�2� �� � �� � �1�1�@�!$�!%� $��� 3���� �s�A�B�)*B�Bc�<�|jrA|j�|jkr#d|_ |jj �yyy#t tf$r�t$r4}|jjd|||jd��Yd}~yd}~wwxYw)NFz protocol.resume_writing() failedrk) rbr8rdro�resume_writingrqrrrsrart)r rvs r�_maybe_resume_protocolz(_FlowControlMixin._maybe_resume_protocol's����!�!��*�*�,����?�$)�D�!� ����-�-�/�@� "�� � 1�2� �� � �� � �1�1�A�!$�!%� $��� 3���� �s�A�B�'*B�Bc�2�|j|jfSr)rdrcrs rr:z)_FlowControlMixin.get_write_buffer_limits7s������!1�!1�2�2rc��|� |�d}nd|z}|�|dz}||cxk\rdk\sntd|�d|�d���||_||_y)Ni��zhigh (z) must be >= low (z) must be >= 0)� ValueErrorrcrdr3s rrgz*_FlowControlMixin._set_write_buffer_limits:sh���<��{� ���3�w���;��!�)�C��s��a������ 2�3�'��H�J� J� �����rc�J�|j||��|j�y)N)r4r5)rgrwr3s rr6z)_FlowControlMixin.set_write_buffer_limitsJs!���%�%�4�S�%�9��"�"�$rc��t�rrrs rr8z'_FlowControlMixin.get_write_buffer_sizeNs��!�!rrI)r$r%r&r'rrwrzr:rgr6r8� __classcell__)ris@rr`r`�s3���� K�I�(��$� 3�� %�"rr`N)�__all__rrrrrrr`r(rr�<module>r�sj�����""�""�J"�M�"�4I"�]�I"�X� �~��0"� �"�23"�-�3"�lT"� �T"r__pycache__/transports.cpython-312.pyc000064400000033266151706172560013722 0ustar00� T��h�)���dZdZGd�d�ZGd�de�ZGd�de�ZGd�d ee�ZGd �de�ZGd�d e�ZGd�de�Zy)zAbstract Transport class.)� BaseTransport� ReadTransport�WriteTransport� Transport�DatagramTransport�SubprocessTransportc�<�eZdZdZdZd d�Zd d�Zd�Zd�Zd�Z d �Z y)rzBase class for transports.��_extraNc��|�i}||_y�Nr )�self�extras �+/usr/lib64/python3.12/asyncio/transports.py�__init__zBaseTransport.__init__s���=��E����c�:�|jj||�S)z#Get optional transport information.)r �get)r �name�defaults r�get_extra_infozBaseTransport.get_extra_infos���{�{���t�W�-�-rc��t�)z2Return True if the transport is closing or closed.��NotImplementedError�r s r� is_closingzBaseTransport.is_closing���!�!rc��t�)aClose the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) be called with None as its argument. rrs r�closezBaseTransport.close� ��"�!rc��t�)zSet a new protocol.r)r �protocols r�set_protocolzBaseTransport.set_protocol%rrc��t�)zReturn the current protocol.rrs r�get_protocolzBaseTransport.get_protocol)rrr)�__name__� __module__�__qualname__�__doc__� __slots__rrrrr"r$�rrrr s(��$��I�� .�"�"�"�"rrc�&�eZdZdZdZd�Zd�Zd�Zy)rz#Interface for read-only transports.r*c��t�)z*Return True if the transport is receiving.rrs r� is_readingzReadTransport.is_reading3rrc��t�)z�Pause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. rrs r� pause_readingzReadTransport.pause_reading7� ��"�!rc��t�)z�Resume the receiving end. Data received will once again be passed to the protocol's data_received() method. rrs r�resume_readingzReadTransport.resume_reading?r0rN)r%r&r'r(r)r-r/r2r*rrrr.s��-��I�"�"�"rrc�F�eZdZdZdZdd�Zd�Zd�Zd�Zd�Z d �Z d �Zd�Zy) rz$Interface for write-only transports.r*Nc��t�)a�Set the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. r�r �high�lows r�set_write_buffer_limitsz&WriteTransport.set_write_buffer_limitsMs ��&"�!rc��t�)z,Return the current size of the write buffer.rrs r�get_write_buffer_sizez$WriteTransport.get_write_buffer_sizebrrc��t�)z�Get the high and low watermarks for write flow control. Return a tuple (low, high) where low and high are positive number of bytes.rrs r�get_write_buffer_limitsz&WriteTransport.get_write_buffer_limitsfs ��"�!rc��t�)z�Write some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. r)r �datas r�writezWriteTransport.writelr0rc�H�dj|�}|j|�y)z�Write a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. rN)�joinr?)r �list_of_datar>s r� writelineszWriteTransport.writelinests���x�x��%��� � �4�rc��t�)z�Close the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. rrs r� write_eofzWriteTransport.write_eof}� ��"�!rc��t�)zAReturn True if this transport supports write_eof(), False if not.rrs r� can_write_eofzWriteTransport.can_write_eof�rrc��t��z�Close the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. rrs r�abortzWriteTransport.abort�rFr�NN) r%r&r'r(r)r8r:r<r?rCrErHrKr*rrrrHs2��.��I�"�*"�"�"��"�"�"rrc��eZdZdZdZy)raSInterface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. r*N)r%r&r'r(r)r*rrrr�s���(�Irrc�"�eZdZdZdZdd�Zd�Zy)rz(Interface for datagram (UDP) transports.r*Nc��t�)aSend data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. r)r r>�addrs r�sendtozDatagramTransport.sendto�rrc��t�rJrrs rrKzDatagramTransport.abort�rFrr)r%r&r'r(r)rQrKr*rrrr�s��2��I�"�"rrc�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z y) rr*c��t�)zGet subprocess id.rrs r�get_pidzSubprocessTransport.get_pid�rrc��t�)z�Get subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode rrs r�get_returncodez"SubprocessTransport.get_returncode�r0rc��t�)z&Get transport for pipe with number fd.r)r �fds r�get_pipe_transportz&SubprocessTransport.get_pipe_transport�rrc��t�)z�Send signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal r)r �signals r�send_signalzSubprocessTransport.send_signal�r0rc��t�)aLStop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate rrs r� terminatezSubprocessTransport.terminate�s ��"�!rc��t�)z�Kill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill rrs r�killzSubprocessTransport.kill�s ��"�!rN) r%r&r'r)rUrWrZr]r_rar*rrrr�s%���I�"�"�"�"�"� "rrc�P��eZdZdZdZd �fd� Zd�Zd�Zd�Zd d�Z d d�Z d �Z�xZS)�_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. )�_loop�_protocol_paused�_high_water� _low_waterc�h��t�|�|�|�J�||_d|_|j �y)NF)�superrrdre�_set_write_buffer_limits)r r�loop� __class__s �rrz_FlowControlMixin.__init__s7��� ����������� � %����%�%�'rc�@�|j�}||jkry|js#d|_ |jj �yy#t tf$r�t$r4}|jjd|||jd��Yd}~yd}~wwxYw)NTzprotocol.pause_writing() failed��message� exception� transportr!) r:rfre� _protocol� pause_writing� SystemExit�KeyboardInterrupt� BaseExceptionrd�call_exception_handler)r �size�excs r�_maybe_pause_protocolz'_FlowControlMixin._maybe_pause_protocols����)�)�+���4�#�#�#���$�$�$(�D�!� ����,�,�.�%��� 1�2� �� � �� � �1�1�@�!$�!%� $��� 3���� �s�A�B�)*B�Bc�<�|jrA|j�|jkr#d|_ |jj �yyy#t tf$r�t$r4}|jjd|||jd��Yd}~yd}~wwxYw)NFz protocol.resume_writing() failedrn) rer:rgrr�resume_writingrtrurvrdrw)r rys r�_maybe_resume_protocolz(_FlowControlMixin._maybe_resume_protocol's����!�!��*�*�,����?�$)�D�!� ����-�-�/�@� "�� � 1�2� �� � �� � �1�1�A�!$�!%� $��� 3���� �s�A�B�'*B�Bc�2�|j|jfSr)rgrfrs rr<z)_FlowControlMixin.get_write_buffer_limits7s������!1�!1�2�2rc��|� |�d}nd|z}|�|dz}||cxk\rdk\sntd|�d|�d���||_||_y)Ni��zhigh (z) must be >= low (z) must be >= 0)� ValueErrorrfrgr5s rrjz*_FlowControlMixin._set_write_buffer_limits:sh���<��{� ���3�w���;��!�)�C��s��a������ 2�3�'��H�J� J� �����rc�J�|j||��|j�y)N)r6r7)rjrzr5s rr8z)_FlowControlMixin.set_write_buffer_limitsJs!���%�%�4�S�%�9��"�"�$rc��t�rrrs rr:z'_FlowControlMixin.get_write_buffer_sizeNs��!�!rrL) r%r&r'r(r)rrzr}r<rjr8r:� __classcell__)rls@rrcrc�s3���� K�I�(��$� 3�� %�"rrcN) r(�__all__rrrrrrrcr*rr�<module>r�sj�����""�""�J"�M�"�4I"�]�I"�X� �~��0"� �"�23"�-�3"�lT"� �T"r__pycache__/trsock.cpython-312.opt-1.pyc000064400000011731151706172560013740 0ustar00� T��h� �� �ddlZGd�d�Zy)�Nc��eZdZdZdZdej fd�Zed��Zed��Z ed��Z d�Zd �Zd �Z d�Zd�Zd �Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�TransportSocketz�A socket-like wrapper for exposing real transport sockets. These objects can be safely returned by APIs like `transport.get_extra_info('socket')`. All potentially disruptive operations (like "socket.close()") are banned. ��_sock�sockc��||_y�Nr)�selfrs �'/usr/lib64/python3.12/asyncio/trsock.py�__init__zTransportSocket.__init__s ���� �c�.�|jjSr )r�family�r s rrzTransportSocket.familys���z�z� � � r c�.�|jjSr )r�typers rrzTransportSocket.types���z�z���r c�.�|jjSr )r�protors rrzTransportSocket.protos���z�z���r c�r�d|j��d|j�d|j�d|j��}|j�dk7r4 |j �}|r|�d|��} |j�}|r|�d|��}|�d�S#t j$rY�4wxYw#t j$rY�3wxYw) Nz<asyncio.TransportSocket fd=z , family=z, type=z, proto=���z, laddr=z, raddr=�>)�filenorrr�getsockname�socket�error�getpeername)r �s�laddr�raddrs r�__repr__zTransportSocket.__repr__s���*�4�;�;�=�/�:��k�k�_�G�D�I�I�=�9��Z�Z�L� "� ��;�;�=�B�� ��(�(�*����#�X�e�W�-�A� ��(�(�*����#�X�e�W�-�A���A�w����<�<� �� ���<�<� �� �s$�B�)B �B�B� B6�5B6c��td��)Nz/Cannot serialize asyncio.TransportSocket object)� TypeErrorrs r�__getstate__zTransportSocket.__getstate__5s���I�J�Jr c�6�|jj�Sr )rrrs rrzTransportSocket.fileno8s���z�z� � �"�"r c�6�|jj�Sr )r�duprs rr&zTransportSocket.dup;s���z�z�~�~��r c�6�|jj�Sr )r�get_inheritablers rr(zTransportSocket.get_inheritable>s���z�z�)�)�+�+r c�:�|jj|�yr )r�shutdown)r �hows rr*zTransportSocket.shutdownAs�� � � ���C� r c�:�|jj|i|��Sr )r� getsockopt�r �args�kwargss rr-zTransportSocket.getsockoptFs��$�t�z�z�$�$�d�5�f�5�5r c�<�|jj|i|��yr )r� setsockoptr.s rr2zTransportSocket.setsockoptIs���� � ���t�.�v�.r c�6�|jj�Sr )rrrs rrzTransportSocket.getpeernameL����z�z�%�%�'�'r c�6�|jj�Sr )rrrs rrzTransportSocket.getsocknameOr4r c�6�|jj�Sr )r� getsockbynamers rr7zTransportSocket.getsockbynameRs���z�z�'�'�)�)r c�$�|dk(rytd��)Nrz<settimeout(): only 0 timeout is allowed on transport sockets�� ValueError)r �values r� settimeoutzTransportSocket.settimeoutUs���A�:���J�L� Lr c��y)Nr�rs r� gettimeoutzTransportSocket.gettimeout[s��r c��|sytd��)Nz3setblocking(): transport sockets cannot be blockingr9)r �flags r�setblockingzTransportSocket.setblocking^s�����A�C� Cr N)�__name__� __module__�__qualname__�__doc__� __slots__rr�propertyrrrr r#rr&r(r*r-r2rrr7r<r?rBr>r rrrs�����I��V�]�]���!��!������ �� ��.K�#� �,�!� 6�/�(�(�*�L��Cr r)rrr>r r�<module>rIs�� �^C�^Cr __pycache__/trsock.cpython-312.opt-2.pyc000064400000011335151706172560013741 0ustar00� T��h� �� �ddlZGd�d�Zy)�Nc��eZdZ dZdejfd�Zed��Zed��Zed��Z d�Z d�Zd �Zd �Z d�Zd�Zd �Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�TransportSocket��_sock�sockc��||_y�Nr)�selfrs �'/usr/lib64/python3.12/asyncio/trsock.py�__init__zTransportSocket.__init__s ���� �c�.�|jjSr )r�family�r s rrzTransportSocket.familys���z�z� � � r c�.�|jjSr )r�typers rrzTransportSocket.types���z�z���r c�.�|jjSr )r�protors rrzTransportSocket.protos���z�z���r c�r�d|j��d|j�d|j�d|j��}|j�dk7r4 |j �}|r|�d|��} |j�}|r|�d|��}|�d�S#t j$rY�4wxYw#t j$rY�3wxYw) Nz<asyncio.TransportSocket fd=z , family=z, type=z, proto=���z, laddr=z, raddr=�>)�filenorrr�getsockname�socket�error�getpeername)r �s�laddr�raddrs r�__repr__zTransportSocket.__repr__s���*�4�;�;�=�/�:��k�k�_�G�D�I�I�=�9��Z�Z�L� "� ��;�;�=�B�� ��(�(�*����#�X�e�W�-�A� ��(�(�*����#�X�e�W�-�A���A�w����<�<� �� ���<�<� �� �s$�B�)B �B�B� B6�5B6c��td��)Nz/Cannot serialize asyncio.TransportSocket object)� TypeErrorrs r�__getstate__zTransportSocket.__getstate__5s���I�J�Jr c�6�|jj�Sr )rrrs rrzTransportSocket.fileno8s���z�z� � �"�"r c�6�|jj�Sr )r�duprs rr&zTransportSocket.dup;s���z�z�~�~��r c�6�|jj�Sr )r�get_inheritablers rr(zTransportSocket.get_inheritable>s���z�z�)�)�+�+r c�:�|jj|�yr )r�shutdown)r �hows rr*zTransportSocket.shutdownAs�� � � ���C� r c�:�|jj|i|��Sr )r� getsockopt�r �args�kwargss rr-zTransportSocket.getsockoptFs��$�t�z�z�$�$�d�5�f�5�5r c�<�|jj|i|��yr )r� setsockoptr.s rr2zTransportSocket.setsockoptIs���� � ���t�.�v�.r c�6�|jj�Sr )rrrs rrzTransportSocket.getpeernameL����z�z�%�%�'�'r c�6�|jj�Sr )rrrs rrzTransportSocket.getsocknameOr4r c�6�|jj�Sr )r� getsockbynamers rr7zTransportSocket.getsockbynameRs���z�z�'�'�)�)r c�$�|dk(rytd��)Nrz<settimeout(): only 0 timeout is allowed on transport sockets�� ValueError)r �values r� settimeoutzTransportSocket.settimeoutUs���A�:���J�L� Lr c��y)Nr�rs r� gettimeoutzTransportSocket.gettimeout[s��r c��|sytd��)Nz3setblocking(): transport sockets cannot be blockingr9)r �flags r�setblockingzTransportSocket.setblocking^s�����A�C� Cr N)�__name__� __module__�__qualname__� __slots__rr�propertyrrrr r#rr&r(r*r-r2rrr7r<r?rBr>r rrrs�����I��V�]�]���!��!������ �� ��.K�#� �,�!� 6�/�(�(�*�L��Cr r)rrr>r r�<module>rHs�� �^C�^Cr __pycache__/trsock.cpython-312.pyc000064400000011731151706172560013001 0ustar00� T��h� �� �ddlZGd�d�Zy)�Nc��eZdZdZdZdej fd�Zed��Zed��Z ed��Z d�Zd �Zd �Z d�Zd�Zd �Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�TransportSocketz�A socket-like wrapper for exposing real transport sockets. These objects can be safely returned by APIs like `transport.get_extra_info('socket')`. All potentially disruptive operations (like "socket.close()") are banned. ��_sock�sockc��||_y�Nr)�selfrs �'/usr/lib64/python3.12/asyncio/trsock.py�__init__zTransportSocket.__init__s ���� �c�.�|jjSr )r�family�r s rrzTransportSocket.familys���z�z� � � r c�.�|jjSr )r�typers rrzTransportSocket.types���z�z���r c�.�|jjSr )r�protors rrzTransportSocket.protos���z�z���r c�r�d|j��d|j�d|j�d|j��}|j�dk7r4 |j �}|r|�d|��} |j�}|r|�d|��}|�d�S#t j$rY�4wxYw#t j$rY�3wxYw) Nz<asyncio.TransportSocket fd=z , family=z, type=z, proto=���z, laddr=z, raddr=�>)�filenorrr�getsockname�socket�error�getpeername)r �s�laddr�raddrs r�__repr__zTransportSocket.__repr__s���*�4�;�;�=�/�:��k�k�_�G�D�I�I�=�9��Z�Z�L� "� ��;�;�=�B�� ��(�(�*����#�X�e�W�-�A� ��(�(�*����#�X�e�W�-�A���A�w����<�<� �� ���<�<� �� �s$�B�)B �B�B� B6�5B6c��td��)Nz/Cannot serialize asyncio.TransportSocket object)� TypeErrorrs r�__getstate__zTransportSocket.__getstate__5s���I�J�Jr c�6�|jj�Sr )rrrs rrzTransportSocket.fileno8s���z�z� � �"�"r c�6�|jj�Sr )r�duprs rr&zTransportSocket.dup;s���z�z�~�~��r c�6�|jj�Sr )r�get_inheritablers rr(zTransportSocket.get_inheritable>s���z�z�)�)�+�+r c�:�|jj|�yr )r�shutdown)r �hows rr*zTransportSocket.shutdownAs�� � � ���C� r c�:�|jj|i|��Sr )r� getsockopt�r �args�kwargss rr-zTransportSocket.getsockoptFs��$�t�z�z�$�$�d�5�f�5�5r c�<�|jj|i|��yr )r� setsockoptr.s rr2zTransportSocket.setsockoptIs���� � ���t�.�v�.r c�6�|jj�Sr )rrrs rrzTransportSocket.getpeernameL����z�z�%�%�'�'r c�6�|jj�Sr )rrrs rrzTransportSocket.getsocknameOr4r c�6�|jj�Sr )r� getsockbynamers rr7zTransportSocket.getsockbynameRs���z�z�'�'�)�)r c�$�|dk(rytd��)Nrz<settimeout(): only 0 timeout is allowed on transport sockets�� ValueError)r �values r� settimeoutzTransportSocket.settimeoutUs���A�:���J�L� Lr c��y)Nr�rs r� gettimeoutzTransportSocket.gettimeout[s��r c��|sytd��)Nz3setblocking(): transport sockets cannot be blockingr9)r �flags r�setblockingzTransportSocket.setblocking^s�����A�C� Cr N)�__name__� __module__�__qualname__�__doc__� __slots__rr�propertyrrrr r#rr&r(r*r-r2rrr7r<r?rBr>r rrrs�����I��V�]�]���!��!������ �� ��.K�#� �,�!� 6�/�(�(�*�L��Cr r)rrr>r r�<module>rIs�� �^C�^Cr __pycache__/unix_events.cpython-312.opt-1.pyc000064400000202743151706172560015007 0ustar00� T��h�����dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlZddlZddl mZddl mZddl mZddl mZddl mZdd l mZdd l mZddl mZddl mZdd l mZddlmZdZe j6dk(red��d�Zd�ZGd�dej>�Z Gd�dejB�Z"Gd�dejFejH�Z%Gd�dejL�Z'Gd�d�Z(Gd�de(�Z)Gd �d!e(�Z*Gd"�d#e*�Z+Gd$�d%e*�Z,Gd&�d'e(�Z-Gd(�d)e(�Z.d*�Z/Gd+�d,ej`�Z1e Z2e1Z3y)-z2Selector event loop for Unix with signal handling.�N�)�base_events)�base_subprocess)� constants)� coroutines)�events)� exceptions)�futures)�selector_events)�tasks)� transports)�logger)�SelectorEventLoop�AbstractChildWatcher�SafeChildWatcher�FastChildWatcher�PidfdChildWatcher�MultiLoopChildWatcher�ThreadedChildWatcher�DefaultEventLoopPolicy�win32z+Signals are not really supported on Windowsc��y)zDummy signal handler.N�)�signum�frames �,/usr/lib64/python3.12/asyncio/unix_events.py�_sighandler_noopr*s���c�P� tj|�S#t$r|cYSwxYw�N)�os�waitstatus_to_exitcode� ValueError)�statuss rr"r"/s.����(�(��0�0����� � �s��%�%c���eZdZdZd�fd� Z�fd�Zd�Zd�Zd�Zd�Z d �Z dd �Z dd�Z dd�Z d �Z ddddddd�d�Z dddddddd�d�Zd�Zd�Zd�Zd�Z�xZS)�_UnixSelectorEventLoopzdUnix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. Nc�2��t�|�|�i|_yr )�super�__init__�_signal_handlers)�self�selector� __class__s �rr)z_UnixSelectorEventLoop.__init__?s��� ����"� "��rc�0��t�|��tj�s,t |j �D]}|j |��y|j r;tjd|�d�t|��|j j�yy)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal��source)r(�close�sys� is_finalizing�listr*�remove_signal_handler�warnings�warn�ResourceWarning�clear)r+�sigr-s �rr1z_UnixSelectorEventLoop.closeCs���� �� ��� � �"��D�1�1�2���*�*�3�/�3��$�$�� � � 1�$��:H�I�.�%)� +� �%�%�+�+�-� %rc�:�|D]}|s�|j|��yr )�_handle_signal)r+�datars r�_process_self_dataz)_UnixSelectorEventLoop._process_self_dataQs ���F�������'� rc�R�tj|�stj|�rtd��|j |�|j� t j|jj��tj|||d�}||j |< t j|t"�t j$|d�y#ttf$r}tt|���d}~wwxYw#t$r�}|j |=|j sI t jd�n2#ttf$r }t'j(d|�Yd}~nd}~wwxYw|j*t*j,k(rtd|�d����d}~wwxYw)z�Add a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. z3coroutines cannot be used with add_signal_handler()NF����set_wakeup_fd(-1) failed: %s�sig � cannot be caught)r�iscoroutine�iscoroutinefunction� TypeError� _check_signal� _check_closed�signal� set_wakeup_fd�_csock�filenor#�OSError�RuntimeError�strr�Handler*r�siginterruptr�info�errno�EINVAL)r+r:�callback�args�exc�handle�nexcs r�add_signal_handlerz)_UnixSelectorEventLoop.add_signal_handlerXsq�� �"�"�8�,��.�.�x�8��8�9� 9����3������ )� � � ����!3�!3�!5�6����x��t�T�:��%+����c�"� � �M�M�#�/�0� ����U�+���G�$� )��s�3�x�(�(�� )��� ��%�%�c�*��(�(�F��(�(��,��"�G�,�F��K�K� >��E�E��F���y�y�E�L�L�(�"�T�#��.?�#@�A�A��� �sZ�-C�-0D �D�-D�D� F&�F!�,E�F!�E1�E,�'F!�,E1�10F!�!F&c��|jj|�}|�y|jr|j|�y|j |�y)z2Internal helper that is the actual signal handler.N)r*�get� _cancelledr5�_add_callback_signalsafe)r+r:rXs rr<z%_UnixSelectorEventLoop._handle_signal�sE���&�&�*�*�3�/���>������&�&�s�+��)�)�&�1rc��|j|� |j|=|tjk(rtj }ntj} tj||�|js tjd�yy#t$rYywxYw#t$r2}|jtjk(rtd|�d����d}~wwxYw#ttf$r }tjd|�Yd}~yd}~wwxYw)zwRemove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. FrBrCNr@rAT)rGr*�KeyErrorrI�SIGINT�default_int_handler�SIG_DFLrMrSrTrNrJr#rrR)r+r:�handlerrWs rr5z,_UnixSelectorEventLoop.remove_signal_handler�s��� ���3�� ��%�%�c�*��&�-�-���0�0�G��n�n�G� ��M�M�#�w�'��$�$� A��$�$�R�(���-� �� ��� ��y�y�E�L�L�(�"�T�#��.?�#@�A�A��� ����(� A����:�C�@�@��� A�sA� B�B�8C� B�B� C�'-C�C�D�+D�Dc��t|t�std|����|tj�vrtd|����y)z�Internal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. zsig must be an int, not zinvalid signal number N)� isinstance�intrFrI� valid_signalsr#)r+r:s rrGz$_UnixSelectorEventLoop._check_signal�sJ���#�s�#��6�s�g�>�?�?��f�*�*�,�,��5�c�U�;�<�<�-rc� �t|||||�Sr )�_UnixReadPipeTransport�r+�pipe�protocol�waiter�extras r�_make_read_pipe_transportz0_UnixSelectorEventLoop._make_read_pipe_transport�s��%�d�D�(�F�E�J�Jrc� �t|||||�Sr )�_UnixWritePipeTransportrks r�_make_write_pipe_transportz1_UnixSelectorEventLoop._make_write_pipe_transport�s��&�t�T�8�V�U�K�Krc ��lK�tj�5tjdt�t j �} ddd� 5| j �std��|j�}t||||||||f||d�| ��}| j|j�|j|� |�d{��� ddd�|S#1swY��xYw7�#ttf$r�t$r+|j!�|j#��d{���7�wxYw#1swYSxYw�w)N�ignorezRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rnro)r6�catch_warnings�simplefilter�DeprecationWarningr�get_child_watcher� is_activerN� create_future�_UnixSubprocessTransport�add_child_handler�get_pid�_child_watcher_callback� SystemExit�KeyboardInterrupt� BaseExceptionr1�_wait) r+rmrV�shell�stdin�stdout�stderr�bufsizero�kwargs�watcherrn�transps r�_make_subprocess_transportz1_UnixSelectorEventLoop._make_subprocess_transport�s/����� $� $� &��!�!�(�,>�?��.�.�0�G�'���$�$�&� #�$G�H�H��'�'�)�F�-�d�H�d�E�,1�6�6�7�6�39��6�/5�6�F� �%�%�f�n�n�&6�$(�$@�$@�&� J� ����!�0� �9'� &��(��� 1�2� �� � ������l�l�n�$�$�� ��'�0� �se�D4�/C� D4�A-D'�>C!�C�C!� D4�C�D4�C!�!;D$�D�D$�$D'�'D1�,D4c�<�|j|j|�yr )�call_soon_threadsafe�_process_exited)r+�pid� returncoder�s rrz._UnixSelectorEventLoop._child_watcher_callback�s���!�!�&�"8�"8�*�Er)�ssl�sock�server_hostname�ssl_handshake_timeout�ssl_shutdown_timeoutc���K�|r |�2td��|�td��|�td��|�td��|��|�td��tj|�}tjtjtj d�} |j d�|j||��d{���nf|�td��|jtjk7s|jtj k7rtd |����|j d�|j||||||� ��d{���\}} || fS7��#|j��xYw7�#�w)Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with ssl�1ssl_handshake_timeout is only meaningful with ssl�0ssl_shutdown_timeout is only meaningful with ssl�3path and sock can not be specified at the same timerFzno path and sock were specified�.A UNIX Domain Stream Socket was expected, got )r�r�)r#r!�fspath�socket�AF_UNIX�SOCK_STREAM�setblocking�sock_connectr1�family�type�_create_connection_transport) r+�protocol_factory�pathr�r�r�r�r�� transportrms r�create_unix_connectionz-_UnixSelectorEventLoop.create_unix_connection�s�������&� �E�G�G��*� �!N�O�O�$�0� �G�I�I�#�/� �F�H�H����� �I�K�K��9�9�T�?�D��=�=�����1C�1C�Q�G�D� �� � ��'��'�'��d�3�3�3��|� �!B�C�C����v�~�~�-��I�I��!3�!3�3� �D�T�H�M�O�O����U�#�$(�$E�$E��"�C��"7�!5�%F�%7�7�� �8��(�"�"�%4�� �� � ����7�s=�BE#�&E�7E �8E�<BE#�=E!�>E#� E�E�E#�dT)r��backlogr�r�r�� start_servingc ��K�t|t�rtd��|� |std��|� |std��|��|�td��t j |�}t jtjtj�}|ddvrH tjt j|�j�rt j|� |j#|�nU|�td ��|j*tjk7s|j,tjk7rtd|����|j/d�t1j2||g|||||�}|r-|j5�t7j8d��d{���|S#t$rY��t$r!} tj d|| �Yd} ~ ��d} ~ wwxYw#t$rT} |j%�| j&t&j(k(r!d|�d �}tt&j(|�d��d} ~ w|j%��xYw7���w) Nz*ssl argument must be an SSLContext or Noner�r�r�r)r�z2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedr�F)rf�boolrFr#r!r�r�r�r��stat�S_ISSOCK�st_mode�remove�FileNotFoundErrorrMr�error�bindr1rS� EADDRINUSEr�r�r�r�Server�_start_servingr�sleep) r+r�r�r�r�r�r�r�r��errrW�msg�servers r�create_unix_serverz)_UnixSelectorEventLoop.create_unix_servers7�����c�4� ��H�I�I� �,�S��C�E� E� �+�C��B�D� D����� �I�K�K��9�9�T�?�D��=�=�����1C�1C�D�D��A�w�k�)�6��}�}�R�W�W�T�]�%:�%:�;�� � �$�� �� � �$���|� �C�E�E����v�~�~�-��I�I��!3�!3�3� �D�T�H�M�O�O� ������#�#�D�4�&�2B�$'��2G�$8�:����!�!�#��+�+�a�.� � �� ��S)����6��L�L�"*�+/��6�6��6��� �� � ���9�9�� 0� 0�0�%�T�H�,>�?�C�!�%�"2�"2�C�8�d�B��� �� � ����& !�si�BI�AF'�"G�3B-I� I�!I�' G�0I�2G�:G�I�G�I� I�'AH6�6I�Ic ��K� tj |j�} tj|�j}|r|n|}|sy|j�} |j| d|||||d�| �d{���S#t$rtjd��wxYw#ttjf$r}tjd��d}~wwxYw#t$rtjd��wxYw7�~�w)Nzos.sendfile() is not availableznot a regular filer) r!�sendfile�AttributeErrorr �SendfileNotAvailableErrorrL�io�UnsupportedOperation�fstat�st_sizerMr{�_sock_sendfile_native_impl) r+r��file�offset�countrLr��fsize� blocksize�futs r�_sock_sendfile_nativez,_UnixSelectorEventLoop._sock_sendfile_nativebs���� 2��K�K� M��[�[�]�F� M��H�H�V�$�,�,�E�#�E�� ���� � �"���'�'��T�4��(.��y�!� E��y���%� 2��6�6�0�2� 2� 2�� �� 7� 7�8� M��6�6�7K�L�L�� M��� M��6�6�7K�L�L� M���sV�C<�B�B"�C�6C<�;C:�<C<�B�C<�"C�;C�C�C<�C7�7C<c ��|j�} |�|j|�|j�r|j|||�y|r/||z }|dkr%|j|||�|j |�y tj| |||�} | dk(r%|j|||�|j |�y|| z }|| z }|�|j||�|j| |j|| ||||||� y#ttf$r;|�|j||�|j| |j|| ||||||� Yyt$r�}|�Q|jtjk(r4t|�t ur#t!dtj�}||_|}|dk(r:t%j&d�} |j|||�|j)| �n)|j|||�|j)|�Yd}~yYd}~yd}~wt*t,f$r�t.$r.}|j|||�|j)|�Yd}~yd}~wwxYw)Nrzsocket is not connectedzos.sendfile call failed)rL� remove_writer� cancelled�_sock_sendfile_update_filepos� set_resultr!r��_sock_add_cancellation_callback� add_writerr��BlockingIOError�InterruptedErrorrMrS�ENOTCONNr��ConnectionError� __cause__r r�� set_exceptionr�r�r�)r+r�� registered_fdr�rLr�r�r�� total_sent�fd�sentrW�new_excr�s rr�z1_UnixSelectorEventLoop._sock_sendfile_native_implysT�� �[�[�]���$� ���}�-��=�=�?��.�.�v�v�z�J���� �*�I��A�~��2�2�6�6�:�N����z�*��1 F��;�;�r�6�6�9�=�D�J�q�y��2�2�6�6�:�N����z�*��$����d�"� � �(��8�8��d�C�����D�$C�$C�S� "�D�&� &��y�*�F��[ �!1�2� B��$��4�4�S�$�?��O�O�B�� ?� ?����f�"�E�9�j� B�� '��)��I�I����/���I�_�4� *�-�u�~�~�?��$'��!����Q�� !�:�:�-�/���2�2�6�6�:�N��!�!�#�&��2�2�6�6�:�N��!�!�#�&�&�'���-�.� ��� #��.�.�v�v�z�J����c�"�"�� #�s,�:C?�?AI�I�B6H�I�+$I�Ic�Z�|dkDr&tj||tj�yy�Nr)r!�lseek�SEEK_SET)r+rLr�r�s rr�z4_UnixSelectorEventLoop._sock_sendfile_update_filepos�s"����>��H�H�V�V�R�[�[�1�rc�6�����fd�}|j|�y)Nc�v��|j�r(�j�}|dk7r�j|�yyy)Nr@)r�rLr�)r�r�r+r�s ��r�cbzB_UnixSelectorEventLoop._sock_add_cancellation_callback.<locals>.cb�s6����}�}���[�[�]����8��&�&�r�*��r)�add_done_callback)r+r�r�r�s` ` rr�z6_UnixSelectorEventLoop._sock_add_cancellation_callback�s��� +� ���b�!rr �NN)�__name__� __module__�__qualname__�__doc__r)r1r>rZr<r5rGrprsr�rr�r�r�r�r�r�� __classcell__�r-s@rr&r&9s����� #�.�(�+�Z2��@ =�@D�(,�K�AE�)-�L�04��BF�*.�0#��4� �"&�!%�0#�f*.�G��s��"&�!%��G�R�.DF�L2�"rr&c���eZdZdZd�fd� Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zd�Z d�Zej fd �Zdd�Zd�Zd�Z�xZS)rjic�4��t�|�|�||jd<||_||_|j�|_||_d|_d|_ tj|j�j}tj|�sJtj|�s5tj |�s d|_d|_d|_t#d��tj$|jd�|jj'|jj(|�|jj'|j*|j|j,�|�,|jj't.j0|d�yy)NrlFz)Pipe transport is for pipes/sockets only.)r(r)�_extra�_loop�_piperL�_fileno� _protocol�_closing�_pausedr!r�r�r��S_ISFIFOr��S_ISCHRr#�set_blocking� call_soon�connection_made�_add_reader�_read_readyr �_set_result_unless_cancelled)r+�looprlrmrnro�moder-s �rr)z_UnixReadPipeTransport.__init__�s.��� �����"����F���� ��� ��{�{�}���!����� �����x�x����%�-�-��� � �d�#�� � �d�#����T�"��D�J��D�L�!�D�N��H�I�I� ������e�,�� � ���T�^�^�;�;�T�B�� � ���T�-�-�!�\�\�4�+;�+;� =����J�J� � ��!E�!E�!'�� /�rc�^�|j�sy|jj||�yr )� is_readingr�r�)r+r�rUs rr�z"_UnixReadPipeTransport._add_reader�s#����� ��� � ���r�8�,rc�:�|jxr |jSr )r�r��r+s rrz!_UnixReadPipeTransport.is_reading�s���<�<��5�� � �$5�5rc�t�|jjg}|j�|jd�n|jr|jd�|jd|j ���t |jdd�}|j�W|�Utj||j tj�}|r|jd�nA|jd�n/|j�|jd�n|jd�djd j|��S) N�closed�closing�fd=� _selector�polling�idle�open�<{}>� )r-r�r��appendr�r��getattrr�r�_test_selector_event� selectors� EVENT_READ�format�join)r+rRr,rs r�__repr__z_UnixReadPipeTransport.__repr__�s������'�'�(���:�:���K�K��!� �]�]��K�K� �"����c�$�,�,��(�)��4�:�:�{�D�9���:�:�!�h�&:�%�:�:��$�,�,� �(<�(<�>�G�����I�&����F�#� �Z�Z� #��K�K����K�K��!��}�}�S�X�X�d�^�,�,rc�h� tj|j|j�}|r|jj|�y|jj�rtjd|�d|_ |jj|j�|jj|jj�|jj|jd�y#tt f$rYyt"$r}|j%|d�Yd}~yd}~wwxYw)N�%r was closed by peerTz"Fatal read error on pipe transport)r!�readr��max_sizer�� data_receivedr�� get_debugrrRr��_remove_readerr��eof_received�_call_connection_lostr�r�rM�_fatal_error)r+r=rWs rr�z"_UnixReadPipeTransport._read_readys��� G��7�7�4�<�<����7�D�����,�,�T�2��:�:�'�'�)��K�K� 7��>� $�� �� � �)�)�$�,�,�7�� � �$�$�T�^�^�%@�%@�A�� � �$�$�T�%?�%?��F�� �!1�2� ��� I����c�#G�H�H�� I�s�*C<�<D1� D1�D,�,D1c���|j�syd|_|jj|j�|jj�rt jd|�yy)NTz%r pauses reading)rr�r�rr�rr�debugrs r� pause_readingz$_UnixReadPipeTransport.pause_readingsP����� ������ � �!�!�$�,�,�/��:�:���!��L�L�,�d�3�"rc��|js|jsyd|_|jj|j|j �|jj �rtjd|�yy)NFz%r resumes reading) r�r�r�r�r�r�rrr#rs r�resume_readingz%_UnixReadPipeTransport.resume_reading%s[���=�=��������� � ���t�|�|�T�-=�-=�>��:�:���!��L�L�-�t�4�"rc��||_yr �r��r+rms r�set_protocolz#_UnixReadPipeTransport.set_protocol-� ��!��rc��|jSr r(rs r�get_protocolz#_UnixReadPipeTransport.get_protocol0����~�~�rc��|jSr �r�rs r� is_closingz!_UnixReadPipeTransport.is_closing3����}�}�rc�@�|js|jd�yyr )r��_closers rr1z_UnixReadPipeTransport.close6s���}�}��K�K���rc�v�|j�-|d|��t|��|jj�yy�Nzunclosed transport r/�r�r8r1�r+�_warns r�__del__z_UnixReadPipeTransport.__del__:�5���:�:�!��'��x�0�/�$�O��J�J����"rc�<�t|t�rQ|jtjk(r4|jj�rDt jd||d��n*|jj||||jd��|j|�y�Nz%r: %sT��exc_info)�message� exceptionr�rm)rfrMrS�EIOr�rrr#�call_exception_handlerr�r4�r+rWr@s rr!z#_UnixReadPipeTransport._fatal_error?sr���s�G�$����e�i�i�)?��z�z�#�#�%����X�t�W�t�D��J�J�-�-�"� �!� �N�N� /� � ���C�rc��d|_|jj|j�|jj |j |�y�NT)r�r�rr�r�r �r+rWs rr4z_UnixReadPipeTransport._closeMs9���� �� � �!�!�$�,�,�/�� � ���T�7�7��=rc�� |jj|�|jj�d|_d|_d|_y#|jj�d|_d|_d|_wxYwr �r��connection_lostr�r1r�rGs rr z,_UnixReadPipeTransport._call_connection_lostR�g�� ��N�N�*�*�3�/��J�J�����D�J�!�D�N��D�J�� �J�J�����D�J�!�D�N��D�J���A � 1A>r��zFatal error on pipe transport)r�r�r�rr)r�rrr�r$r&r*r-r1r1r6r7r:r!r4r r�r�s@rrjrj�s]����H�/�<-� 6�-�*G�$4�5�"����%�M�M�� �>� rrjc���eZdZd�fd� Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zd�Z d�Zej fd �Zd�Zdd�Zdd�Zd�Z�xZS)rrc���t� |�||�||jd<||_|j �|_||_t�|_d|_ d|_ tj|j �j}tj|�}tj |�}tj"|�} |s$|s"| s d|_d|_d|_t%d��tj&|j d�|j(j+|jj,|�| s!|rdt.j0j3d�sE|j(j+|j(j4|j |j6�|�,|j(j+t8j:|d�yy)NrlrFz?Pipe transport is only for pipes, sockets and character devices�aix)r(r)r�r�rLr�r�� bytearray�_buffer� _conn_lostr�r!r�r�r�r�r�r�r#r�r�r�r�r2�platform� startswithr�r�r r�)r+rrlrmrnror�is_char�is_fifo� is_socketr-s �rr)z _UnixWritePipeTransport.__init___si��� �����%�"����F���� ��{�{�}���!��� �{�������� ��x�x����%�-�-���,�,�t�$���-�-��%���M�M�$�'� ��7�i��D�J��D�L�!�D�N��D�E� E� ������e�,�� � ���T�^�^�;�;�T�B� �����)@�)@��)G��J�J� � ����!7�!7�!%���t�/?�/?� A����J�J� � ��!E�!E�!'�� /�rc��|jjg}|j�|jd�n|jr|jd�|jd|j ���t |jdd�}|j�{|�ytj||j tj�}|r|jd�n|jd�|j�}|jd|���n/|j�|jd�n|jd�d jd j|��S)Nrrr r rrzbufsize=r rr)r-r�r�rr�r�rr�rrr�EVENT_WRITE�get_write_buffer_sizerr)r+rRr,rr�s rrz _UnixWritePipeTransport.__repr__�s�����'�'�(���:�:���K�K��!� �]�]��K�K� �"����c�$�,�,��(�)��4�:�:�{�D�9���:�:�!�h�&:�%�:�:��$�,�,� �(=�(=�?�G�����I�&����F�#��0�0�2�G��K�K�(�7�)�,�-� �Z�Z� #��K�K����K�K��!��}�}�S�X�X�d�^�,�,rc�,�t|j�Sr )�lenrRrs rr[z-_UnixWritePipeTransport.get_write_buffer_size�s���4�<�<� � rc���|jj�rtjd|�|jr|jt ��y|j�y)Nr)r�rrrRrRr4�BrokenPipeErrorrs rr�z#_UnixWritePipeTransport._read_ready�s@���:�:���!��K�K�/��6��<�<��K�K��)�*��K�K�Mrc��t|t�rt|�}|sy|js|jrH|jt jk\rtjd�|xjdz c_y|jss tj|j|�}|t'|�k(ry|dkDrt|�|d}|j(j+|j|j,�|xj|z c_ |j/�y#ttf$rd}Y��tt f$r�t"$r1}|xjdz c_|j%|d�Yd}~yd}~wwxYw)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rr�#Fatal write error on pipe transport)rfrQ� memoryviewrSr�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr�warningrRr!�writer�r�r�r�r�r�r!r]r��_add_writer�_write_ready�_maybe_pause_protocol)r+r=�nrWs rrez_UnixWritePipeTransport.write�s7���d�I�&��d�#�D����?�?�d�m�m����)�"M�"M�M���� H�I��O�O�q� �O���|�|� ��H�H�T�\�\�4�0���C��I�~���Q��!�$�'���+���J�J�"�"�4�<�<��1B�1B�C��������"�"�$��$�%5�6� ���� 1�2� �� � ����1�$���!�!�#�'L�M��� �s� D$�$E?�7E?�'E:�:E?c�� tj|j|j�}|t |j�k(r�|jj�|jj|j�|j�|jr6|jj|j�|jd�y|dkDr|jd|�=yy#ttf$rYyttf$r�t $rp}|jj�|xj"dz c_|jj|j�|j%|d�Yd}~yd}~wwxYw)Nrrra)r!rer�rRr]r9r��_remove_writer�_maybe_resume_protocolr�rr r�r�r�r�r�rSr!)r+rirWs rrgz$_UnixWritePipeTransport._write_ready�s.�� %�������t�|�|�4�A��C����%�%����"�"�$�� � �)�)�$�,�,�7��+�+�-��=�=��J�J�-�-�d�l�l�;��.�.�t�4���Q���L�L��!��$���) �!1�2� ���-�.� ��� J��L�L��� ��O�O�q� �O� �J�J�%�%�d�l�l�3����c�#H�I�I�� J�s�*C,�,F�=F�A&E?�?Fc��yrFrrs r� can_write_eofz%_UnixWritePipeTransport.can_write_eof����rc���|jryd|_|jsL|jj|j�|jj|jd�yyrF)r�rRr�rr�r�r rs r� write_eofz!_UnixWritePipeTransport.write_eof�sO���=�=���� ��|�|��J�J�%�%�d�l�l�3��J�J� � ��!;�!;�T�B�rc��||_yr r(r)s rr*z$_UnixWritePipeTransport.set_protocol�r+rc��|jSr r(rs rr-z$_UnixWritePipeTransport.get_protocol�r.rc��|jSr r0rs rr1z"_UnixWritePipeTransport.is_closing�r2rc�X�|j�|js|j�yyyr )r�r�rqrs rr1z_UnixWritePipeTransport.close�s$���:�:�!�$�-�-��N�N��+8�!rc�v�|j�-|d|��t|��|jj�yyr6r7r8s rr:z_UnixWritePipeTransport.__del__r;rc�&�|jd�yr )r4rs r�abortz_UnixWritePipeTransport.aborts�����D�rc��t|t�r4|jj�rDt j d||d��n*|jj ||||jd��|j|�yr=) rfrMr�rrr#rCr�r4rDs rr!z$_UnixWritePipeTransport._fatal_error sc���c�7�#��z�z�#�#�%����X�t�W�t�D��J�J�-�-�"� �!� �N�N� /� � ���C�rc�>�d|_|jr%|jj|j�|jj�|jj |j�|jj|j|�yrF) r�rRr�rkr�r9rr�r rGs rr4z_UnixWritePipeTransport._closesf���� ��<�<��J�J�%�%�d�l�l�3�������� � �!�!�$�,�,�/�� � ���T�7�7��=rc�� |jj|�|jj�d|_d|_d|_y#|jj�d|_d|_d|_wxYwr rIrGs rr z-_UnixWritePipeTransport._call_connection_lostrKrLr�rMr )r�r�r�r)rr[r�rergrnrqr*r-r1r1r6r7r:rxr!r4r r�r�s@rrrrr\sd���#/�J-�0!��!%�F%�8�C�"���� %�M�M�� ��>�rrrc��eZdZd�Zy)r|c ���d}|tjk(r6tjj d�rtj�\}} tj|f||||d|d�|��|_|�=|j�t|j�d|��|j_d}|�!|j�|j�yy#|�!|j�|j�wwxYw)NrPF)r�r�r�r��universal_newlinesr��wb)� buffering) � subprocess�PIPEr2rTrUr�� socketpair�Popen�_procr1r �detachr�) r+rVr�r�r�r�r�r��stdin_ws r�_startz_UnixSubprocessTransport._start+s������J�O�O�#����(?�(?��(F� $�.�.�0�N�E�7� �#�)�)��E�!��v�f�#(�'�E�=C�E�D�J��"���� �#'����(8�$�'�#R�� � � ����"���� �� � ��#��w�"���� �� � ��#�s � A!C�%C7N)r�r�r�r�rrrr|r|)s�� rr|c�B�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z d �Z d �Zy)raHAbstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. Nc�\�|jtk7rtjddd��yy)Nr�P{name!r} is deprecated as of Python 3.12 and will be removed in Python {remove}.����r�)r�r�r6�_deprecated)�clss r�__init_subclass__z&AbstractChildWatcher.__init_subclass__Xs,���>�>�X�%�� � �!7�;�%,� .�&rc��t��)aRegister a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. ��NotImplementedError�r+r�rUrVs rr}z&AbstractChildWatcher.add_child_handler_s ��"�#�#rc��t��)z�Removes the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.r��r+r�s r�remove_child_handlerz)AbstractChildWatcher.remove_child_handlerjs ��"�#�#rc��t��)z�Attach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. r��r+rs r�attach_loopz AbstractChildWatcher.attach_looprs ��"�#�#rc��t��)zlClose the watcher. This must be called to make sure that any underlying resource is freed. r�rs rr1zAbstractChildWatcher.close|s �� "�#�#rc��t��)z�Return ``True`` if the watcher is active and is used by the event loop. Return True if the watcher is installed and ready to handle process exit notifications. r�rs rrzzAbstractChildWatcher.is_active�s ��"�#�#rc��t��)zdEnter the watcher's context and allow starting new processes This function must return selfr�rs r� __enter__zAbstractChildWatcher.__enter__�s ��"�#�#rc��t��)zExit the watcher's contextr��r+�a�b�cs r�__exit__zAbstractChildWatcher.__exit__�s��!�#�#r)�returnN)r�r�r�r�r�r}r�r�r1rzr�r�rrrrrAs/���,.� $�$�$�$�$�$�$rrc�@�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zy )ra6Child watcher implementation using Linux's pid file descriptors. This child watcher polls process file descriptors (pidfds) to await child process termination. In some respects, PidfdChildWatcher is a "Goldilocks" child watcher implementation. It doesn't require signals or threads, doesn't interfere with any processes launched outside the event loop, and scales linearly with the number of subprocesses launched by the event loop. The main disadvantage is that pidfds are specific to Linux, and only work on recent (5.3+) kernels. c��|Sr rrs rr�zPidfdChildWatcher.__enter__�����rc��yr r)r+�exc_type� exc_value� exc_tracebacks rr�zPidfdChildWatcher.__exit__����rc��yrFrrs rrzzPidfdChildWatcher.is_active�rorc��yr rrs rr1zPidfdChildWatcher.close�r�rc��yr rr�s rr�zPidfdChildWatcher.attach_loop�r�rc��tj�}tj|�}|j ||j ||||�yr )r�get_running_loopr!� pidfd_openr��_do_wait)r+r�rUrVr�pidfds rr}z#PidfdChildWatcher.add_child_handler�s:���&�&�(��� � �c�"������� � �s�E�8�T�Jrc�$�tj�}|j|� tj|d�\}}t|�}tj|�|||g|���y#t$rd}tjd|�Y�CwxYw)Nr�zJchild process pid %d exit status already read: will report returncode 255) rr�rr!�waitpidr"�ChildProcessErrorrrdr1) r+r�r�rUrVr�_r$r�s rr�zPidfdChildWatcher._do_wait�s����&�&�(�����E�"� 8�� � �3��*�I�A�v�0��7�J� �������j�(�4�(��!� ��J��N�N�.�� � �s�A+�+!B�Bc��yrFrr�s rr�z&PidfdChildWatcher.remove_child_handler����rN)r�r�r�r�r�r�rzr1r�r}r�r�rrrrr�s0�� �� �� � �K� )�&rrc�6�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z y) �BaseChildWatcherc� �d|_i|_yr )r�� _callbacksrs rr)zBaseChildWatcher.__init__�s���� ���rc�&�|jd�yr )r�rs rr1zBaseChildWatcher.close�s������rc�V�|jduxr|jj�Sr )r�� is_runningrs rrzzBaseChildWatcher.is_active�s#���z�z��%�A�$�*�*�*?�*?�*A�Arc��t��r r�)r+�expected_pids r�_do_waitpidzBaseChildWatcher._do_waitpid����!�#�#rc��t��r r�rs r�_do_waitpid_allz BaseChildWatcher._do_waitpid_all�r�rc�^�|j�(|�&|jrtjdt�|j�)|jjtj�||_|�;|jtj|j�|j�yy)NzCA loop is being detached from a child watcher with pending handlers)r�r�r6r7�RuntimeWarningr5rI�SIGCHLDrZ� _sig_chldr�r�s rr�zBaseChildWatcher.attach_loop�s����:�:�!�d�l�t����M�M�=�� � �:�:�!��J�J�,�,�V�^�^�<��� ����#�#�F�N�N�D�N�N�C� � � �"�rc�� |j�y#ttf$r�t$r(}|jjd|d��Yd}~yd}~wwxYw)N�$Unknown exception in SIGCHLD handler)r@rA)r�r�r�r�r�rCrGs rr�zBaseChildWatcher._sig_chld�sX�� �� � �"���-�.� ��� � �J�J�-�-�A� �/� � �� �s��A�A�AN) r�r�r�r)r1rzr�r�r�r�rrrr�r��s&����B�$�$�#�(rr�c�P��eZdZdZ�fd�Z�fd�Zd�Zd�Zd�Zd�Z d�Z d �Z�xZS) rad'Safe' child watcher implementation. This implementation avoids disrupting other code spawning processes by polling explicitly each process in the SIGCHLD handler instead of calling os.waitpid(-1). This is a safe solution but it has a significant overhead when handling a big number of children (O(n) each time SIGCHLD is raised) c�R��t�|��tjddd��y)Nrr�r�r�)r(r)r6r��r+r-s �rr)zSafeChildWatcher.__init__s'��� �������/�;�%,� .rc�V��|jj�t�|� �yr )r�r9r(r1r�s �rr1zSafeChildWatcher.closes��������� �� �rc��|Sr rrs rr�zSafeChildWatcher.__enter__r�rc��yr rr�s rr�zSafeChildWatcher.__exit__r�rc�H�||f|j|<|j|�yr )r�r�r�s rr}z"SafeChildWatcher.add_child_handler"s%�� (�$�/������ ����rc�>� |j|=y#t$rYywxYw�NTF�r�r`r�s rr�z%SafeChildWatcher.remove_child_handler(�(�� �����$���� �� ��� � �c�Z�t|j�D]}|j|��yr �r4r�r�r�s rr�z SafeChildWatcher._do_waitpid_all/s#������(�C����S�!�)rc�� tj|tj�\}}|dk(ryt|�}|jj�rt jd||� |jj|�\}}|||g|���y#t$r|}d}t jd|�Y�OwxYw#t$r7|jj�rt jd|d��YyYywxYw)Nr�$process %s exited with returncode %sr��8Unknown child process pid %d, will report returncode 255�'Child watcher got an unexpected pid: %rTr>) r!r��WNOHANGr"r�rrr#r�rdr��popr`)r+r�r�r$r�rUrVs rr�zSafeChildWatcher._do_waitpid4s��� 7��*�*�\�2�:�:�>�K�C���a�x��/��7�J��z�z�#�#�%����C�)�:�7� -�!�_�_�0�0��5�N�H�d� �S�*�,�t�,��7!� ��C��J��N�N�J�� � ��(� 3��z�z�#�#�%����H�"�T�3�&� 3�s#�'B�-B?�#B<�;B<�?;C?�>C?) r�r�r�r�r)r1r�r�r}r�r�r�r�r�s@rrrs0����.��� ���"� -rrc�J��eZdZdZ�fd�Z�fd�Zd�Zd�Zd�Zd�Z d�Z �xZS) raW'Fast' child watcher implementation. This implementation reaps every terminated processes by calling os.waitpid(-1) directly, possibly breaking other code spawning processes and waiting for their termination. There is no noticeable overhead when handling a big number of children (O(1) each time a child terminates). c���t�|��tj�|_i|_d|_tjddd��y)Nrrr�r�r�) r(r)� threading�Lock�_lock�_zombies�_forksr6r�r�s �rr)zFastChildWatcher.__init__asC��� �����^�^�%�� ��� �������/�;�%,� .rc���|jj�|jj�t�|��yr )r�r9r�r(r1r�s �rr1zFastChildWatcher.closeks,���������� � ���� �� �rc�t�|j5|xjdz c_|cddd�S#1swYyxYw)Nr)r�r�rs rr�zFastChildWatcher.__enter__ps$�� �Z�Z��K�K�1��K���Z�Z�s�.�7c�>�|j5|xjdzc_|js|js ddd�yt|j�}|jj �ddd�tjd�y#1swY� xYw)Nrz5Caught subprocesses termination from unknown pids: %s)r�r�r�rOr9rrd)r+r�r�r��collateral_victimss rr�zFastChildWatcher.__exit__vsp�� �Z�Z��K�K�1��K��{�{�$�-�-�� �Z�"%�T�]�]�!3���M�M���!�� ���C�� ��Z�s�/B�/B�Bc���|j5 |jj|�} ddd�||g|���y#t$r||f|j|<Yddd�ywxYw#1swY�<xYwr )r�r�r�r`r�)r+r�rUrVr�s rr}z"FastChildWatcher.add_child_handler�so���Z�Z� �!�]�]�.�.�s�3� �� ��j�(�4�(�� � �'/��~�����$�� �Z� ���Z�s&�A&�>�A#�A&�"A#�#A&�&A/c�>� |j|=y#t$rYywxYwr�r�r�s rr�z%FastChildWatcher.remove_child_handler�r�r�c�� tjdtj�\}}|dk(ryt|�}|j 5 |jj|�\}}|jj�rtjd||� ddd��tjd||�n |||g�����#t$rYywxYw#t$r\|jrK||j|<|jj�rtjd||�Yddd���4d}Y��wxYw#1swY��xYw)Nr@rr�z,unknown process %s exited with returncode %sz8Caught subprocess termination from unknown pid: %d -> %d)r!r�r�r"r�r�r�r�r�rrr#r`r�r�rd)r+r�r$r�rUrVs rr�z FastChildWatcher._do_waitpid_all�s8��� <� �j�j��R�Z�Z�8���V� �!�8��3�F�;� ����6�%)�_�_�%8�%8��%=�N�H�d��z�z�+�+�-����%K�%(�*�6�!�&������ #�Z�1���j�0�4�0�K��%� �� �� � $��{�{�-7�� � �c�*��:�:�/�/�1�"�L�L�*>�),�j�:�!��� $�H� $����sN�'C�D=� C�'2D=� C�C�AD:�*D=�5D:�7D=�9D:�:D=�=E)r�r�r�r�r)r1r�r�r}r�r�r�r�s@rrrWs+����.�� � �)��(1rrc�R�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zd�Z d�Zy )ra~A watcher that doesn't require running loop in the main thread. This implementation registers a SIGCHLD signal handler on instantiation (which may conflict with other code that install own handler for this signal). The solution is safe but it has a significant overhead when handling a big number of processes (*O(n)* each time a SIGCHLD is received). c�P�i|_d|_tjddd��y)Nrr�r�r�)r��_saved_sighandlerr6r�rs rr)zMultiLoopChildWatcher.__init__�s*�����!%������4�;�%,� .rc��|jduSr )r�rs rrzzMultiLoopChildWatcher.is_active�s���%�%�T�1�1rc�Z�|jj�|j�ytjtj �}||jk7rtjd�d|_ytjtj |j�d|_y)Nz+SIGCHLD handler was changed by outside code) r�r9r�rI� getsignalr�r�rrd)r+rds rr1zMultiLoopChildWatcher.close�sz���������!�!�)���"�"�6�>�>�2���d�n�n�$��N�N�H�I�"&��� �M�M�&�.�.�$�*@�*@�A�!%��rc��|Sr rrs rr�zMultiLoopChildWatcher.__enter__�r�rc��yr r�r+r��exc_val�exc_tbs rr�zMultiLoopChildWatcher.__exit__�r�rc�r�tj�}|||f|j|<|j|�yr )rr�r�r�)r+r�rUrVrs rr}z'MultiLoopChildWatcher.add_child_handler�s5���&�&�(�� $�h��5������ ����rc�>� |j|=y#t$rYywxYwr�r�r�s rr�z*MultiLoopChildWatcher.remove_child_handler�r�r�c�8�|j�ytjtj|j�|_|j�*t j d�tj|_tjtjd�y)NzaPrevious SIGCHLD handler was set by non-Python code, restore to default handler on watcher close.F)r�rIr�r�rrdrcrQr�s rr�z!MultiLoopChildWatcher.attach_loopso�� �!�!�-��!'���v�~�~�t�~�~�!N����!�!�)��N�N�J� K�%+�^�^�D�"� ���F�N�N�E�2rc�Z�t|j�D]}|j|��yr r�r�s rr�z%MultiLoopChildWatcher._do_waitpid_alls#������(�C����S�!�)rc�*� tj|tj�\}}|dk(ryt|�}d} |jj|�\}}}|j�rtjd||�y|r'|j�rtjd||�|j|||g|���y#t$r|}d}tjd|�d}Y��wxYw#t$rtjd|d� �YywxYw) NrTr�r�F�%Loop %r that handles pid %r is closedr�r�r>)r!r�r�r"r�rrdr�r�� is_closedrr#r�r`) r+r�r�r$r�� debug_logrrUrVs rr�z!MultiLoopChildWatcher._do_waitpids �� ��*�*�\�2�:�:�>�K�C���a�x��/��7�J��I� L�#'�?�?�#6�#6�s�#;� �D�(�D��~�~�����F��c�R�����!1��L�L�!G�!-�z�;�)��)�)�(�C��K�d�K��=!� ��C��J��N�N�J�� ��I� ��$� /� �N�N�D��� /� /�s"�'C�C.�%C+�*C+�.!D�Dc�� |j�y#ttf$r�t$rt j dd��YywxYw)Nr�Tr>)r�r�r�r�rrd)r+rrs rr�zMultiLoopChildWatcher._sig_chld<sE�� R�� � �"���-�.� ��� R��N�N�A�D�Q� R�s��/A�AN)r�r�r�r�r)rzr1r�r�r}r�r�r�r�r�rrrrr�sA�� �$.�2� &�� ���3�""�#L�JRrrc�d�eZdZdZd�Zd�Zd�Zd�Zd�Ze jfd�Zd�Zd �Z d �Zd�Zy) raAThreaded child watcher implementation. The watcher uses a thread per process for waiting for the process finish. It doesn't require subscription on POSIX signal but a thread creation is not free. The watcher has O(1) complexity, its performance doesn't depend on amount of spawn processes. c�F�tjd�|_i|_yr�)� itertoolsr��_pid_counter�_threadsrs rr)zThreadedChildWatcher.__init__Rs��%�O�O�A�.����� rc��yrFrrs rrzzThreadedChildWatcher.is_activeVrorc��yr rrs rr1zThreadedChildWatcher.closeYr�rc��|Sr rrs rr�zThreadedChildWatcher.__enter__\r�rc��yr rr�s rr�zThreadedChildWatcher.__exit___r�rc���t|jj��D�cgc]}|j�r|��}}|r||j�d�t |��yycc}w)Nz0 has registered but not finished child processesr/)r4r�values�is_aliver-r8)r+r9�thread�threadss rr:zThreadedChildWatcher.__del__bse��(,�T�]�]�-A�-A�-C�(D�)�(D�f��o�o�'��(D��)���T�^�^�$�$T�U�!�� ���)s�A!c���tj�}tj|jdt|j���||||fd��}||j|<|j�y)Nzasyncio-waitpid-T)�target�namerV�daemon) rr�r��Threadr��nextrr�start)r+r�rUrVrrs rr}z&ThreadedChildWatcher.add_child_handlerjsf���&�&�(���!�!��)9�)9�)9�$�t�?P�?P�:Q�9R�'S�(,�c�8�T�'B�)-�/��$�� � �c�����rc��yrFrr�s rr�z)ThreadedChildWatcher.remove_child_handlersr�rc��yr rr�s rr�z ThreadedChildWatcher.attach_loopyr�rc�� tj|d�\}}t|�}|j�rt j d||� |j�rt jd||�n|j|||g|���|jj|�y#t$r|}d}t jd|�Y�~wxYw)Nrr�r�r�r)r!r�r"rrr#r�rdrr�rr�)r+rr�rUrVr�r$r�s rr�z ThreadedChildWatcher._do_waitpid|s��� 7��*�*�\�1�5�K�C��0��7�J��~�~�����C�)�:�7��>�>���N�N�B�D�#�N�%�D�%�%�h��Z�G�$�G�� � ���,�'��'!� ��C��J��N�N�J�� � �s�B'�'#C �C N)r�r�r�r�r)rzr1r�r�r6r7r:r}r�r�r�rrrrrEsB�� ��� �� �%�M�M���� �(rrc��ttd�sy tj�}tjtj|d��y#t $rYywxYw)Nr�FrT)�hasattrr!�getpidr1r�rM)r�s r� can_use_pidfdr#�sO���2�|�$����i�i�k�� ������s�A�&�'�������s�=A� A�Ac�B��eZdZdZeZ�fd�Zd�Z�fd�Zd�Z d�Z �xZS)�_UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.c�0��t�|��d|_yr )r(r)�_watcherr�s �rr)z$_UnixDefaultEventLoopPolicy.__init__�s��� ������ rc��tj5|j�)t�rt �|_nt�|_ddd�y#1swYyxYwr )rr�r'r#rrrs r� _init_watcherz)_UnixDefaultEventLoopPolicy._init_watcher�s6�� �\�\��}�}�$� �?�$5�$7�D�M�$8�$:�D�M��\�\�s�6A�Ac����t�|�|�|j�Etj�tj �ur|jj |�yyy)z�Set the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. N)r(�set_event_loopr'r��current_thread�main_threadr�)r+rr-s �rr+z*_UnixDefaultEventLoopPolicy.set_event_loop�sS��� ���t�$��M�M�%��(�(�*�i�.C�.C�.E�E��M�M�%�%�d�+�F� &rc��|j�|j�tjddd��|jS)z~Get the watcher for child processes. If not yet set, a ThreadedChildWatcher object is automatically created. ryr�r�r�)r'r)r6r�rs rryz-_UnixDefaultEventLoopPolicy.get_child_watcher�s@�� �=�=� ���� ����0�:�BI� K��}�}�rc��|j�|jj�||_tjddd��y)z$Set the watcher for child processes.N�set_child_watcherr�r�r�)r'r1r6r�)r+r�s rr0z-_UnixDefaultEventLoopPolicy.set_child_watcher�s?�� �=�=�$��M�M���!��� ����0�:�BI� Kr)r�r�r�r�r&� _loop_factoryr)r)r+ryr0r�r�s@rr%r%�s%���D�*�M��;�,��Krr%)4r�rSr�r r!rrIr�r�r�r2r�r6�rrrrrr r rrr �logr�__all__rT�ImportErrorrr"�BaseSelectorEventLoopr&� ReadTransportrj�_FlowControlMixin�WriteTransportrr�BaseSubprocessTransportr|rrr�rrrrr#�BaseDefaultEventLoopPolicyr%rrrrr�<module>r<se��8�� �� �� � ��� �����������������<�<�7�� �C� D�D� � �P"�_�B�B�P"�fM�Z�5�5�M�`J�j�:�:�(�7�7�J�Z ��F�F� �0S$�S$�l7�,�7�t2�+�2�jN-�'�N-�bj1�'�j1�Z~R�0�~R�BO(�/�O(�b �6K�&�"C�"C�6K�r+��4�r__pycache__/unix_events.cpython-312.opt-2.pyc000064400000171054151706172560015010 0ustar00� T��h����� ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlZddlm Z ddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZddlmZddlmZdd lmZdZe j4dk(red��d�Zd�ZGd�dej<�ZGd�dej@�Z!Gd�dejDejF�Z$Gd�dejJ�Z&Gd�d�Z'Gd�de'�Z(Gd�d e'�Z)Gd!�d"e)�Z*Gd#�d$e)�Z+Gd%�d&e'�Z,Gd'�d(e'�Z-d)�Z.Gd*�d+ej^�Z0eZ1e0Z2y),�N�)�base_events)�base_subprocess)� constants)� coroutines)�events)� exceptions)�futures)�selector_events)�tasks)� transports)�logger)�SelectorEventLoop�AbstractChildWatcher�SafeChildWatcher�FastChildWatcher�PidfdChildWatcher�MultiLoopChildWatcher�ThreadedChildWatcher�DefaultEventLoopPolicy�win32z+Signals are not really supported on Windowsc�� y�N�)�signum�frames �,/usr/lib64/python3.12/asyncio/unix_events.py�_sighandler_noopr*s����c�P� tj|�S#t$r|cYSwxYwr)�os�waitstatus_to_exitcode� ValueError)�statuss rr"r"/s.����(�(��0�0����� � �s��%�%c���eZdZ d�fd� Z�fd�Zd�Zd�Zd�Zd�Zd�Z dd �Z dd �Z dd�Zd�Z ddddddd �d�Z dddddddd�d�Zd�Zd�Zd�Zd�Z�xZS)�_UnixSelectorEventLoopNc�2��t�|�|�i|_yr)�super�__init__�_signal_handlers)�self�selector� __class__s �rr)z_UnixSelectorEventLoop.__init__?s��� ����"� "��rc�0��t�|��tj�s,t |j �D]}|j |��y|j r;tjd|�d�t|��|j j�yy)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal��source)r(�close�sys� is_finalizing�listr*�remove_signal_handler�warnings�warn�ResourceWarning�clear)r+�sigr-s �rr1z_UnixSelectorEventLoop.closeCs���� �� ��� � �"��D�1�1�2���*�*�3�/�3��$�$�� � � 1�$��:H�I�.�%)� +� �%�%�+�+�-� %rc�:�|D]}|s�|j|��yr)�_handle_signal)r+�datars r�_process_self_dataz)_UnixSelectorEventLoop._process_self_dataQs ���F�������'� rc�T� tj|�stj|�rtd��|j |�|j� t j|jj��tj|||d�}||j |< t j|t"�t j$|d�y#ttf$r}tt|���d}~wwxYw#t$r�}|j |=|j sI t jd�n2#ttf$r }t'j(d|�Yd}~nd}~wwxYw|j*t*j,k(rtd|�d����d}~wwxYw)Nz3coroutines cannot be used with add_signal_handler()F����set_wakeup_fd(-1) failed: %s�sig � cannot be caught)r�iscoroutine�iscoroutinefunction� TypeError� _check_signal� _check_closed�signal� set_wakeup_fd�_csock�filenor#�OSError�RuntimeError�strr�Handler*r�siginterruptr�info�errno�EINVAL)r+r:�callback�args�exc�handle�nexcs r�add_signal_handlerz)_UnixSelectorEventLoop.add_signal_handlerXsv�� � �"�"�8�,��.�.�x�8��8�9� 9����3������ )� � � ����!3�!3�!5�6����x��t�T�:��%+����c�"� � �M�M�#�/�0� ����U�+���G�$� )��s�3�x�(�(�� )��� ��%�%�c�*��(�(�F��(�(��,��"�G�,�F��K�K� >��E�E��F���y�y�E�L�L�(�"�T�#��.?�#@�A�A��� �sZ�-C�.0D �D�.D�D� F'�F"�-E�F"�E2�E-�(F"�-E2�20F"�"F'c�� |jj|�}|�y|jr|j|�y|j |�yr)r*�get� _cancelledr5�_add_callback_signalsafe)r+r:rXs rr<z%_UnixSelectorEventLoop._handle_signal�sH��@��&�&�*�*�3�/���>������&�&�s�+��)�)�&�1rc�� |j|� |j|=|tjk(rtj }ntj} tj||�|js tjd�yy#t$rYywxYw#t$r2}|jtjk(rtd|�d����d}~wwxYw#ttf$r }tjd|�Yd}~yd}~wwxYw)NFrBrCr@rAT)rGr*�KeyErrorrI�SIGINT�default_int_handler�SIG_DFLrMrSrTrNrJr#rrR)r+r:�handlerrWs rr5z,_UnixSelectorEventLoop.remove_signal_handler�s��� � ���3�� ��%�%�c�*��&�-�-���0�0�G��n�n�G� ��M�M�#�w�'��$�$� A��$�$�R�(���-� �� ��� ��y�y�E�L�L�(�"�T�#��.?�#@�A�A��� ����(� A����:�C�@�@��� A�sA� B�B�9C� B�B� C�(-C�C�D�,D�Dc�� t|t�std|����|tj�vrtd|����y)Nzsig must be an int, not zinvalid signal number )� isinstance�intrFrI� valid_signalsr#)r+r:s rrGz$_UnixSelectorEventLoop._check_signal�sO�� � �#�s�#��6�s�g�>�?�?��f�*�*�,�,��5�c�U�;�<�<�-rc� �t|||||�Sr)�_UnixReadPipeTransport�r+�pipe�protocol�waiter�extras r�_make_read_pipe_transportz0_UnixSelectorEventLoop._make_read_pipe_transport�s��%�d�D�(�F�E�J�Jrc� �t|||||�Sr)�_UnixWritePipeTransportrks r�_make_write_pipe_transportz1_UnixSelectorEventLoop._make_write_pipe_transport�s��&�t�T�8�V�U�K�Krc ��lK�tj�5tjdt�t j �} ddd� 5| j �std��|j�}t||||||||f||d�| ��}| j|j�|j|� |�d{��� ddd�|S#1swY��xYw7�#ttf$r�t$r+|j!�|j#��d{���7�wxYw#1swYSxYw�w)N�ignorezRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rnro)r6�catch_warnings�simplefilter�DeprecationWarningr�get_child_watcher� is_activerN� create_future�_UnixSubprocessTransport�add_child_handler�get_pid�_child_watcher_callback� SystemExit�KeyboardInterrupt� BaseExceptionr1�_wait) r+rmrV�shell�stdin�stdout�stderr�bufsizero�kwargs�watcherrn�transps r�_make_subprocess_transportz1_UnixSelectorEventLoop._make_subprocess_transport�s/����� $� $� &��!�!�(�,>�?��.�.�0�G�'���$�$�&� #�$G�H�H��'�'�)�F�-�d�H�d�E�,1�6�6�7�6�39��6�/5�6�F� �%�%�f�n�n�&6�$(�$@�$@�&� J� ����!�0� �9'� &��(��� 1�2� �� � ������l�l�n�$�$�� ��'�0� �se�D4�/C� D4�A-D'�>C!�C�C!� D4�C�D4�C!�!;D$�D�D$�$D'�'D1�,D4c�<�|j|j|�yr)�call_soon_threadsafe�_process_exited)r+�pid� returncoder�s rrz._UnixSelectorEventLoop._child_watcher_callback�s���!�!�&�"8�"8�*�Er)�ssl�sock�server_hostname�ssl_handshake_timeout�ssl_shutdown_timeoutc���K�|r |�2td��|�td��|�td��|�td��|��|�td��tj|�}tjtjtj d�} |j d�|j||��d{���nf|�td��|jtjk7s|jtj k7rtd |����|j d�|j||||||� ��d{���\}} || fS7��#|j��xYw7�#�w)Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with ssl�1ssl_handshake_timeout is only meaningful with ssl�0ssl_shutdown_timeout is only meaningful with ssl�3path and sock can not be specified at the same timerFzno path and sock were specified�.A UNIX Domain Stream Socket was expected, got )r�r�)r#r!�fspath�socket�AF_UNIX�SOCK_STREAM�setblocking�sock_connectr1�family�type�_create_connection_transport) r+�protocol_factory�pathr�r�r�r�r�� transportrms r�create_unix_connectionz-_UnixSelectorEventLoop.create_unix_connection�s�������&� �E�G�G��*� �!N�O�O�$�0� �G�I�I�#�/� �F�H�H����� �I�K�K��9�9�T�?�D��=�=�����1C�1C�Q�G�D� �� � ��'��'�'��d�3�3�3��|� �!B�C�C����v�~�~�-��I�I��!3�!3�3� �D�T�H�M�O�O����U�#�$(�$E�$E��"�C��"7�!5�%F�%7�7�� �8��(�"�"�%4�� �� � ����7�s=�BE#�&E�7E �8E�<BE#�=E!�>E#� E�E�E#�dT)r��backlogr�r�r�� start_servingc ��K�t|t�rtd��|� |std��|� |std��|��|�td��t j |�}t jtjtj�}|ddvrH tjt j|�j�rt j|� |j#|�nU|�td ��|j*tjk7s|j,tjk7rtd|����|j/d�t1j2||g|||||�}|r-|j5�t7j8d��d{���|S#t$rY��t$r!} tj d|| �Yd} ~ ��d} ~ wwxYw#t$rT} |j%�| j&t&j(k(r!d|�d �}tt&j(|�d��d} ~ w|j%��xYw7���w) Nz*ssl argument must be an SSLContext or Noner�r�r�r)r�z2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedr�F)rf�boolrFr#r!r�r�r�r��stat�S_ISSOCK�st_mode�remove�FileNotFoundErrorrMr�error�bindr1rS� EADDRINUSEr�r�r�r�Server�_start_servingr�sleep) r+r�r�r�r�r�r�r�r��errrW�msg�servers r�create_unix_serverz)_UnixSelectorEventLoop.create_unix_servers7�����c�4� ��H�I�I� �,�S��C�E� E� �+�C��B�D� D����� �I�K�K��9�9�T�?�D��=�=�����1C�1C�D�D��A�w�k�)�6��}�}�R�W�W�T�]�%:�%:�;�� � �$�� �� � �$���|� �C�E�E����v�~�~�-��I�I��!3�!3�3� �D�T�H�M�O�O� ������#�#�D�4�&�2B�$'��2G�$8�:����!�!�#��+�+�a�.� � �� ��S)����6��L�L�"*�+/��6�6��6��� �� � ���9�9�� 0� 0�0�%�T�H�,>�?�C�!�%�"2�"2�C�8�d�B��� �� � ����& !�si�BI�AF'�"G�3B-I� I�!I�' G�0I�2G�:G�I�G�I� I�'AH6�6I�Ic ��K� tj |j�} tj|�j}|r|n|}|sy|j�} |j| d|||||d�| �d{���S#t$rtjd��wxYw#ttjf$r}tjd��d}~wwxYw#t$rtjd��wxYw7�~�w)Nzos.sendfile() is not availableznot a regular filer) r!�sendfile�AttributeErrorr �SendfileNotAvailableErrorrL�io�UnsupportedOperation�fstat�st_sizerMr{�_sock_sendfile_native_impl) r+r��file�offset�countrLr��fsize� blocksize�futs r�_sock_sendfile_nativez,_UnixSelectorEventLoop._sock_sendfile_nativebs���� 2��K�K� M��[�[�]�F� M��H�H�V�$�,�,�E�#�E�� ���� � �"���'�'��T�4��(.��y�!� E��y���%� 2��6�6�0�2� 2� 2�� �� 7� 7�8� M��6�6�7K�L�L�� M��� M��6�6�7K�L�L� M���sV�C<�B�B"�C�6C<�;C:�<C<�B�C<�"C�;C�C�C<�C7�7C<c ��|j�} |�|j|�|j�r|j|||�y|r/||z }|dkr%|j|||�|j |�y tj| |||�} | dk(r%|j|||�|j |�y|| z }|| z }|�|j||�|j| |j|| ||||||� y#ttf$r;|�|j||�|j| |j|| ||||||� Yyt$r�}|�Q|jtjk(r4t|�t ur#t!dtj�}||_|}|dk(r:t%j&d�} |j|||�|j)| �n)|j|||�|j)|�Yd}~yYd}~yd}~wt*t,f$r�t.$r.}|j|||�|j)|�Yd}~yd}~wwxYw)Nrzsocket is not connectedzos.sendfile call failed)rL� remove_writer� cancelled�_sock_sendfile_update_filepos� set_resultr!r��_sock_add_cancellation_callback� add_writerr��BlockingIOError�InterruptedErrorrMrS�ENOTCONNr��ConnectionError� __cause__r r�� set_exceptionr�r�r�)r+r�� registered_fdr�rLr�r�r�� total_sent�fd�sentrW�new_excr�s rr�z1_UnixSelectorEventLoop._sock_sendfile_native_implysT�� �[�[�]���$� ���}�-��=�=�?��.�.�v�v�z�J���� �*�I��A�~��2�2�6�6�:�N����z�*��1 F��;�;�r�6�6�9�=�D�J�q�y��2�2�6�6�:�N����z�*��$����d�"� � �(��8�8��d�C�����D�$C�$C�S� "�D�&� &��y�*�F��[ �!1�2� B��$��4�4�S�$�?��O�O�B�� ?� ?����f�"�E�9�j� B�� '��)��I�I����/���I�_�4� *�-�u�~�~�?��$'��!����Q�� !�:�:�-�/���2�2�6�6�:�N��!�!�#�&��2�2�6�6�:�N��!�!�#�&�&�'���-�.� ��� #��.�.�v�v�z�J����c�"�"�� #�s,�:C?�?AI�I�B6H�I�+$I�Ic�Z�|dkDr&tj||tj�yy�Nr)r!�lseek�SEEK_SET)r+rLr�r�s rr�z4_UnixSelectorEventLoop._sock_sendfile_update_filepos�s"����>��H�H�V�V�R�[�[�1�rc�6�����fd�}|j|�y)Nc�v��|j�r(�j�}|dk7r�j|�yyy)Nr@)r�rLr�)r�r�r+r�s ��r�cbzB_UnixSelectorEventLoop._sock_add_cancellation_callback.<locals>.cb�s6����}�}���[�[�]����8��&�&�r�*��r)�add_done_callback)r+r�r�r�s` ` rr�z6_UnixSelectorEventLoop._sock_add_cancellation_callback�s��� +� ���b�!rr�NN)�__name__� __module__�__qualname__r)r1r>rZr<r5rGrprsr�rr�r�r�r�r�r�� __classcell__�r-s@rr&r&9s����� #�.�(�+�Z2��@ =�@D�(,�K�AE�)-�L�04��BF�*.�0#��4� �"&�!%�0#�f*.�G��s��"&�!%��G�R�.DF�L2�"rr&c���eZdZdZd�fd� Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zd�Z d�Zej fd �Zdd�Zd�Zd�Z�xZS)rjic�4��t�|�|�||jd<||_||_|j�|_||_d|_d|_ tj|j�j}tj|�sJtj|�s5tj |�s d|_d|_d|_t#d��tj$|jd�|jj'|jj(|�|jj'|j*|j|j,�|�,|jj't.j0|d�yy)NrlFz)Pipe transport is for pipes/sockets only.)r(r)�_extra�_loop�_piperL�_fileno� _protocol�_closing�_pausedr!r�r�r��S_ISFIFOr��S_ISCHRr#�set_blocking� call_soon�connection_made�_add_reader�_read_readyr �_set_result_unless_cancelled)r+�looprlrmrnro�moder-s �rr)z_UnixReadPipeTransport.__init__�s.��� �����"����F���� ��� ��{�{�}���!����� �����x�x����%�-�-��� � �d�#�� � �d�#����T�"��D�J��D�L�!�D�N��H�I�I� ������e�,�� � ���T�^�^�;�;�T�B�� � ���T�-�-�!�\�\�4�+;�+;� =����J�J� � ��!E�!E�!'�� /�rc�^�|j�sy|jj||�yr)� is_readingr�r�)r+r�rUs rr�z"_UnixReadPipeTransport._add_reader�s#����� ��� � ���r�8�,rc�:�|jxr |jSr)r�r��r+s rrz!_UnixReadPipeTransport.is_reading�s���<�<��5�� � �$5�5rc�t�|jjg}|j�|jd�n|jr|jd�|jd|j ���t |jdd�}|j�W|�Utj||j tj�}|r|jd�nA|jd�n/|j�|jd�n|jd�djd j|��S) N�closed�closing�fd=� _selector�polling�idle�open�<{}>� )r-r�r��appendr�r��getattrr�r�_test_selector_event� selectors� EVENT_READ�format�join)r+rRr,r s r�__repr__z_UnixReadPipeTransport.__repr__�s������'�'�(���:�:���K�K��!� �]�]��K�K� �"����c�$�,�,��(�)��4�:�:�{�D�9���:�:�!�h�&:�%�:�:��$�,�,� �(<�(<�>�G�����I�&����F�#� �Z�Z� #��K�K����K�K��!��}�}�S�X�X�d�^�,�,rc�h� tj|j|j�}|r|jj|�y|jj�rtjd|�d|_ |jj|j�|jj|jj�|jj|jd�y#tt f$rYyt"$r}|j%|d�Yd}~yd}~wwxYw)N�%r was closed by peerTz"Fatal read error on pipe transport)r!�readr��max_sizer�� data_receivedr�� get_debugrrRr��_remove_readerr��eof_received�_call_connection_lostr�r�rM�_fatal_error)r+r=rWs rr�z"_UnixReadPipeTransport._read_readys��� G��7�7�4�<�<����7�D�����,�,�T�2��:�:�'�'�)��K�K� 7��>� $�� �� � �)�)�$�,�,�7�� � �$�$�T�^�^�%@�%@�A�� � �$�$�T�%?�%?��F�� �!1�2� ��� I����c�#G�H�H�� I�s�*C<�<D1� D1�D,�,D1c���|j�syd|_|jj|j�|jj�rt jd|�yy)NTz%r pauses reading)rr�r�rr�rr�debugrs r� pause_readingz$_UnixReadPipeTransport.pause_readingsP����� ������ � �!�!�$�,�,�/��:�:���!��L�L�,�d�3�"rc��|js|jsyd|_|jj|j|j �|jj �rtjd|�yy)NFz%r resumes reading) r�r�r�r�r�r�rrr"rs r�resume_readingz%_UnixReadPipeTransport.resume_reading%s[���=�=��������� � ���t�|�|�T�-=�-=�>��:�:���!��L�L�-�t�4�"rc��||_yr�r��r+rms r�set_protocolz#_UnixReadPipeTransport.set_protocol-� ��!��rc��|jSrr'rs r�get_protocolz#_UnixReadPipeTransport.get_protocol0����~�~�rc��|jSr�r�rs r� is_closingz!_UnixReadPipeTransport.is_closing3����}�}�rc�@�|js|jd�yyr)r��_closers rr1z_UnixReadPipeTransport.close6s���}�}��K�K���rc�v�|j�-|d|��t|��|jj�yy�Nzunclosed transport r/�r�r8r1�r+�_warns r�__del__z_UnixReadPipeTransport.__del__:�5���:�:�!��'��x�0�/�$�O��J�J����"rc�<�t|t�rQ|jtjk(r4|jj�rDt jd||d��n*|jj||||jd��|j|�y�Nz%r: %sT��exc_info)�message� exceptionr�rm)rfrMrS�EIOr�rrr"�call_exception_handlerr�r3�r+rWr?s rr z#_UnixReadPipeTransport._fatal_error?sr���s�G�$����e�i�i�)?��z�z�#�#�%����X�t�W�t�D��J�J�-�-�"� �!� �N�N� /� � ���C�rc��d|_|jj|j�|jj |j |�y�NT)r�r�rr�r�r�r+rWs rr3z_UnixReadPipeTransport._closeMs9���� �� � �!�!�$�,�,�/�� � ���T�7�7��=rc�� |jj|�|jj�d|_d|_d|_y#|jj�d|_d|_d|_wxYwr�r��connection_lostr�r1r�rFs rrz,_UnixReadPipeTransport._call_connection_lostR�g�� ��N�N�*�*�3�/��J�J�����D�J�!�D�N��D�J�� �J�J�����D�J�!�D�N��D�J���A � 1A>r��zFatal error on pipe transport)r�r�r�rr)r�rrr�r#r%r)r,r0r1r6r7r9r r3rr�r�s@rrjrj�s]����H�/�<-� 6�-�*G�$4�5�"����%�M�M�� �>� rrjc���eZdZd�fd� Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zd�Z d�Zej fd �Zd�Zdd�Zdd�Zd�Z�xZS)rrc���t� |�||�||jd<||_|j �|_||_t�|_d|_ d|_ tj|j �j}tj|�}tj |�}tj"|�} |s$|s"| s d|_d|_d|_t%d��tj&|j d�|j(j+|jj,|�| s!|rdt.j0j3d�sE|j(j+|j(j4|j |j6�|�,|j(j+t8j:|d�yy)NrlrFz?Pipe transport is only for pipes, sockets and character devices�aix)r(r)r�r�rLr�r�� bytearray�_buffer� _conn_lostr�r!r�r�r�r�r�r�r#r�r�r�r�r2�platform� startswithr�r�r r�)r+r�rlrmrnror�is_char�is_fifo� is_socketr-s �rr)z _UnixWritePipeTransport.__init___si��� �����%�"����F���� ��{�{�}���!��� �{�������� ��x�x����%�-�-���,�,�t�$���-�-��%���M�M�$�'� ��7�i��D�J��D�L�!�D�N��D�E� E� ������e�,�� � ���T�^�^�;�;�T�B� �����)@�)@��)G��J�J� � ����!7�!7�!%���t�/?�/?� A����J�J� � ��!E�!E�!'�� /�rc��|jjg}|j�|jd�n|jr|jd�|jd|j ���t |jdd�}|j�{|�ytj||j tj�}|r|jd�n|jd�|j�}|jd|���n/|j�|jd�n|jd�d jd j|��S)Nrrrr r rzbufsize=rr r)r-r�r�rr�r�rr�rrr�EVENT_WRITE�get_write_buffer_sizerr)r+rRr,r r�s rrz _UnixWritePipeTransport.__repr__�s�����'�'�(���:�:���K�K��!� �]�]��K�K� �"����c�$�,�,��(�)��4�:�:�{�D�9���:�:�!�h�&:�%�:�:��$�,�,� �(=�(=�?�G�����I�&����F�#��0�0�2�G��K�K�(�7�)�,�-� �Z�Z� #��K�K����K�K��!��}�}�S�X�X�d�^�,�,rc�,�t|j�Sr)�lenrQrs rrZz-_UnixWritePipeTransport.get_write_buffer_size�s���4�<�<� � rc���|jj�rtjd|�|jr|jt ��y|j�y)Nr)r�rrrRrQr3�BrokenPipeErrorrs rr�z#_UnixWritePipeTransport._read_ready�s@���:�:���!��K�K�/��6��<�<��K�K��)�*��K�K�Mrc��t|t�rt|�}|sy|js|jrH|jt jk\rtjd�|xjdz c_y|jss tj|j|�}|t'|�k(ry|dkDrt|�|d}|j(j+|j|j,�|xj|z c_ |j/�y#ttf$rd}Y��tt f$r�t"$r1}|xjdz c_|j%|d�Yd}~yd}~wwxYw)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rr�#Fatal write error on pipe transport)rfrP� memoryviewrRr�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr�warningrQr!�writer�r�r�r�r�r�r r\r��_add_writer�_write_ready�_maybe_pause_protocol)r+r=�nrWs rrdz_UnixWritePipeTransport.write�s7���d�I�&��d�#�D����?�?�d�m�m����)�"M�"M�M���� H�I��O�O�q� �O���|�|� ��H�H�T�\�\�4�0���C��I�~���Q��!�$�'���+���J�J�"�"�4�<�<��1B�1B�C��������"�"�$��$�%5�6� ���� 1�2� �� � ����1�$���!�!�#�'L�M��� �s� D$�$E?�7E?�'E:�:E?c�� tj|j|j�}|t |j�k(r�|jj�|jj|j�|j�|jr6|jj|j�|jd�y|dkDr|jd|�=yy#ttf$rYyttf$r�t $rp}|jj�|xj"dz c_|jj|j�|j%|d�Yd}~yd}~wwxYw)Nrrr`)r!rdr�rQr\r9r��_remove_writer�_maybe_resume_protocolr�rrr�r�r�r�r�rRr )r+rhrWs rrfz$_UnixWritePipeTransport._write_ready�s.�� %�������t�|�|�4�A��C����%�%����"�"�$�� � �)�)�$�,�,�7��+�+�-��=�=��J�J�-�-�d�l�l�;��.�.�t�4���Q���L�L��!��$���) �!1�2� ���-�.� ��� J��L�L��� ��O�O�q� �O� �J�J�%�%�d�l�l�3����c�#H�I�I�� J�s�*C,�,F�=F�A&E?�?Fc��yrErrs r� can_write_eofz%_UnixWritePipeTransport.can_write_eof����rc���|jryd|_|jsL|jj|j�|jj|jd�yyrE)r�rQr�rr�r�rrs r� write_eofz!_UnixWritePipeTransport.write_eof�sO���=�=���� ��|�|��J�J�%�%�d�l�l�3��J�J� � ��!;�!;�T�B�rc��||_yrr'r(s rr)z$_UnixWritePipeTransport.set_protocol�r*rc��|jSrr'rs rr,z$_UnixWritePipeTransport.get_protocol�r-rc��|jSrr/rs rr0z"_UnixWritePipeTransport.is_closing�r1rc�X�|j�|js|j�yyyr)r�r�rprs rr1z_UnixWritePipeTransport.close�s$���:�:�!�$�-�-��N�N��+8�!rc�v�|j�-|d|��t|��|jj�yyr5r6r7s rr9z_UnixWritePipeTransport.__del__r:rc�&�|jd�yr)r3rs r�abortz_UnixWritePipeTransport.aborts�����D�rc��t|t�r4|jj�rDt j d||d��n*|jj ||||jd��|j|�yr<) rfrMr�rrr"rBr�r3rCs rr z$_UnixWritePipeTransport._fatal_error sc���c�7�#��z�z�#�#�%����X�t�W�t�D��J�J�-�-�"� �!� �N�N� /� � ���C�rc�>�d|_|jr%|jj|j�|jj�|jj |j�|jj|j|�yrE) r�rQr�rjr�r9rr�rrFs rr3z_UnixWritePipeTransport._closesf���� ��<�<��J�J�%�%�d�l�l�3�������� � �!�!�$�,�,�/�� � ���T�7�7��=rc�� |jj|�|jj�d|_d|_d|_y#|jj�d|_d|_d|_wxYwrrHrFs rrz-_UnixWritePipeTransport._call_connection_lostrJrKr�rLr)r�r�r�r)rrZr�rdrfrmrpr)r,r0r1r6r7r9rwr r3rr�r�s@rrrrr\sd���#/�J-�0!��!%�F%�8�C�"���� %�M�M�� ��>�rrrc��eZdZd�Zy)r|c ���d}|tjk(r6tjj d�rtj�\}} tj|f||||d|d�|��|_|�=|j�t|j�d|��|j_d}|�!|j�|j�yy#|�!|j�|j�wwxYw)NrOF)r�r�r�r��universal_newlinesr��wb)� buffering) � subprocess�PIPEr2rSrTr�� socketpair�Popen�_procr1r�detachr�) r+rVr�r�r�r�r�r��stdin_ws r�_startz_UnixSubprocessTransport._start+s������J�O�O�#����(?�(?��(F� $�.�.�0�N�E�7� �#�)�)��E�!��v�f�#(�'�E�=C�E�D�J��"���� �#'����(8�$�'�#R�� � � ����"���� �� � ��#��w�"���� �� � ��#�s � A!C�%C7N)r�r�r�r�rrrr|r|)s�� rr|c�@�eZdZ d d�Zd�Zd�Zd�Zd�Zd�Zd�Z d �Z y)rNc�\�|jtk7rtjddd��yy)Nr�P{name!r} is deprecated as of Python 3.12 and will be removed in Python {remove}.����r�)r�r�r6�_deprecated)�clss r�__init_subclass__z&AbstractChildWatcher.__init_subclass__Xs,���>�>�X�%�� � �!7�;�%,� .�&rc�� t��r��NotImplementedError�r+r�rUrVs rr}z&AbstractChildWatcher.add_child_handler_s�� �"�#�#rc�� t��rr��r+r�s r�remove_child_handlerz)AbstractChildWatcher.remove_child_handlerjs�� 1� "�#�#rc�� t��rr��r+r�s r�attach_loopz AbstractChildWatcher.attach_looprs�� �"�#�#rc�� t��rr�rs rr1zAbstractChildWatcher.close|s�� �"�#�#rc�� t��rr�rs rrzzAbstractChildWatcher.is_active�s�� �"�#�#rc�� t��rr�rs r� __enter__zAbstractChildWatcher.__enter__�s�� *�"�#�#rc�� t��rr��r+�a�b�cs r�__exit__zAbstractChildWatcher.__exit__�s��(�!�#�#r)�returnN)r�r�r�r�r}r�r�r1rzr�r�rrrrrAs/���,.� $�$�$�$�$�$�$rrc�>�eZdZ d�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z y ) rc��|Srrrs rr�zPidfdChildWatcher.__enter__�����rc��yrr)r+�exc_type� exc_value� exc_tracebacks rr�zPidfdChildWatcher.__exit__����rc��yrErrs rrzzPidfdChildWatcher.is_active�rnrc��yrrrs rr1zPidfdChildWatcher.close�r�rc��yrrr�s rr�zPidfdChildWatcher.attach_loop�r�rc��tj�}tj|�}|j ||j ||||�yr)r�get_running_loopr!� pidfd_openr��_do_wait)r+r�rUrVr��pidfds rr}z#PidfdChildWatcher.add_child_handler�s:���&�&�(��� � �c�"������� � �s�E�8�T�Jrc�$�tj�}|j|� tj|d�\}}t|�}tj|�|||g|���y#t$rd}tjd|�Y�CwxYw)Nr�zJchild process pid %d exit status already read: will report returncode 255) rr�rr!�waitpidr"�ChildProcessErrorrrcr1) r+r�r�rUrVr��_r$r�s rr�zPidfdChildWatcher._do_wait�s����&�&�(�����E�"� 8�� � �3��*�I�A�v�0��7�J� �������j�(�4�(��!� ��J��N�N�.�� � �s�A+�+!B�Bc��yrErr�s rr�z&PidfdChildWatcher.remove_child_handler����rN)r�r�r�r�r�rzr1r�r}r�r�rrrrr�s0�� �� �� � �K� )�&rrc�6�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z y) �BaseChildWatcherc� �d|_i|_yr)r�� _callbacksrs rr)zBaseChildWatcher.__init__�s���� ���rc�&�|jd�yr)r�rs rr1zBaseChildWatcher.close�s������rc�V�|jduxr|jj�Sr)r�� is_runningrs rrzzBaseChildWatcher.is_active�s#���z�z��%�A�$�*�*�*?�*?�*A�Arc��t��rr�)r+�expected_pids r�_do_waitpidzBaseChildWatcher._do_waitpid����!�#�#rc��t��rr�rs r�_do_waitpid_allz BaseChildWatcher._do_waitpid_all�r�rc�^�|j�(|�&|jrtjdt�|j�)|jjtj�||_|�;|jtj|j�|j�yy)NzCA loop is being detached from a child watcher with pending handlers)r�r�r6r7�RuntimeWarningr5rI�SIGCHLDrZ� _sig_chldr�r�s rr�zBaseChildWatcher.attach_loop�s����:�:�!�d�l�t����M�M�=�� � �:�:�!��J�J�,�,�V�^�^�<��� ����#�#�F�N�N�D�N�N�C� � � �"�rc�� |j�y#ttf$r�t$r(}|jjd|d��Yd}~yd}~wwxYw)N�$Unknown exception in SIGCHLD handler)r?r@)r�r�r�r�r�rBrFs rr�zBaseChildWatcher._sig_chld�sX�� �� � �"���-�.� ��� � �J�J�-�-�A� �/� � �� �s��A�A�AN) r�r�r�r)r1rzr�r�r�r�rrrr�r��s&����B�$�$�#�(rr�c�N��eZdZ �fd�Z�fd�Zd�Zd�Zd�Zd�Zd�Z d�Z �xZS) rc�R��t�|��tjddd��y)Nrr�r�r�)r(r)r6r��r+r-s �rr)zSafeChildWatcher.__init__s'��� �������/�;�%,� .rc�V��|jj�t�|� �yr)r�r9r(r1r�s �rr1zSafeChildWatcher.closes��������� �� �rc��|Srrrs rr�zSafeChildWatcher.__enter__r�rc��yrrr�s rr�zSafeChildWatcher.__exit__r�rc�H�||f|j|<|j|�yr)r�r�r�s rr}z"SafeChildWatcher.add_child_handler"s%�� (�$�/������ ����rc�>� |j|=y#t$rYywxYw�NTF�r�r`r�s rr�z%SafeChildWatcher.remove_child_handler(�(�� �����$���� �� ��� � �c�Z�t|j�D]}|j|��yr�r4r�r�r�s rr�z SafeChildWatcher._do_waitpid_all/s#������(�C����S�!�)rc�� tj|tj�\}}|dk(ryt|�}|jj�rt jd||� |jj|�\}}|||g|���y#t$r|}d}t jd|�Y�OwxYw#t$r7|jj�rt jd|d��YyYywxYw)Nr�$process %s exited with returncode %sr��8Unknown child process pid %d, will report returncode 255�'Child watcher got an unexpected pid: %rTr=) r!r��WNOHANGr"r�rrr"r�rcr��popr`)r+r�r�r$r�rUrVs rr�zSafeChildWatcher._do_waitpid4s��� 7��*�*�\�2�:�:�>�K�C���a�x��/��7�J��z�z�#�#�%����C�)�:�7� -�!�_�_�0�0��5�N�H�d� �S�*�,�t�,��7!� ��C��J��N�N�J�� � ��(� 3��z�z�#�#�%����H�"�T�3�&� 3�s#�'B�-B?�#B<�;B<�?;C?�>C?)r�r�r�r)r1r�r�r}r�r�r�r�r�s@rrrs0����.��� ���"� -rrc�H��eZdZ �fd�Z�fd�Zd�Zd�Zd�Zd�Zd�Z �xZ S)rc���t�|��tj�|_i|_d|_tjddd��y)Nrrr�r�r�) r(r)� threading�Lock�_lock�_zombies�_forksr6r�r�s �rr)zFastChildWatcher.__init__asC��� �����^�^�%�� ��� �������/�;�%,� .rc���|jj�|jj�t�|��yr)r�r9r�r(r1r�s �rr1zFastChildWatcher.closeks,���������� � ���� �� �rc�t�|j5|xjdz c_|cddd�S#1swYyxYw)Nr)r�r�rs rr�zFastChildWatcher.__enter__ps$�� �Z�Z��K�K�1��K���Z�Z�s�.�7c�>�|j5|xjdzc_|js|js ddd�yt|j�}|jj �ddd�tjd�y#1swY� xYw)Nrz5Caught subprocesses termination from unknown pids: %s)r�r�r�rOr9rrc)r+r�r�r��collateral_victimss rr�zFastChildWatcher.__exit__vsp�� �Z�Z��K�K�1��K��{�{�$�-�-�� �Z�"%�T�]�]�!3���M�M���!�� ���C�� ��Z�s�/B�/B�Bc���|j5 |jj|�} ddd�||g|���y#t$r||f|j|<Yddd�ywxYw#1swY�<xYwr)r�r�r�r`r�)r+r�rUrVr�s rr}z"FastChildWatcher.add_child_handler�so���Z�Z� �!�]�]�.�.�s�3� �� ��j�(�4�(�� � �'/��~�����$�� �Z� ���Z�s&�A&�>�A#�A&�"A#�#A&�&A/c�>� |j|=y#t$rYywxYwr�r�r�s rr�z%FastChildWatcher.remove_child_handler�r�r�c�� tjdtj�\}}|dk(ryt|�}|j 5 |jj|�\}}|jj�rtjd||� ddd��tjd||�n |||g�����#t$rYywxYw#t$r\|jrK||j|<|jj�rtjd||�Yddd���4d}Y��wxYw#1swY��xYw)Nr@rr�z,unknown process %s exited with returncode %sz8Caught subprocess termination from unknown pid: %d -> %d)r!r�r�r"r�r�r�r�r�rrr"r`r�r�rc)r+r�r$r�rUrVs rr�z FastChildWatcher._do_waitpid_all�s8��� <� �j�j��R�Z�Z�8���V� �!�8��3�F�;� ����6�%)�_�_�%8�%8��%=�N�H�d��z�z�+�+�-����%K�%(�*�6�!�&������ #�Z�1���j�0�4�0�K��%� �� �� � $��{�{�-7�� � �c�*��:�:�/�/�1�"�L�L�*>�),�j�:�!��� $�H� $����sN�'C�D=� C�'2D=� C�C�AD:�*D=�5D:�7D=�9D:�:D=�=E)r�r�r�r)r1r�r�r}r�r�r�r�s@rrrWs+����.�� � �)��(1rrc�P�eZdZ d�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zd�Z y) rc�P�i|_d|_tjddd��y)Nrr�r�r�)r��_saved_sighandlerr6r�rs rr)zMultiLoopChildWatcher.__init__�s*�����!%������4�;�%,� .rc��|jduSr)r�rs rrzzMultiLoopChildWatcher.is_active�s���%�%�T�1�1rc�Z�|jj�|j�ytjtj �}||jk7rtjd�d|_ytjtj |j�d|_y)Nz+SIGCHLD handler was changed by outside code) r�r9r�rI� getsignalr�r�rrc)r+rds rr1zMultiLoopChildWatcher.close�sz���������!�!�)���"�"�6�>�>�2���d�n�n�$��N�N�H�I�"&��� �M�M�&�.�.�$�*@�*@�A�!%��rc��|Srrrs rr�zMultiLoopChildWatcher.__enter__�r�rc��yrr�r+r��exc_val�exc_tbs rr�zMultiLoopChildWatcher.__exit__�r�rc�r�tj�}|||f|j|<|j|�yr)rr�r�r�)r+r�rUrVr�s rr}z'MultiLoopChildWatcher.add_child_handler�s5���&�&�(�� $�h��5������ ����rc�>� |j|=y#t$rYywxYwr�r�r�s rr�z*MultiLoopChildWatcher.remove_child_handler�r�r�c�8�|j�ytjtj|j�|_|j�*t j d�tj|_tjtjd�y)NzaPrevious SIGCHLD handler was set by non-Python code, restore to default handler on watcher close.F)r�rIr�r�rrcrcrQr�s rr�z!MultiLoopChildWatcher.attach_loopso�� �!�!�-��!'���v�~�~�t�~�~�!N����!�!�)��N�N�J� K�%+�^�^�D�"� ���F�N�N�E�2rc�Z�t|j�D]}|j|��yrr�r�s rr�z%MultiLoopChildWatcher._do_waitpid_alls#������(�C����S�!�)rc�*� tj|tj�\}}|dk(ryt|�}d} |jj|�\}}}|j�rtjd||�y|r'|j�rtjd||�|j|||g|���y#t$r|}d}tjd|�d}Y��wxYw#t$rtjd|d� �YywxYw) NrTr�r�F�%Loop %r that handles pid %r is closedr�r�r=)r!r�r�r"r�rrcr�r�� is_closedrr"r�r`) r+r�r�r$r�� debug_logr�rUrVs rr�z!MultiLoopChildWatcher._do_waitpids �� ��*�*�\�2�:�:�>�K�C���a�x��/��7�J��I� L�#'�?�?�#6�#6�s�#;� �D�(�D��~�~�����F��c�R�����!1��L�L�!G�!-�z�;�)��)�)�(�C��K�d�K��=!� ��C��J��N�N�J�� ��I� ��$� /� �N�N�D��� /� /�s"�'C�C.�%C+�*C+�.!D�Dc�� |j�y#ttf$r�t$rt j dd��YywxYw)Nr�Tr=)r�r�r�r�rrc)r+rrs rr�zMultiLoopChildWatcher._sig_chld<sE�� R�� � �"���-�.� ��� R��N�N�A�D�Q� R�s��/A�AN)r�r�r�r)rzr1r�r�r}r�r�r�r�r�rrrrr�sA�� �$.�2� &�� ���3�""�#L�JRrrc�b�eZdZ d�Zd�Zd�Zd�Zd�Zejfd�Z d�Zd�Zd �Z d �Zy)rc�F�tjd�|_i|_yr�)� itertoolsr��_pid_counter�_threadsrs rr)zThreadedChildWatcher.__init__Rs��%�O�O�A�.����� rc��yrErrs rrzzThreadedChildWatcher.is_activeVrnrc��yrrrs rr1zThreadedChildWatcher.closeYr�rc��|Srrrs rr�zThreadedChildWatcher.__enter__\r�rc��yrrr�s rr�zThreadedChildWatcher.__exit___r�rc���t|jj��D�cgc]}|j�r|��}}|r||j�d�t |��yycc}w)Nz0 has registered but not finished child processesr/)r4r�values�is_aliver-r8)r+r8�thread�threadss rr9zThreadedChildWatcher.__del__bse��(,�T�]�]�-A�-A�-C�(D�)�(D�f��o�o�'��(D��)���T�^�^�$�$T�U�!�� ���)s�A!c���tj�}tj|jdt|j���||||fd��}||j|<|j�y)Nzasyncio-waitpid-T)�target�namerV�daemon) rr�r��Threadr��nextr r�start)r+r�rUrVr�rs rr}z&ThreadedChildWatcher.add_child_handlerjsf���&�&�(���!�!��)9�)9�)9�$�t�?P�?P�:Q�9R�'S�(,�c�8�T�'B�)-�/��$�� � �c�����rc��yrErr�s rr�z)ThreadedChildWatcher.remove_child_handlersr�rc��yrrr�s rr�z ThreadedChildWatcher.attach_loopyr�rc�� tj|d�\}}t|�}|j�rt j d||� |j�rt jd||�n|j|||g|���|jj|�y#t$r|}d}t jd|�Y�~wxYw)Nrr�r�r�r)r!r�r"rrr"r�rcrr�rr�)r+r�r�rUrVr�r$r�s rr�z ThreadedChildWatcher._do_waitpid|s��� 7��*�*�\�1�5�K�C��0��7�J��~�~�����C�)�:�7��>�>���N�N�B�D�#�N�%�D�%�%�h��Z�G�$�G�� � ���,�'��'!� ��C��J��N�N�J�� � �s�B'�'#C �C N)r�r�r�r)rzr1r�r�r6r7r9r}r�r�r�rrrrrEsB�� ��� �� �%�M�M���� �(rrc��ttd�sy tj�}tjtj|d��y#t $rYywxYw)Nr�FrT)�hasattrr!�getpidr1r�rM)r�s r� can_use_pidfdr"�sO���2�|�$����i�i�k�� ������s�A�&�'�������s�=A� A�Ac�@��eZdZ eZ�fd�Zd�Z�fd�Zd�Zd�Z �xZ S)�_UnixDefaultEventLoopPolicyc�0��t�|��d|_yr)r(r)�_watcherr�s �rr)z$_UnixDefaultEventLoopPolicy.__init__�s��� ������ rc��tj5|j�)t�rt �|_nt�|_ddd�y#1swYyxYwr)rr�r&r"rrrs r� _init_watcherz)_UnixDefaultEventLoopPolicy._init_watcher�s6�� �\�\��}�}�$� �?�$5�$7�D�M�$8�$:�D�M��\�\�s�6A�Ac���� t�|�|�|j�Etj�tj �ur|jj |�yyyr)r(�set_event_loopr&r��current_thread�main_threadr�)r+r�r-s �rr*z*_UnixDefaultEventLoopPolicy.set_event_loop�sX��� � ���t�$��M�M�%��(�(�*�i�.C�.C�.E�E��M�M�%�%�d�+�F� &rc�� |j�|j�tjddd��|jS)Nryr�r�r�)r&r(r6r�rs rryz-_UnixDefaultEventLoopPolicy.get_child_watcher�sE�� ��=�=� ���� ����0�:�BI� K��}�}�rc�� |j�|jj�||_tjddd��y)N�set_child_watcherr�r�r�)r&r1r6r�)r+r�s rr/z-_UnixDefaultEventLoopPolicy.set_child_watcher�sB��2��=�=�$��M�M���!��� ����0�:�BI� Kr)r�r�r�r&� _loop_factoryr)r(r*ryr/r�r�s@rr$r$�s%���D�*�M��;�,��Krr$)3rSr�r r!rrIr�r�r�r2r�r6�rrrrrr r rrr �logr�__all__rS�ImportErrorrr"�BaseSelectorEventLoopr&� ReadTransportrj�_FlowControlMixin�WriteTransportrr�BaseSubprocessTransportr|rrr�rrrrr"�BaseDefaultEventLoopPolicyr$rrrrr�<module>r;se��8�� �� �� � ��� �����������������<�<�7�� �C� D�D� � �P"�_�B�B�P"�fM�Z�5�5�M�`J�j�:�:�(�7�7�J�Z ��F�F� �0S$�S$�l7�,�7�t2�+�2�jN-�'�N-�bj1�'�j1�Z~R�0�~R�BO(�/�O(�b �6K�&�"C�"C�6K�r+��4�r__pycache__/unix_events.cpython-312.pyc000064400000204222151706172560014042 0ustar00� T��h�����dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlZddlZddl mZddl mZddl mZddl mZddl mZdd l mZdd l mZddl mZddl mZdd l mZddlmZdZe j6dk(red��d�Zd�ZGd�dej>�Z Gd�dejB�Z"Gd�dejFejH�Z%Gd�dejL�Z'Gd�d�Z(Gd�de(�Z)Gd �d!e(�Z*Gd"�d#e*�Z+Gd$�d%e*�Z,Gd&�d'e(�Z-Gd(�d)e(�Z.d*�Z/Gd+�d,ej`�Z1e Z2e1Z3y)-z2Selector event loop for Unix with signal handling.�N�)�base_events)�base_subprocess)� constants)� coroutines)�events)� exceptions)�futures)�selector_events)�tasks)� transports)�logger)�SelectorEventLoop�AbstractChildWatcher�SafeChildWatcher�FastChildWatcher�PidfdChildWatcher�MultiLoopChildWatcher�ThreadedChildWatcher�DefaultEventLoopPolicy�win32z+Signals are not really supported on Windowsc��y)zDummy signal handler.N�)�signum�frames �,/usr/lib64/python3.12/asyncio/unix_events.py�_sighandler_noopr*s���c�P� tj|�S#t$r|cYSwxYw�N)�os�waitstatus_to_exitcode� ValueError)�statuss rr"r"/s.����(�(��0�0����� � �s��%�%c���eZdZdZd�fd� Z�fd�Zd�Zd�Zd�Zd�Z d �Z dd �Z dd�Z dd�Z d �Z ddddddd�d�Z dddddddd�d�Zd�Zd�Zd�Zd�Z�xZS)�_UnixSelectorEventLoopzdUnix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. Nc�2��t�|�|�i|_yr )�super�__init__�_signal_handlers)�self�selector� __class__s �rr)z_UnixSelectorEventLoop.__init__?s��� ����"� "��rc�0��t�|��tj�s,t |j �D]}|j |��y|j r;tjd|�d�t|��|j j�yy)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal��source)r(�close�sys� is_finalizing�listr*�remove_signal_handler�warnings�warn�ResourceWarning�clear)r+�sigr-s �rr1z_UnixSelectorEventLoop.closeCs���� �� ��� � �"��D�1�1�2���*�*�3�/�3��$�$�� � � 1�$��:H�I�.�%)� +� �%�%�+�+�-� %rc�:�|D]}|s�|j|��yr )�_handle_signal)r+�datars r�_process_self_dataz)_UnixSelectorEventLoop._process_self_dataQs ���F�������'� rc�R�tj|�stj|�rtd��|j |�|j� t j|jj��tj|||d�}||j |< t j|t"�t j$|d�y#ttf$r}tt|���d}~wwxYw#t$r�}|j |=|j sI t jd�n2#ttf$r }t'j(d|�Yd}~nd}~wwxYw|j*t*j,k(rtd|�d����d}~wwxYw)z�Add a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. z3coroutines cannot be used with add_signal_handler()NF����set_wakeup_fd(-1) failed: %s�sig � cannot be caught)r�iscoroutine�iscoroutinefunction� TypeError� _check_signal� _check_closed�signal� set_wakeup_fd�_csock�filenor#�OSError�RuntimeError�strr�Handler*r�siginterruptr�info�errno�EINVAL)r+r:�callback�args�exc�handle�nexcs r�add_signal_handlerz)_UnixSelectorEventLoop.add_signal_handlerXsq�� �"�"�8�,��.�.�x�8��8�9� 9����3������ )� � � ����!3�!3�!5�6����x��t�T�:��%+����c�"� � �M�M�#�/�0� ����U�+���G�$� )��s�3�x�(�(�� )��� ��%�%�c�*��(�(�F��(�(��,��"�G�,�F��K�K� >��E�E��F���y�y�E�L�L�(�"�T�#��.?�#@�A�A��� �sZ�-C�-0D �D�-D�D� F&�F!�,E�F!�E1�E,�'F!�,E1�10F!�!F&c��|jj|�}|�y|jr|j|�y|j |�y)z2Internal helper that is the actual signal handler.N)r*�get� _cancelledr5�_add_callback_signalsafe)r+r:rXs rr<z%_UnixSelectorEventLoop._handle_signal�sE���&�&�*�*�3�/���>������&�&�s�+��)�)�&�1rc��|j|� |j|=|tjk(rtj }ntj} tj||�|js tjd�yy#t$rYywxYw#t$r2}|jtjk(rtd|�d����d}~wwxYw#ttf$r }tjd|�Yd}~yd}~wwxYw)zwRemove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. FrBrCNr@rAT)rGr*�KeyErrorrI�SIGINT�default_int_handler�SIG_DFLrMrSrTrNrJr#rrR)r+r:�handlerrWs rr5z,_UnixSelectorEventLoop.remove_signal_handler�s��� ���3�� ��%�%�c�*��&�-�-���0�0�G��n�n�G� ��M�M�#�w�'��$�$� A��$�$�R�(���-� �� ��� ��y�y�E�L�L�(�"�T�#��.?�#@�A�A��� ����(� A����:�C�@�@��� A�sA� B�B�8C� B�B� C�'-C�C�D�+D�Dc��t|t�std|����|tj�vrtd|����y)z�Internal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. zsig must be an int, not zinvalid signal number N)� isinstance�intrFrI� valid_signalsr#)r+r:s rrGz$_UnixSelectorEventLoop._check_signal�sJ���#�s�#��6�s�g�>�?�?��f�*�*�,�,��5�c�U�;�<�<�-rc� �t|||||�Sr )�_UnixReadPipeTransport�r+�pipe�protocol�waiter�extras r�_make_read_pipe_transportz0_UnixSelectorEventLoop._make_read_pipe_transport�s��%�d�D�(�F�E�J�Jrc� �t|||||�Sr )�_UnixWritePipeTransportrks r�_make_write_pipe_transportz1_UnixSelectorEventLoop._make_write_pipe_transport�s��&�t�T�8�V�U�K�Krc ��lK�tj�5tjdt�t j �} ddd� 5| j �std��|j�}t||||||||f||d�| ��}| j|j�|j|� |�d{��� ddd�|S#1swY��xYw7�#ttf$r�t$r+|j!�|j#��d{���7�wxYw#1swYSxYw�w)N�ignorezRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rnro)r6�catch_warnings�simplefilter�DeprecationWarningr�get_child_watcher� is_activerN� create_future�_UnixSubprocessTransport�add_child_handler�get_pid�_child_watcher_callback� SystemExit�KeyboardInterrupt� BaseExceptionr1�_wait) r+rmrV�shell�stdin�stdout�stderr�bufsizero�kwargs�watcherrn�transps r�_make_subprocess_transportz1_UnixSelectorEventLoop._make_subprocess_transport�s/����� $� $� &��!�!�(�,>�?��.�.�0�G�'���$�$�&� #�$G�H�H��'�'�)�F�-�d�H�d�E�,1�6�6�7�6�39��6�/5�6�F� �%�%�f�n�n�&6�$(�$@�$@�&� J� ����!�0� �9'� &��(��� 1�2� �� � ������l�l�n�$�$�� ��'�0� �se�D4�/C� D4�A-D'�>C!�C�C!� D4�C�D4�C!�!;D$�D�D$�$D'�'D1�,D4c�<�|j|j|�yr )�call_soon_threadsafe�_process_exited)r+�pid� returncoder�s rrz._UnixSelectorEventLoop._child_watcher_callback�s���!�!�&�"8�"8�*�Er)�ssl�sock�server_hostname�ssl_handshake_timeout�ssl_shutdown_timeoutc���K�|�t|t�sJ�|r |�2td��|�td��|�td��|�td��|��|�td��tj|�}tj t jt jd�} |jd�|j||��d{���nf|�td��|jt jk7s|jt jk7rtd |����|jd�|j||||||� ��d{���\}} || fS7��#|j��xYw7�#�w)Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with ssl�1ssl_handshake_timeout is only meaningful with ssl�0ssl_shutdown_timeout is only meaningful with ssl�3path and sock can not be specified at the same timerFzno path and sock were specified�.A UNIX Domain Stream Socket was expected, got )r�r�)rfrOr#r!�fspath�socket�AF_UNIX�SOCK_STREAM�setblocking�sock_connectr1�family�type�_create_connection_transport) r+�protocol_factory�pathr�r�r�r�r�� transportrms r�create_unix_connectionz-_UnixSelectorEventLoop.create_unix_connection�s������&�*�_�c�*J�J�J���&� �E�G�G��*� �!N�O�O�$�0� �G�I�I�#�/� �F�H�H����� �I�K�K��9�9�T�?�D��=�=�����1C�1C�Q�G�D� �� � ��'��'�'��d�3�3�3��|� �!B�C�C����v�~�~�-��I�I��!3�!3�3� �D�T�H�M�O�O����U�#�$(�$E�$E��"�C��"7�!5�%F�%7�7�� �8��(�"�"�%4�� �� � ����7�s=�B"E7�%&E�E�E�BE7�E5�E7�E�E2�2E7�dT)r��backlogr�r�r�� start_servingc ��K�t|t�rtd��|� |std��|� |std��|��|�td��t j |�}t jtjtj�}|ddvrH tjt j|�j�rt j|� |j#|�nU|�td ��|j*tjk7s|j,tjk7rtd|����|j/d�t1j2||g|||||�}|r-|j5�t7j8d��d{���|S#t$rY��t$r!} tj d|| �Yd} ~ ��d} ~ wwxYw#t$rT} |j%�| j&t&j(k(r!d|�d �}tt&j(|�d��d} ~ w|j%��xYw7���w) Nz*ssl argument must be an SSLContext or Noner�r�r�r)r�z2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedr�F)rf�boolrFr#r!r�r�r�r��stat�S_ISSOCK�st_mode�remove�FileNotFoundErrorrMr�error�bindr1rS� EADDRINUSEr�r�r�r�Server�_start_servingr�sleep) r+r�r�r�r�r�r�r�r��errrW�msg�servers r�create_unix_serverz)_UnixSelectorEventLoop.create_unix_servers7�����c�4� ��H�I�I� �,�S��C�E� E� �+�C��B�D� D����� �I�K�K��9�9�T�?�D��=�=�����1C�1C�D�D��A�w�k�)�6��}�}�R�W�W�T�]�%:�%:�;�� � �$�� �� � �$���|� �C�E�E����v�~�~�-��I�I��!3�!3�3� �D�T�H�M�O�O� ������#�#�D�4�&�2B�$'��2G�$8�:����!�!�#��+�+�a�.� � �� ��S)����6��L�L�"*�+/��6�6��6��� �� � ���9�9�� 0� 0�0�%�T�H�,>�?�C�!�%�"2�"2�C�8�d�B��� �� � ����& !�si�BI�AF'�"G�3B-I� I�!I�' G�0I�2G�:G�I�G�I� I�'AH6�6I�Ic ��K� tj |j�} tj|�j}|r|n|}|sy|j�} |j| d|||||d�| �d{���S#t$rtjd��wxYw#ttjf$r}tjd��d}~wwxYw#t$rtjd��wxYw7�~�w)Nzos.sendfile() is not availableznot a regular filer) r!�sendfile�AttributeErrorr �SendfileNotAvailableErrorrL�io�UnsupportedOperation�fstat�st_sizerMr{�_sock_sendfile_native_impl) r+r��file�offset�countrLr��fsize� blocksize�futs r�_sock_sendfile_nativez,_UnixSelectorEventLoop._sock_sendfile_nativebs���� 2��K�K� M��[�[�]�F� M��H�H�V�$�,�,�E�#�E�� ���� � �"���'�'��T�4��(.��y�!� E��y���%� 2��6�6�0�2� 2� 2�� �� 7� 7�8� M��6�6�7K�L�L�� M��� M��6�6�7K�L�L� M���sV�C<�B�B"�C�6C<�;C:�<C<�B�C<�"C�;C�C�C<�C7�7C<c ��|j�} |�|j|�|j�r|j|||�y|r/||z }|dkr%|j|||�|j |�y tj| |||�} | dk(r%|j|||�|j |�y|| z }|| z }|�|j||�|j| |j|| ||||||� y#ttf$r;|�|j||�|j| |j|| ||||||� Yyt$r�}|�Q|jtjk(r4t|�t ur#t!dtj�}||_|}|dk(r:t%j&d�} |j|||�|j)| �n)|j|||�|j)|�Yd}~yYd}~yd}~wt*t,f$r�t.$r.}|j|||�|j)|�Yd}~yd}~wwxYw)Nrzsocket is not connectedzos.sendfile call failed)rL� remove_writer� cancelled�_sock_sendfile_update_filepos� set_resultr!r��_sock_add_cancellation_callback� add_writerr��BlockingIOError�InterruptedErrorrMrS�ENOTCONNr��ConnectionError� __cause__r r�� set_exceptionr�r�r�)r+r�� registered_fdr�rLr�r�r�� total_sent�fd�sentrW�new_excr�s rr�z1_UnixSelectorEventLoop._sock_sendfile_native_implysT�� �[�[�]���$� ���}�-��=�=�?��.�.�v�v�z�J���� �*�I��A�~��2�2�6�6�:�N����z�*��1 F��;�;�r�6�6�9�=�D�J�q�y��2�2�6�6�:�N����z�*��$����d�"� � �(��8�8��d�C�����D�$C�$C�S� "�D�&� &��y�*�F��[ �!1�2� B��$��4�4�S�$�?��O�O�B�� ?� ?����f�"�E�9�j� B�� '��)��I�I����/���I�_�4� *�-�u�~�~�?��$'��!����Q�� !�:�:�-�/���2�2�6�6�:�N��!�!�#�&��2�2�6�6�:�N��!�!�#�&�&�'���-�.� ��� #��.�.�v�v�z�J����c�"�"�� #�s,�:C?�?AI�I�B6H�I�+$I�Ic�Z�|dkDr&tj||tj�yy�Nr)r!�lseek�SEEK_SET)r+rLr�r�s rr�z4_UnixSelectorEventLoop._sock_sendfile_update_filepos�s"����>��H�H�V�V�R�[�[�1�rc�6�����fd�}|j|�y)Nc�v��|j�r(�j�}|dk7r�j|�yyy)Nr@)r�rLr�)r�r�r+r�s ��r�cbzB_UnixSelectorEventLoop._sock_add_cancellation_callback.<locals>.cb�s6����}�}���[�[�]����8��&�&�r�*��r)�add_done_callback)r+r�r�r�s` ` rr�z6_UnixSelectorEventLoop._sock_add_cancellation_callback�s��� +� ���b�!rr �NN)�__name__� __module__�__qualname__�__doc__r)r1r>rZr<r5rGrprsr�rr�r�r�r�r�r�� __classcell__�r-s@rr&r&9s����� #�.�(�+�Z2��@ =�@D�(,�K�AE�)-�L�04��BF�*.�0#��4� �"&�!%�0#�f*.�G��s��"&�!%��G�R�.DF�L2�"rr&c���eZdZdZd�fd� Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zd�Z d�Zej fd �Zdd�Zd�Zd�Z�xZS)rjic�4��t�|�|�||jd<||_||_|j�|_||_d|_d|_ tj|j�j}tj|�sJtj|�s5tj |�s d|_d|_d|_t#d��tj$|jd�|jj'|jj(|�|jj'|j*|j|j,�|�,|jj't.j0|d�yy)NrlFz)Pipe transport is for pipes/sockets only.)r(r)�_extra�_loop�_piperL�_fileno� _protocol�_closing�_pausedr!r�r�r��S_ISFIFOr��S_ISCHRr#�set_blocking� call_soon�connection_made�_add_reader�_read_readyr �_set_result_unless_cancelled)r+�looprlrmrnro�moder-s �rr)z_UnixReadPipeTransport.__init__�s.��� �����"����F���� ��� ��{�{�}���!����� �����x�x����%�-�-��� � �d�#�� � �d�#����T�"��D�J��D�L�!�D�N��H�I�I� ������e�,�� � ���T�^�^�;�;�T�B�� � ���T�-�-�!�\�\�4�+;�+;� =����J�J� � ��!E�!E�!'�� /�rc�^�|j�sy|jj||�yr )� is_readingr�r�)r+r�rUs rr�z"_UnixReadPipeTransport._add_reader�s#����� ��� � ���r�8�,rc�:�|jxr |jSr )r�r��r+s rrz!_UnixReadPipeTransport.is_reading�s���<�<��5�� � �$5�5rc�t�|jjg}|j�|jd�n|jr|jd�|jd|j ���t |jdd�}|j�W|�Utj||j tj�}|r|jd�nA|jd�n/|j�|jd�n|jd�djd j|��S) N�closed�closing�fd=� _selector�polling�idle�open�<{}>� )r-r�r��appendr�r��getattrr�r�_test_selector_event� selectors� EVENT_READ�format�join)r+rRr,rs r�__repr__z_UnixReadPipeTransport.__repr__�s������'�'�(���:�:���K�K��!� �]�]��K�K� �"����c�$�,�,��(�)��4�:�:�{�D�9���:�:�!�h�&:�%�:�:��$�,�,� �(<�(<�>�G�����I�&����F�#� �Z�Z� #��K�K����K�K��!��}�}�S�X�X�d�^�,�,rc�h� tj|j|j�}|r|jj|�y|jj�rtjd|�d|_ |jj|j�|jj|jj�|jj|jd�y#tt f$rYyt"$r}|j%|d�Yd}~yd}~wwxYw)N�%r was closed by peerTz"Fatal read error on pipe transport)r!�readr��max_sizer�� data_receivedr�� get_debugrrRr��_remove_readerr��eof_received�_call_connection_lostr�r�rM�_fatal_error)r+r=rWs rr�z"_UnixReadPipeTransport._read_readys��� G��7�7�4�<�<����7�D�����,�,�T�2��:�:�'�'�)��K�K� 7��>� $�� �� � �)�)�$�,�,�7�� � �$�$�T�^�^�%@�%@�A�� � �$�$�T�%?�%?��F�� �!1�2� ��� I����c�#G�H�H�� I�s�*C<�<D1� D1�D,�,D1c���|j�syd|_|jj|j�|jj�rt jd|�yy)NTz%r pauses reading)rr�r�rr�rr�debugrs r� pause_readingz$_UnixReadPipeTransport.pause_readingsP����� ������ � �!�!�$�,�,�/��:�:���!��L�L�,�d�3�"rc��|js|jsyd|_|jj|j|j �|jj �rtjd|�yy)NFz%r resumes reading) r�r�r�r�r�r�rrr#rs r�resume_readingz%_UnixReadPipeTransport.resume_reading%s[���=�=��������� � ���t�|�|�T�-=�-=�>��:�:���!��L�L�-�t�4�"rc��||_yr �r��r+rms r�set_protocolz#_UnixReadPipeTransport.set_protocol-� ��!��rc��|jSr r(rs r�get_protocolz#_UnixReadPipeTransport.get_protocol0����~�~�rc��|jSr �r�rs r� is_closingz!_UnixReadPipeTransport.is_closing3����}�}�rc�@�|js|jd�yyr )r��_closers rr1z_UnixReadPipeTransport.close6s���}�}��K�K���rc�v�|j�-|d|��t|��|jj�yy�Nzunclosed transport r/�r�r8r1�r+�_warns r�__del__z_UnixReadPipeTransport.__del__:�5���:�:�!��'��x�0�/�$�O��J�J����"rc�<�t|t�rQ|jtjk(r4|jj�rDt jd||d��n*|jj||||jd��|j|�y�Nz%r: %sT��exc_info)�message� exceptionr�rm)rfrMrS�EIOr�rrr#�call_exception_handlerr�r4�r+rWr@s rr!z#_UnixReadPipeTransport._fatal_error?sr���s�G�$����e�i�i�)?��z�z�#�#�%����X�t�W�t�D��J�J�-�-�"� �!� �N�N� /� � ���C�rc��d|_|jj|j�|jj |j |�y�NT)r�r�rr�r�r �r+rWs rr4z_UnixReadPipeTransport._closeMs9���� �� � �!�!�$�,�,�/�� � ���T�7�7��=rc�� |jj|�|jj�d|_d|_d|_y#|jj�d|_d|_d|_wxYwr �r��connection_lostr�r1r�rGs rr z,_UnixReadPipeTransport._call_connection_lostR�g�� ��N�N�*�*�3�/��J�J�����D�J�!�D�N��D�J�� �J�J�����D�J�!�D�N��D�J���A � 1A>r��zFatal error on pipe transport)r�r�r�rr)r�rrr�r$r&r*r-r1r1r6r7r:r!r4r r�r�s@rrjrj�s]����H�/�<-� 6�-�*G�$4�5�"����%�M�M�� �>� rrjc���eZdZd�fd� Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zd�Z d�Zej fd �Zd�Zdd�Zdd�Zd�Z�xZS)rrc���t� |�||�||jd<||_|j �|_||_t�|_d|_ d|_ tj|j �j}tj|�}tj |�}tj"|�} |s$|s"| s d|_d|_d|_t%d��tj&|j d�|j(j+|jj,|�| s!|rdt.j0j3d�sE|j(j+|j(j4|j |j6�|�,|j(j+t8j:|d�yy)NrlrFz?Pipe transport is only for pipes, sockets and character devices�aix)r(r)r�r�rLr�r�� bytearray�_buffer� _conn_lostr�r!r�r�r�r�r�r�r#r�r�r�r�r2�platform� startswithr�r�r r�)r+rrlrmrnror�is_char�is_fifo� is_socketr-s �rr)z _UnixWritePipeTransport.__init___si��� �����%�"����F���� ��{�{�}���!��� �{�������� ��x�x����%�-�-���,�,�t�$���-�-��%���M�M�$�'� ��7�i��D�J��D�L�!�D�N��D�E� E� ������e�,�� � ���T�^�^�;�;�T�B� �����)@�)@��)G��J�J� � ����!7�!7�!%���t�/?�/?� A����J�J� � ��!E�!E�!'�� /�rc��|jjg}|j�|jd�n|jr|jd�|jd|j ���t |jdd�}|j�{|�ytj||j tj�}|r|jd�n|jd�|j�}|jd|���n/|j�|jd�n|jd�d jd j|��S)Nrrr r rrzbufsize=r rr)r-r�r�rr�r�rr�rrr�EVENT_WRITE�get_write_buffer_sizerr)r+rRr,rr�s rrz _UnixWritePipeTransport.__repr__�s�����'�'�(���:�:���K�K��!� �]�]��K�K� �"����c�$�,�,��(�)��4�:�:�{�D�9���:�:�!�h�&:�%�:�:��$�,�,� �(=�(=�?�G�����I�&����F�#��0�0�2�G��K�K�(�7�)�,�-� �Z�Z� #��K�K����K�K��!��}�}�S�X�X�d�^�,�,rc�,�t|j�Sr )�lenrRrs rr[z-_UnixWritePipeTransport.get_write_buffer_size�s���4�<�<� � rc���|jj�rtjd|�|jr|jt ��y|j�y)Nr)r�rrrRrRr4�BrokenPipeErrorrs rr�z#_UnixWritePipeTransport._read_ready�s@���:�:���!��K�K�/��6��<�<��K�K��)�*��K�K�Mrc�Z�t|tttf�sJt |���t|t�rt|�}|sy|j s|jrH|j tjk\rtjd�|xj dz c_y|jss tj|j|�}|t+|�k(ry|dkDrt|�|d}|j,j/|j|j0�|xj|z c_|j3�y#tt f$rd}Y��t"t$f$r�t&$r1}|xj dz c_|j)|d�Yd}~yd}~wwxYw)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rr�#Fatal write error on pipe transport)rf�bytesrQ� memoryview�reprrSr�r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr�warningrRr!�writer�r�r�r�r�r�r!r]r��_add_writer�_write_ready�_maybe_pause_protocol)r+r=�nrWs rrgz_UnixWritePipeTransport.write�sW���$�� �:� >�?�K��d��K�?��d�I�&��d�#�D����?�?�d�m�m����)�"M�"M�M���� H�I��O�O�q� �O���|�|� ��H�H�T�\�\�4�0���C��I�~���Q��!�$�'���+���J�J�"�"�4�<�<��1B�1B�C��������"�"�$��$�%5�6� ���� 1�2� �� � ����1�$���!�!�#�'L�M��� �s�7 E�F*�"F*�9'F%�%F*c�4�|jsJd�� tj|j|j�}|t |j�k(r�|jj�|jj|j�|j�|jr6|jj|j�|jd�y|dkDr|jd|�=yy#ttf$rYyttf$r�t $rp}|jj�|xj"dz c_|jj|j�|j%|d�Yd}~yd}~wwxYw)NzData should not be emptyrrra)rRr!rgr�r]r9r��_remove_writer�_maybe_resume_protocolr�rr r�r�r�r�r�rSr!)r+rkrWs rriz$_UnixWritePipeTransport._write_ready�s@���|�|�7�7�7�|� %�������t�|�|�4�A��C����%�%����"�"�$�� � �)�)�$�,�,�7��+�+�-��=�=��J�J�-�-�d�l�l�;��.�.�t�4���Q���L�L��!��$���) �!1�2� ���-�.� ��� J��L�L��� ��O�O�q� �O� �J�J�%�%�d�l�l�3����c�#H�I�I�� J�s�*C?�?F�F�'A&F�Fc��yrFrrs r� can_write_eofz%_UnixWritePipeTransport.can_write_eof����rc��|jry|jsJ�d|_|jsL|jj |j �|jj |jd�yyrF)r�r�rRr�rr�r�r rs r� write_eofz!_UnixWritePipeTransport.write_eof�s[���=�=���z�z��z��� ��|�|��J�J�%�%�d�l�l�3��J�J� � ��!;�!;�T�B�rc��||_yr r(r)s rr*z$_UnixWritePipeTransport.set_protocol�r+rc��|jSr r(rs rr-z$_UnixWritePipeTransport.get_protocol�r.rc��|jSr r0rs rr1z"_UnixWritePipeTransport.is_closing�r2rc�X�|j�|js|j�yyyr )r�r�rsrs rr1z_UnixWritePipeTransport.close�s$���:�:�!�$�-�-��N�N��+8�!rc�v�|j�-|d|��t|��|jj�yyr6r7r8s rr:z_UnixWritePipeTransport.__del__r;rc�&�|jd�yr )r4rs r�abortz_UnixWritePipeTransport.aborts�����D�rc��t|t�r4|jj�rDt j d||d��n*|jj ||||jd��|j|�yr=) rfrMr�rrr#rCr�r4rDs rr!z$_UnixWritePipeTransport._fatal_error sc���c�7�#��z�z�#�#�%����X�t�W�t�D��J�J�-�-�"� �!� �N�N� /� � ���C�rc�>�d|_|jr%|jj|j�|jj�|jj |j�|jj|j|�yrF) r�rRr�rmr�r9rr�r rGs rr4z_UnixWritePipeTransport._closesf���� ��<�<��J�J�%�%�d�l�l�3�������� � �!�!�$�,�,�/�� � ���T�7�7��=rc�� |jj|�|jj�d|_d|_d|_y#|jj�d|_d|_d|_wxYwr rIrGs rr z-_UnixWritePipeTransport._call_connection_lostrKrLr�rMr )r�r�r�r)rr[r�rgrirprsr*r-r1r1r6r7r:rzr!r4r r�r�s@rrrrr\sd���#/�J-�0!��!%�F%�8�C�"���� %�M�M�� ��>�rrrc��eZdZd�Zy)r|c ���d}|tjk(r6tjj d�rtj�\}} tj|f||||d|d�|��|_|�=|j�t|j�d|��|j_d}|�!|j�|j�yy#|�!|j�|j�wwxYw)NrPF)r�r�r�r��universal_newlinesr��wb)� buffering) � subprocess�PIPEr2rTrUr�� socketpair�Popen�_procr1r �detachr�) r+rVr�r�r�r�r�r��stdin_ws r�_startz_UnixSubprocessTransport._start+s������J�O�O�#����(?�(?��(F� $�.�.�0�N�E�7� �#�)�)��E�!��v�f�#(�'�E�=C�E�D�J��"���� �#'����(8�$�'�#R�� � � ����"���� �� � ��#��w�"���� �� � ��#�s � A!C�%C7N)r�r�r�r�rrrr|r|)s�� rr|c�B�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z d �Z d �Zy)raHAbstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. Nc�\�|jtk7rtjddd��yy)Nr�P{name!r} is deprecated as of Python 3.12 and will be removed in Python {remove}.����r�)r�r�r6�_deprecated)�clss r�__init_subclass__z&AbstractChildWatcher.__init_subclass__Xs,���>�>�X�%�� � �!7�;�%,� .�&rc��t��)aRegister a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. ��NotImplementedError�r+r�rUrVs rr}z&AbstractChildWatcher.add_child_handler_s ��"�#�#rc��t��)z�Removes the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.r��r+r�s r�remove_child_handlerz)AbstractChildWatcher.remove_child_handlerjs ��"�#�#rc��t��)z�Attach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. r��r+rs r�attach_loopz AbstractChildWatcher.attach_looprs ��"�#�#rc��t��)zlClose the watcher. This must be called to make sure that any underlying resource is freed. r�rs rr1zAbstractChildWatcher.close|s �� "�#�#rc��t��)z�Return ``True`` if the watcher is active and is used by the event loop. Return True if the watcher is installed and ready to handle process exit notifications. r�rs rrzzAbstractChildWatcher.is_active�s ��"�#�#rc��t��)zdEnter the watcher's context and allow starting new processes This function must return selfr�rs r� __enter__zAbstractChildWatcher.__enter__�s ��"�#�#rc��t��)zExit the watcher's contextr��r+�a�b�cs r�__exit__zAbstractChildWatcher.__exit__�s��!�#�#r)�returnN)r�r�r�r�r�r}r�r�r1rzr�r�rrrrrAs/���,.� $�$�$�$�$�$�$rrc�@�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zy )ra6Child watcher implementation using Linux's pid file descriptors. This child watcher polls process file descriptors (pidfds) to await child process termination. In some respects, PidfdChildWatcher is a "Goldilocks" child watcher implementation. It doesn't require signals or threads, doesn't interfere with any processes launched outside the event loop, and scales linearly with the number of subprocesses launched by the event loop. The main disadvantage is that pidfds are specific to Linux, and only work on recent (5.3+) kernels. c��|Sr rrs rr�zPidfdChildWatcher.__enter__�����rc��yr r)r+�exc_type� exc_value� exc_tracebacks rr�zPidfdChildWatcher.__exit__����rc��yrFrrs rrzzPidfdChildWatcher.is_active�rqrc��yr rrs rr1zPidfdChildWatcher.close�r�rc��yr rr�s rr�zPidfdChildWatcher.attach_loop�r�rc��tj�}tj|�}|j ||j ||||�yr )r�get_running_loopr!� pidfd_openr��_do_wait)r+r�rUrVr�pidfds rr}z#PidfdChildWatcher.add_child_handler�s:���&�&�(��� � �c�"������� � �s�E�8�T�Jrc�$�tj�}|j|� tj|d�\}}t|�}tj|�|||g|���y#t$rd}tjd|�Y�CwxYw)Nr�zJchild process pid %d exit status already read: will report returncode 255) rr�rr!�waitpidr"�ChildProcessErrorrrfr1) r+r�r�rUrVr�_r$r�s rr�zPidfdChildWatcher._do_wait�s����&�&�(�����E�"� 8�� � �3��*�I�A�v�0��7�J� �������j�(�4�(��!� ��J��N�N�.�� � �s�A+�+!B�Bc��yrFrr�s rr�z&PidfdChildWatcher.remove_child_handler����rN)r�r�r�r�r�r�rzr1r�r}r�r�rrrrr�s0�� �� �� � �K� )�&rrc�6�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z y) �BaseChildWatcherc� �d|_i|_yr )r�� _callbacksrs rr)zBaseChildWatcher.__init__�s���� ���rc�&�|jd�yr )r�rs rr1zBaseChildWatcher.close�s������rc�V�|jduxr|jj�Sr )r�� is_runningrs rrzzBaseChildWatcher.is_active�s#���z�z��%�A�$�*�*�*?�*?�*A�Arc��t��r r�)r+�expected_pids r�_do_waitpidzBaseChildWatcher._do_waitpid����!�#�#rc��t��r r�rs r�_do_waitpid_allz BaseChildWatcher._do_waitpid_all�r�rc��|�t|tj�sJ�|j�(|�&|jrtjdt�|j�)|jjtj�||_|�;|jtj|j�|j�yy)NzCA loop is being detached from a child watcher with pending handlers)rfr�AbstractEventLoopr�r�r6r7�RuntimeWarningr5rI�SIGCHLDrZ� _sig_chldr�r�s rr�zBaseChildWatcher.attach_loop�s����|�z�$��0H�0H�I�I�I��:�:�!�d�l�t����M�M�=�� � �:�:�!��J�J�,�,�V�^�^�<��� ����#�#�F�N�N�D�N�N�C� � � �"�rc�� |j�y#ttf$r�t$r(}|jjd|d��Yd}~yd}~wwxYw)N�$Unknown exception in SIGCHLD handler)r@rA)r�r�r�r�r�rCrGs rr�zBaseChildWatcher._sig_chld�sX�� �� � �"���-�.� ��� � �J�J�-�-�A� �/� � �� �s��A�A�AN) r�r�r�r)r1rzr�r�r�r�rrrr�r��s&����B�$�$�#�(rr�c�P��eZdZdZ�fd�Z�fd�Zd�Zd�Zd�Zd�Z d�Z d �Z�xZS) rad'Safe' child watcher implementation. This implementation avoids disrupting other code spawning processes by polling explicitly each process in the SIGCHLD handler instead of calling os.waitpid(-1). This is a safe solution but it has a significant overhead when handling a big number of children (O(n) each time SIGCHLD is raised) c�R��t�|��tjddd��y)Nrr�r�r�)r(r)r6r��r+r-s �rr)zSafeChildWatcher.__init__s'��� �������/�;�%,� .rc�V��|jj�t�|� �yr )r�r9r(r1r�s �rr1zSafeChildWatcher.closes��������� �� �rc��|Sr rrs rr�zSafeChildWatcher.__enter__r�rc��yr rr�s rr�zSafeChildWatcher.__exit__r�rc�H�||f|j|<|j|�yr )r�r�r�s rr}z"SafeChildWatcher.add_child_handler"s%�� (�$�/������ ����rc�>� |j|=y#t$rYywxYw�NTF�r�r`r�s rr�z%SafeChildWatcher.remove_child_handler(�(�� �����$���� �� ��� � �c�Z�t|j�D]}|j|��yr �r4r�r�r�s rr�z SafeChildWatcher._do_waitpid_all/s#������(�C����S�!�)rc��|dkDsJ� tj|tj�\}}|dk(ryt|�}|jj�rt jd||� |jj|�\}}|||g|���y#t$r|}d}t jd|�Y�OwxYw#t$r7|jj�rt jd|d��YyYywxYw)Nr�$process %s exited with returncode %sr��8Unknown child process pid %d, will report returncode 255�'Child watcher got an unexpected pid: %rTr>) r!r��WNOHANGr"r�rrr#r�rfr��popr`)r+r�r�r$r�rUrVs rr�zSafeChildWatcher._do_waitpid4s����a���� 7��*�*�\�2�:�:�>�K�C���a�x��/��7�J��z�z�#�#�%����C�)�:�7� -�!�_�_�0�0��5�N�H�d� �S�*�,�t�,��7!� ��C��J��N�N�J�� � ��(� 3��z�z�#�#�%����H�"�T�3�&� 3�s#�'B�4C�#C�C�;D�D) r�r�r�r�r)r1r�r�r}r�r�r�r�r�s@rrrs0����.��� ���"� -rrc�J��eZdZdZ�fd�Z�fd�Zd�Zd�Zd�Zd�Z d�Z �xZS) raW'Fast' child watcher implementation. This implementation reaps every terminated processes by calling os.waitpid(-1) directly, possibly breaking other code spawning processes and waiting for their termination. There is no noticeable overhead when handling a big number of children (O(1) each time a child terminates). c���t�|��tj�|_i|_d|_tjddd��y)Nrrr�r�r�) r(r)� threading�Lock�_lock�_zombies�_forksr6r�r�s �rr)zFastChildWatcher.__init__asC��� �����^�^�%�� ��� �������/�;�%,� .rc���|jj�|jj�t�|��yr )r�r9r�r(r1r�s �rr1zFastChildWatcher.closeks,���������� � ���� �� �rc�t�|j5|xjdz c_|cddd�S#1swYyxYw)Nr)r�r�rs rr�zFastChildWatcher.__enter__ps$�� �Z�Z��K�K�1��K���Z�Z�s�.�7c�>�|j5|xjdzc_|js|js ddd�yt|j�}|jj �ddd�tjd�y#1swY� xYw)Nrz5Caught subprocesses termination from unknown pids: %s)r�r�r�rOr9rrf)r+r�r�r��collateral_victimss rr�zFastChildWatcher.__exit__vsp�� �Z�Z��K�K�1��K��{�{�$�-�-�� �Z�"%�T�]�]�!3���M�M���!�� ���C�� ��Z�s�/B�/B�Bc� �|jsJd��|j5 |jj|�} ddd�||g|���y#t$r||f|j |<Yddd�ywxYw#1swY�<xYw)NzMust use the context manager)r�r�r�r�r`r�)r+r�rUrVr�s rr}z"FastChildWatcher.add_child_handler�s���{�{�:�:�:�{� �Z�Z� �!�]�]�.�.�s�3� �� ��j�(�4�(�� � �'/��~�����$�� �Z� ���Z�s(�A9�A�A6�+A9�5A6�6A9�9Bc�>� |j|=y#t$rYywxYwr�r�r�s rr�z%FastChildWatcher.remove_child_handler�r�r�c�� tjdtj�\}}|dk(ryt|�}|j 5 |jj|�\}}|jj�rtjd||� ddd��tjd||�n |||g�����#t$rYywxYw#t$r\|jrK||j|<|jj�rtjd||�Yddd���4d}Y��wxYw#1swY��xYw)Nr@rr�z,unknown process %s exited with returncode %sz8Caught subprocess termination from unknown pid: %d -> %d)r!r�r�r"r�r�r�r�r�rrr#r`r�r�rf)r+r�r$r�rUrVs rr�z FastChildWatcher._do_waitpid_all�s8��� <� �j�j��R�Z�Z�8���V� �!�8��3�F�;� ����6�%)�_�_�%8�%8��%=�N�H�d��z�z�+�+�-����%K�%(�*�6�!�&������ #�Z�1���j�0�4�0�K��%� �� �� � $��{�{�-7�� � �c�*��:�:�/�/�1�"�L�L�*>�),�j�:�!��� $�H� $����sN�'C�D=� C�'2D=� C�C�AD:�*D=�5D:�7D=�9D:�:D=�=E)r�r�r�r�r)r1r�r�r}r�r�r�r�s@rrrWs+����.�� � �)��(1rrc�R�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zd �Zd�Z d�Zy )ra~A watcher that doesn't require running loop in the main thread. This implementation registers a SIGCHLD signal handler on instantiation (which may conflict with other code that install own handler for this signal). The solution is safe but it has a significant overhead when handling a big number of processes (*O(n)* each time a SIGCHLD is received). c�P�i|_d|_tjddd��y)Nrr�r�r�)r��_saved_sighandlerr6r�rs rr)zMultiLoopChildWatcher.__init__�s*�����!%������4�;�%,� .rc��|jduSr )r�rs rrzzMultiLoopChildWatcher.is_active�s���%�%�T�1�1rc�Z�|jj�|j�ytjtj �}||jk7rtjd�d|_ytjtj |j�d|_y)Nz+SIGCHLD handler was changed by outside code) r�r9r�rI� getsignalr�r�rrf)r+rds rr1zMultiLoopChildWatcher.close�sz���������!�!�)���"�"�6�>�>�2���d�n�n�$��N�N�H�I�"&��� �M�M�&�.�.�$�*@�*@�A�!%��rc��|Sr rrs rr�zMultiLoopChildWatcher.__enter__�r�rc��yr r�r+r��exc_val�exc_tbs rr�zMultiLoopChildWatcher.__exit__�r�rc�r�tj�}|||f|j|<|j|�yr )rr�r�r�)r+r�rUrVrs rr}z'MultiLoopChildWatcher.add_child_handler�s5���&�&�(�� $�h��5������ ����rc�>� |j|=y#t$rYywxYwr�r�r�s rr�z*MultiLoopChildWatcher.remove_child_handler�r�r�c�8�|j�ytjtj|j�|_|j�*t j d�tj|_tjtjd�y)NzaPrevious SIGCHLD handler was set by non-Python code, restore to default handler on watcher close.F)r�rIr�r�rrfrcrQr�s rr�z!MultiLoopChildWatcher.attach_loopso�� �!�!�-��!'���v�~�~�t�~�~�!N����!�!�)��N�N�J� K�%+�^�^�D�"� ���F�N�N�E�2rc�Z�t|j�D]}|j|��yr r�r�s rr�z%MultiLoopChildWatcher._do_waitpid_alls#������(�C����S�!�)rc�8�|dkDsJ� tj|tj�\}}|dk(ryt|�}d} |jj|�\}}}|j�rtjd||�y|r'|j�rtjd||�|j|||g|���y#t$r|}d}tjd|�d}Y��wxYw#t$rtjd|d� �YywxYw) NrTr�r�F�%Loop %r that handles pid %r is closedr�r�r>)r!r�r�r"r�rrfr�r�� is_closedrr#r�r`) r+r�r�r$r�� debug_logrrUrVs rr�z!MultiLoopChildWatcher._do_waitpids���a���� ��*�*�\�2�:�:�>�K�C���a�x��/��7�J��I� L�#'�?�?�#6�#6�s�#;� �D�(�D��~�~�����F��c�R�����!1��L�L�!G�!-�z�;�)��)�)�(�C��K�d�K��=!� ��C��J��N�N�J�� ��I� ��$� /� �N�N�D��� /� /�s#�'C �C5� %C2�1C2�5!D�Dc�� |j�y#ttf$r�t$rt j dd��YywxYw)Nr�Tr>)r�r�r�r�rrf)r+rrs rr�zMultiLoopChildWatcher._sig_chld<sE�� R�� � �"���-�.� ��� R��N�N�A�D�Q� R�s��/A�AN)r�r�r�r�r)rzr1r�r�r}r�r�r�r�r�rrrrr�sA�� �$.�2� &�� ���3�""�#L�JRrrc�d�eZdZdZd�Zd�Zd�Zd�Zd�Ze jfd�Zd�Zd �Z d �Zd�Zy) raAThreaded child watcher implementation. The watcher uses a thread per process for waiting for the process finish. It doesn't require subscription on POSIX signal but a thread creation is not free. The watcher has O(1) complexity, its performance doesn't depend on amount of spawn processes. c�F�tjd�|_i|_yr�)� itertoolsr��_pid_counter�_threadsrs rr)zThreadedChildWatcher.__init__Rs��%�O�O�A�.����� rc��yrFrrs rrzzThreadedChildWatcher.is_activeVrqrc��yr rrs rr1zThreadedChildWatcher.closeYr�rc��|Sr rrs rr�zThreadedChildWatcher.__enter__\r�rc��yr rr�s rr�zThreadedChildWatcher.__exit___r�rc���t|jj��D�cgc]}|j�r|��}}|r||j�d�t |��yycc}w)Nz0 has registered but not finished child processesr/)r4r�values�is_aliver-r8)r+r9�thread�threadss rr:zThreadedChildWatcher.__del__bse��(,�T�]�]�-A�-A�-C�(D�)�(D�f��o�o�'��(D��)���T�^�^�$�$T�U�!�� ���)s�A!c���tj�}tj|jdt|j���||||fd��}||j|<|j�y)Nzasyncio-waitpid-T)�target�namerV�daemon) rr�r��Threadr��nextrr�start)r+r�rUrVrrs rr}z&ThreadedChildWatcher.add_child_handlerjsf���&�&�(���!�!��)9�)9�)9�$�t�?P�?P�:Q�9R�'S�(,�c�8�T�'B�)-�/��$�� � �c�����rc��yrFrr�s rr�z)ThreadedChildWatcher.remove_child_handlersr�rc��yr rr�s rr�z ThreadedChildWatcher.attach_loopyr�rc��|dkDsJ� tj|d�\}}t|�}|j�rt j d||� |j�rt jd||�n|j|||g|���|jj|�y#t$r|}d}t jd|�Y�~wxYw)Nrr�r�r�r)r!r�r"rrr#r�rfrr�rr�)r+rr�rUrVr�r$r�s rr�z ThreadedChildWatcher._do_waitpid|s����a���� 7��*�*�\�1�5�K�C��0��7�J��~�~�����C�)�:�7��>�>���N�N�B�D�#�N�%�D�%�%�h��Z�G�$�G�� � ���,�'��'!� ��C��J��N�N�J�� � �s�B.�.#C�CN)r�r�r�r�r)rzr1r�r�r6r7r:r}r�r�r�rrrrrEsB�� ��� �� �%�M�M���� �(rrc��ttd�sy tj�}tjtj|d��y#t $rYywxYw)Nr�FrT)�hasattrr!�getpidr1r�rM)r�s r� can_use_pidfdr&�sO���2�|�$����i�i�k�� ������s�A�&�'�������s�=A� A�Ac�B��eZdZdZeZ�fd�Zd�Z�fd�Zd�Z d�Z �xZS)�_UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.c�0��t�|��d|_yr )r(r)�_watcherr�s �rr)z$_UnixDefaultEventLoopPolicy.__init__�s��� ������ rc��tj5|j�)t�rt �|_nt�|_ddd�y#1swYyxYwr )rr�r*r&rrrs r� _init_watcherz)_UnixDefaultEventLoopPolicy._init_watcher�s6�� �\�\��}�}�$� �?�$5�$7�D�M�$8�$:�D�M��\�\�s�6A�Ac����t�|�|�|j�Etj�tj �ur|jj |�yyy)z�Set the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. N)r(�set_event_loopr*r��current_thread�main_threadr�)r+rr-s �rr.z*_UnixDefaultEventLoopPolicy.set_event_loop�sS��� ���t�$��M�M�%��(�(�*�i�.C�.C�.E�E��M�M�%�%�d�+�F� &rc��|j�|j�tjddd��|jS)z~Get the watcher for child processes. If not yet set, a ThreadedChildWatcher object is automatically created. ryr�r�r�)r*r,r6r�rs rryz-_UnixDefaultEventLoopPolicy.get_child_watcher�s@�� �=�=� ���� ����0�:�BI� K��}�}�rc��|�t|t�sJ�|j�|jj�||_t j ddd��y)z$Set the watcher for child processes.N�set_child_watcherr�r�r�)rfrr*r1r6r�)r+r�s rr3z-_UnixDefaultEventLoopPolicy.set_child_watcher�sT����*�W�6J�"K�K�K��=�=�$��M�M���!��� ����0�:�BI� Kr)r�r�r�r�r&� _loop_factoryr)r,r.ryr3r�r�s@rr(r(�s%���D�*�M��;�,��Krr()4r�rSr�r r!rrIr�r�r�r2r�r6�rrrrrr r rrr �logr�__all__rT�ImportErrorrr"�BaseSelectorEventLoopr&� ReadTransportrj�_FlowControlMixin�WriteTransportrr�BaseSubprocessTransportr|rrr�rrrrr&�BaseDefaultEventLoopPolicyr(rrrrr�<module>r?se��8�� �� �� � ��� �����������������<�<�7�� �C� D�D� � �P"�_�B�B�P"�fM�Z�5�5�M�`J�j�:�:�(�7�7�J�Z ��F�F� �0S$�S$�l7�,�7�t2�+�2�jN-�'�N-�bj1�'�j1�Z~R�0�~R�BO(�/�O(�b �6K�&�"C�"C�6K�r+��4�r__pycache__/windows_events.cpython-312.opt-1.pyc000064400000121007151706172560015507 0ustar00� T��hK����dZddlZejdk7red��ddlZddlZddlZddlmZddl Z ddl Z ddlZddlZddl Z ddlZddlmZddlmZdd lmZdd lmZddlmZddlmZdd lmZddlmZddlmZdZej6Zej8ZdZdZdZdZ Gd�dejB�Z"Gd�dejB�Z#Gd�de#�Z$Gd�de#�Z%Gd�de&�Z'Gd�d ejP�Z)Gd!�d"ejT�Z+Gd#�d$�Z,Gd%�d&ejZ�Z.e)Z/Gd'�d(ej`�Z1Gd)�d*ej`�Z2e2Z3y)+z.Selector and proactor event loops for Windows.�N�win32z win32 only)�partial�)�events)�base_subprocess)�futures)� exceptions)�proactor_events)�selector_events)�tasks)� windows_utils)�logger)�SelectorEventLoop�ProactorEventLoop�IocpProactor�DefaultEventLoopPolicy�WindowsSelectorEventLoopPolicy�WindowsProactorEventLoopPolicyi�i�g����MbP?g�������?c�X��eZdZdZdd��fd� Z�fd�Zd�Zd �fd� Z�fd�Z�fd �Z �xZ S)�_OverlappedFuturez�Subclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. N��loopc�f��t�|�|��|jr |jd=||_y�Nr���)�super�__init__�_source_traceback�_ov)�self�ovr� __class__s ��//usr/lib64/python3.12/asyncio/windows_events.pyrz_OverlappedFuture.__init__7s1��� ���d��#��!�!��&�&�r�*����c����t�|��}|j�H|jjrdnd}|j dd|�d|jj d�d��|S)N�pending� completedrzoverlapped=<z, �#x�>)r� _repr_inforr&�insert�address�r �info�stater"s �r#r*z_OverlappedFuture._repr_info=s\����w�!�#���8�8��!%���!1�!1�I�{�E��K�K��\�%���4�8�8�3C�3C�B�2G�q�I�J��r$c��|j�y |jj�d|_y#t$rM}d||d�}|jr|j|d<|jj|�Yd}~d|_yd}~wwxYw)Nz&Cancelling an overlapped future failed��message� exception�future�source_traceback)r�cancel�OSErrorr�_loop�call_exception_handler)r �exc�contexts r#�_cancel_overlappedz$_OverlappedFuture._cancel_overlappedDs����8�8��� 7��H�H�O�O������� 7�C� ���G� �%�%�.2�.D�.D��*�+��J�J�-�-�g�6�6����� 7�s�1� B�<B�Bc�D��|j�t�|� |��S�N)�msg)r<rr6�r r?r"s �r#r6z_OverlappedFuture.cancelTs ������!��w�~�#�~�&�&r$c�D��t�|�|�|j�y�N)r� set_exceptionr<�r r3r"s �r#rCz_OverlappedFuture.set_exceptionXs��� ���i�(����!r$c�2��t�|�|�d|_yrB)r� set_resultr�r �resultr"s �r#rFz_OverlappedFuture.set_result\s��� ���6�"���r$rB)�__name__� __module__�__qualname__�__doc__rr*r<r6rCrF� __classcell__�r"s@r#rr1s0���� $(���� '�"��r$rc�d��eZdZdZdd��fd� Zd�Z�fd�Zd�Zd�Zd�fd � Z �fd �Z �fd�Z�xZS) �_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.Nrc���t�|�|��|jr |jd=||_||_||_d|_y)NrrT)rrrr�_handle�_wait_handle�_registered)r r!�handle�wait_handlerr"s �r#rz_BaseWaitHandleFuture.__init__dsL��� ���d��#��!�!��&�&�r�*�������'��� ��r$c�d�tj|jd�tjk(S�Nr)�_winapi�WaitForSingleObjectrR� WAIT_OBJECT_0�r s r#�_pollz_BaseWaitHandleFuture._pollrs)���+�+�D�L�L�!�<��%�%�&� 'r$c���t�|��}|jd|jd���|j�%|j �rdnd}|j|�|j �|jd|j d���|S)Nzhandle=r(�signaled�waitingzwait_handle=)rr*�appendrRr]rSr-s �r#r*z _BaseWaitHandleFuture._repr_infows|����w�!�#�����g�d�l�l�2�.�/�0��<�<�#�"&�*�*�,�J�I�E��K�K������(��K�K�,�t�'8�'8��&<�=�>��r$c��d|_yrB)r)r �futs r#�_unregister_wait_cbz)_BaseWaitHandleFuture._unregister_wait_cb�s����r$c��|jsyd|_|j}d|_ tj|�|jd�y#t$rh}|j tjk7rAd||d�}|jr|j|d<|jj|�Yd}~yYd}~�~d}~wwxYw�NFz$Failed to unregister the wait handler1r5)rTrS�_overlapped�UnregisterWaitr7�winerror�ERROR_IO_PENDINGrr8r9rd�r rVr:r;s r#�_unregister_waitz&_BaseWaitHandleFuture._unregister_wait�s������� ����'�'�� ��� ��&�&�{�3� � � ��&��� ��|�|�{�;�;�;�E�!$�"��� �)�)�26�2H�2H�G�.�/�� � �1�1�'�:��<�� �s�A� C�AB<�<Cc�D��|j�t�|� |��Sr>)rlrr6r@s �r#r6z_BaseWaitHandleFuture.cancel�s ��������w�~�#�~�&�&r$c�D��|j�t�|� |�yrB)rlrrCrDs �r#rCz#_BaseWaitHandleFuture.set_exception�s������� ���i�(r$c�D��|j�t�|� |�yrB)rlrrFrGs �r#rFz _BaseWaitHandleFuture.set_result�s������� ���6�"r$rB) rIrJrKrLrr]r*rdrlr6rCrFrMrNs@r#rPrPas6���<�8<� �'� �� '�0'�)�#�#r$rPc�B��eZdZdZdd��fd� Zd�Z�fd�Z�fd�Z�xZS)�_WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. Nrc�:��t�|�||||��d|_y)Nr)rr�_done_callback)r r!�eventrVrr"s �r#rz_WaitCancelFuture.__init__�s!��� ����U�K�d��;�"��r$c��td��)Nz'_WaitCancelFuture must not be cancelled)�RuntimeErrorr\s r#r6z_WaitCancelFuture.cancel�s���D�E�Er$c�`��t�|�|�|j�|j|�yyrB)rrFrsrGs �r#rFz_WaitCancelFuture.set_result�s/��� ���6�"����*�����%�+r$c�`��t�|�|�|j�|j|�yyrB)rrCrsrDs �r#rCz_WaitCancelFuture.set_exception�s/��� ���i�(����*�����%�+r$) rIrJrKrLrr6rFrCrMrNs@r#rqrq�s'����8<�#� F�&� &�&r$rqc�4��eZdZdd��fd� Z�fd�Zd�Z�xZS)�_WaitHandleFutureNrc���t�|�||||��||_d|_t j dddd�|_d|_y)NrTF)rr� _proactor�_unregister_proactorrg�CreateEvent�_event� _event_fut)r r!rUrV�proactorrr"s �r#rz_WaitHandleFuture.__init__�sG��� ����V�[�t��<�!���$(��!�!�-�-�d�D�%��F�����r$c����|j�-tj|j�d|_d|_|jj|j�d|_t�|�!|�yrB) rrY�CloseHandler�r|�_unregisterrrrd)r rcr"s �r#rdz%_WaitHandleFuture._unregister_wait_cb�sY����;�;�"�������,��D�K�"�D�O� ���"�"�4�8�8�,���� ��#�C�(r$c���|jsyd|_|j}d|_ tj||j�|jj|j|j�|_y#t $rh}|jtjk7rAd||d�}|jr|j|d<|jj|�Yd}~yYd}~��d}~wwxYwrf)rTrSrg�UnregisterWaitExrr7rirjrr8r9r|�_wait_cancelrdr�rks r#rlz"_WaitHandleFuture._unregister_wait�s������� ����'�'�� ��� ��(�(��d�k�k�B��.�.�5�5�d�k�k�6:�6N�6N�P����� ��|�|�{�;�;�;�E�!$�"��� �)�)�26�2H�2H�G�.�/�� � �1�1�'�:��<�� �s� A?�? C0�AC+�+C0)rIrJrKrrdrlrMrNs@r#rzrz�s���BF��)�$Pr$rzc�2�eZdZdZd�Zd�Zd�Zd�Zd�ZeZ y)� PipeServerzXClass representing a pipe server. This is much like a bound, listening socket. c��||_tj�|_d|_d|_|j d�|_y�NT)�_address�weakref�WeakSet�_free_instances�_pipe�_accept_pipe_future�_server_pipe_handle)r r,s r#rzPipeServer.__init__�s;���� �&���0����� �#'�� ��-�-�d�3�� r$c�L�|j|jd�c}|_|S)NF)r�r�)r �tmps r#�_get_unconnected_pipez PipeServer._get_unconnected_pipes%�� �*�*�d�&>�&>�u�&E���T�Z�� r$c �,�|j�rytjtjz}|r|tjz}tj |j|tjtjztjztjtjtjtjtj�}tj|�}|j j#|�|SrB)�closedrY�PIPE_ACCESS_DUPLEX�FILE_FLAG_OVERLAPPED�FILE_FLAG_FIRST_PIPE_INSTANCE�CreateNamedPiper��PIPE_TYPE_MESSAGE�PIPE_READMODE_MESSAGE� PIPE_WAIT�PIPE_UNLIMITED_INSTANCESr �BUFSIZE�NMPWAIT_WAIT_FOREVER�NULL� PipeHandler��add)r �first�flags�h�pipes r#r�zPipeServer._server_pipe_handles����;�;�=���*�*�W�-I�-I�I����W�:�:�:�E��#�#��M�M�5��%�%��(E�(E�E���� ��,�,��!�!�=�#8�#8��(�(�'�,�,� 8���'�'��*����� � ��&��r$c��|jduSrB)r�r\s r#r�zPipeServer.closed s��� � ��%�&r$c� �|j�!|jj�d|_|j�J|jD]}|j ��d|_d|_|jj �yyrB)r�r6r�r��closer��clear)r r�s r#r�zPipeServer.close#sp���#�#�/��$�$�+�+�-�'+�D�$��=�=�$��,�,��� � ��-��D�J� �D�M�� � �&�&�(�%r$N) rIrJrKrLrr�r�r�r��__del__�r$r#r�r��s'���4���$'� )��Gr$r�c��eZdZdZy)�_WindowsSelectorEventLoopz'Windows version of selector event loop.N)rIrJrKrLr�r$r#r�r�2s��1r$r�c�D��eZdZdZd�fd� Z�fd�Zd�Zd�Z dd�Z�xZ S)rz2Windows version of proactor event loop using IOCP.c�<��|� t�}t�|� |�yrB)rrr)r r�r"s �r#rzProactorEventLoop.__init__9s�����#�~�H� ����"r$c��� |j|j�t�|� �|j�a|jj }|jj �|�'|js|jj|�d|_yy#|j�a|jj }|jj �|�'|js|jj|�d|_wwxYwrB) � call_soon�_loop_self_readingr�run_forever�_self_reading_futurerr6r&r|r�)r r!r"s �r#r�zProactorEventLoop.run_forever>s���� 1��N�N�4�2�2�3��G��!��(�(�4��.�.�2�2���)�)�0�0�2��>�"�*�*��N�N�.�.�r�2�,0��)�5��t�(�(�4��.�.�2�2���)�)�0�0�2��>�"�*�*��N�N�.�.�r�2�,0��)�5�s�)B�A/D c��K�|jj|�}|�d{���}|�}|j||d|i��}||fS7�%�w)N�addr��extra)r|�connect_pipe�_make_duplex_pipe_transport)r �protocol_factoryr,�fr��protocol�transs r#�create_pipe_connectionz(ProactorEventLoop.create_pipe_connectionQsZ�����N�N�'�'��0���w��#�%���0�0��x�8>��7H�1�J���h��� �s�!A�A �&Ac��f�����K�t���d�����fd� ��j���gS�w)Nc�J��d} |ri|j�}�jj|��j�r|j �y��}�j||d�i���j �}|�y�jj|�}|�_ |j��y#t$r9|r#|j�dk7r|j ��j��Yyt$rz}|r9|j�dk7r&�jd||d��|j �n$�j rt#j$d|d���j��Yd}~yd}~wt&j($r|r|j �YyYywxYw) Nr�r�rzPipe accept failed)r2r3r�zAccept pipe failed on pipe %rT)�exc_info)rHr��discardr�r�r�r�r|�accept_piper��add_done_callback�BrokenPipeError�filenor�r7r9�_debugr�warningr �CancelledError) r�r�r�r:r,�loop_accept_piper�r �servers �����r#r�z>ProactorEventLoop.start_serving_pipe.<locals>.loop_accept_pipe\st����D�) 6���8�8�:�D��*�*�2�2�4�8��}�}��� � ���/�1�H��4�4��h�v�w�.?�5�A��3�3�5���<���N�N�.�.�t�4��*./��*��#�#�$4�5��+#� 1��D�K�K�M�R�/��J�J�L����/�0�� 1��D�K�K�M�R�/��/�/�#7�%(� $�1�� �J�J�L��[�[��N�N�#B�#'�$�8����/�0�0���,�,� !���J�J�L�� !�s1�A B7�/B7�B7�7?F"�8F"�A0E5�5(F"�!F"rB)r�r�)r r�r,r�r�s```@@r#�start_serving_pipez$ProactorEventLoop.start_serving_pipeYs2������G�$��+ 6�+ 6�Z ���'�(��x��s�*1c ��K�|j�} t||||||||f| |d�| ��} | �d{���|S7�#ttf$r�t$r+|j�|j ��d{���7�wxYw�w)N)�waiterr�)� create_future�_WindowsSubprocessTransport� SystemExit�KeyboardInterrupt� BaseExceptionr��_wait)r r��args�shell�stdin�stdout�stderr�bufsizer��kwargsr��transps r#�_make_subprocess_transportz,ProactorEventLoop._make_subprocess_transport�s������#�#�%��,�T�8�T�5�-2�F�F�G�7�4:�%�7�06�7�� ��L�L�� � ���-�.� ��� ��L�L�N��,�,�.� � �� �s1�'A>�8�6�8�A>�8�;A;�3A6�4A;�;A>rB) rIrJrKrLrr�r�r�r�rMrNs@r#rr6s%���<�#� 1�&�1�j04�r$rc���eZdZdZefd�Zd�Zd�Zd�Zd!d�Z d�Z ed ��Ze d ��Zd"d�Zd"d�Zd"d �Zd"d�Zd#d�Zd"d�Zd�Zd�Zd�Zd�Zd�Zd!d�Zd�Zd�Zd�Zd�Zd�Zd�Z d!d�Z!d�Z"d�Z#d �Z$y)$rz#Proactor implementation using IOCP.c��d|_g|_tjtjt d|�|_i|_tj�|_ g|_tj�|_yrX) r8�_resultsrg�CreateIoCompletionPort�INVALID_HANDLE_VALUEr��_iocp�_cacher�r�rT� _unregistered�_stopped_serving)r �concurrencys r#rzIocpProactor.__init__�s_���� ��� � �7�7��,�,�d�A�{�D�� ����"�?�?�,������ '��� 1��r$c�2�|j�td��y)NzIocpProactor is closed)r�rvr\s r#� _check_closedzIocpProactor._check_closed�s���:�:���7�8�8�r$c���dt|j�zdt|j�zg}|j�|j d�d|j j�ddj|��d�S)Nzoverlapped#=%sz result#=%sr��<� r))�lenr�r�r�rar"rI�join)r r.s r#�__repr__zIocpProactor.__repr__�s_�� �3�t�{�{�#3�3��s�4�=�=�1�1�3���:�:���K�K��!�� �N�N�3�3�S�X�X�d�^�D�Dr$c��||_yrB)r8)r rs r#�set_loopzIocpProactor.set_loop�s ���� r$Nc�z�|js|j|�|j}g|_ |d}S#d}wxYwrB)r�r])r �timeoutr�s r#�selectzIocpProactor.select�s:���}�}��J�J�w���m�m���� � ���C��$�C�s�6�:c�\�|jj�}|j|�|SrB)r8r�rF)r �valuercs r#�_resultzIocpProactor._result�s%���j�j�&�&�(�����u��� r$c��� |j�S#t$rD}|jtjtj fvrt |j���d}~wwxYwrB)� getresultr7rirg�ERROR_NETNAME_DELETED�ERROR_OPERATION_ABORTED�ConnectionResetErrorr�)r��keyr!r:s r#�finish_socket_funczIocpProactor.finish_socket_func�sY�� ��<�<�>�!��� ��|�|�� A� A� +� C� C� E�E�*�C�H�H�5�5��� �s�� A�?A�Ac�� |j|||�S#t$r,}|jtjk(r |dfcYd}~S�d}~wwxYwrB)rr7rirg�ERROR_PORT_UNREACHABLE)�clsr�rr!�empty_resultr:s r#�_finish_recvfromzIocpProactor._finish_recvfrom�sN�� ��)�)�%��b�9�9��� ��|�|�{�A�A�A�#�T�)�)��� �s�� A � A�A �A�A c��|j|�tjt�} t |t j �r"|j |j�||�n |j|j�|�|j|||j�S#t$r|jd�cYSwxYw)Nr$) �_register_with_iocprg� Overlappedr�� isinstance�socket�WSARecvr��ReadFiler�r�� _registerr�r �conn�nbytesr�r!s r#�recvzIocpProactor.recv�s���� � ��&� � #� #�D� )�� %��$�� � �.�� � �4�;�;�=�&�%�8����D�K�K�M�6�2��~�~�b�$��(?�(?�@�@��� %��<�<��$�$� %���AB%�%C�Cc��|j|�tjt�} t |t j �r"|j |j�||�n |j|j�|�|j|||j�S#t$r|jd�cYSwxYwrX) r rgr r�rr�WSARecvIntor��ReadFileIntor�r�rr�r r�bufr�r!s r#� recv_intozIocpProactor.recv_into�s���� � ��&� � #� #�D� )�� #��$�� � �.����t�{�{�}�c�5�9������� �s�3��~�~�b�$��(?�(?�@�@��� #��<�<��?�"� #�rc�*�|j|�tjt�} |j |j�||�|j||t|jd���S#t$r|jd�cYSwxYw)N)r$Nr$�r)r rgr r��WSARecvFromr�r�r�rrrrs r#�recvfromzIocpProactor.recvfrom�s���� � ��&� � #� #�D� )�� -��N�N�4�;�;�=�&�%�8��~�~�b�$���0E�0E�=@�)B�C� C��� -��<�<��,�,� -���!A5�5B�Bc�*�|j|�tjt�} |j |j�||�|j||t|jd���S#t$r|jd�cYSwxYw)N�rNrr)r rgr r��WSARecvFromIntor�r�r�rrrrs r#� recvfrom_intozIocpProactor.recvfrom_intos���� � ��&� � #� #�D� )�� +����t�{�{�}�c�5�9��~�~�b�$���0E�0E�=>�)@�A� A��� +��<�<� �*�*� +�rc���|j|�tjt�}|j |j�|||�|j |||j�SrB)r rgr r�� WSASendTor�rr)r rrr�r�r!s r#�sendtozIocpProactor.sendtosQ��� � ��&� � #� #�D� )�� ���T�[�[�]�C���5��~�~�b�$��(?�(?�@�@r$c�H�|j|�tjt�}t |t j �r"|j |j�||�n |j|j�|�|j|||j�SrB)r rgr r�rr�WSASendr�� WriteFilerrrs r#�sendzIocpProactor.sendsq��� � ��&� � #� #�D� )���d�F�M�M�*��J�J�t�{�{�}�c�5�1��L�L������,��~�~�b�$��(?�(?�@�@r$c�|���|j��|j�j��tjt �}|j �j��j����fd�}d�}|j|�|�}||��}tj||j��|S)Nc�,��|j�tjd�j��}�j t jtj|��j�j����j�fS)Nz@P)r��struct�packr�� setsockoptr� SOL_SOCKETrg�SO_UPDATE_ACCEPT_CONTEXT� settimeout� gettimeout�getpeername)r�rr!rr�listeners ��r#� finish_acceptz*IocpProactor.accept.<locals>.finish_accept*sl����L�L�N��+�+�d�H�O�O�$5�6�C��O�O�F�-�-�'�@�@�#� G��O�O�H�/�/�1�2���)�)�+�+�+r$c��vK� |�d{���y7�#tj$r|j��wxYw�wrB)r r�r�)r4rs r#�accept_coroz(IocpProactor.accept.<locals>.accept_coro3s2���� ������,�,� �� � ��� �s �9����9��%6�9r)r �_get_accept_socket�familyrgr r��AcceptExr�rr� ensure_futurer8)r r5r!r6r8r4�corors ` @r#�acceptzIocpProactor.accept$s����� � ��*��&�&�x���7�� � #� #�D� )�� ���H�O�O�%�t�{�{�}�5� ,� �����H�m�<���6�4�(�� ���D�t�z�z�2�� r$c����jtjk(rQtj�j�|�|jj�}|jd�|S|j�� tj�j��j�tj"t$�}|j'�j�|��fd�}|j)|�|�S#t$r?}|jtjk7r��j!�ddk(r�Yd}~��d}~wwxYw)Nrrc���|j��jtjtj d��SrX)r�r/rr0rg�SO_UPDATE_CONNECT_CONTEXT)r�rr!rs �r#�finish_connectz,IocpProactor.connect.<locals>.finish_connectVs1����L�L�N��O�O�F�-�-�'�A�A�1� F��Kr$)�typer� SOCK_DGRAMrg� WSAConnectr�r8r�rFr � BindLocalr:r7ri�errno� WSAEINVAL�getsocknamer r�� ConnectExr)r rr,rc�er!rBs ` r#�connectzIocpProactor.connect@s����9�9��)�)�)� �"�"�4�;�;�=�'�:��*�*�*�*�,�C��N�N�4� ��J�� � ��&� ��!�!�$�+�+�-����=�� #� #�D� )�� ���T�[�[�]�G�,� ��~�~�b�$��7�7��!� ��z�z�U�_�_�,�����!�!�$��)��*�� �s�.D� E � 5E�E c �6�|j|�tjt�}|dz}|dz dz}|j |j�t j|j��|||dd�|j|||j�S)Nl��� r) r rgr r��TransmitFiler��msvcrt� get_osfhandlerr)r �sock�file�offset�countr!� offset_low�offset_highs r#�sendfilezIocpProactor.sendfile_s���� � ��&� � #� #�D� )���k�)� ���|�{�2�� ������ ��,�,�T�[�[�]�;�"�K��q�!� %� �~�~�b�$��(?�(?�@�@r$c����|j��tjt�}|j �j��}|r|j ��S�fd�}|j|�|�S)Nc�(��|j��SrB)r�)r�rr!r�s �r#�finish_accept_pipez4IocpProactor.accept_pipe.<locals>.finish_accept_pipevs����L�L�N��Kr$)r rgr r��ConnectNamedPiper�r�r)r r�r!� connectedr[s ` r#r�zIocpProactor.accept_pipeksf���� � ��&� � #� #�D� )���'�'���� �6� ���<�<��%�%� ��~�~�b�$�(:�;�;r$c��<K�t} tj|�} tj|�S#t$r(}|jtj k7r�Yd}~nd}~wwxYwt |dzt�}tj|��d{���7���w)N�)�CONNECT_PIPE_INIT_DELAYrg�ConnectPiper7ri�ERROR_PIPE_BUSY�min�CONNECT_PIPE_MAX_DELAYr�sleepr r�)r r,�delayrUr:s r#r�zIocpProactor.connect_pipe|s�����'��� �$�0�0��9����'�'��/�/��� ��<�<�;�#>�#>�>��?�� �� ��� �#9�:�E��+�+�e�$�$�$��s6�B�6�B� A'�A"�B�"A'�'.B�B�Bc�(�|j||d�S)z�Wait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). F)�_wait_for_handle)r rUr�s r#�wait_for_handlezIocpProactor.wait_for_handle�s���$�$�V�W�e�<�<r$c�:�|j|dd�}||_|Sr�)rhrs)r rt� done_callbackrcs r#r�zIocpProactor._wait_cancel�s%���#�#�E�4��6��+���� r$c����|j�|�tj}ntj|dz�}tjt�}tj||j|j|�}|rt||||j���nt|||||j����jr �jd=�fd�}�|d|f|j|j<�S)N�@�@rrc�$���j�SrB)r])r�rr!r�s �r#�finish_wait_for_handlez=IocpProactor._wait_for_handle.<locals>.finish_wait_for_handle�s����7�7�9�r$r)r�rY�INFINITE�math�ceilrgr r��RegisterWaitWithQueuer�r,rqr8rzrr�) r rUr�� _is_cancel�msr!rVror�s @r#rhzIocpProactor._wait_for_handle�s���������?��!�!�B����7�S�=�)�B�� #� #�D� )��!�7�7��D�J�J�� � �B�0���!�"�f�k�� � �K�A�!�"�f�k�4�'+�z�z�3�A�����#�#�B�'� �$%�b�!�-C�"D����B�J�J���r$c��||jvrL|jj|�tj|j �|j dd�yyrX)rTr�rgr�r�r��r �objs r#r z IocpProactor._register_with_iocp�sI���d�&�&�&���� � ��%��.�.�s�z�z�|�T�Z�Z��A�N�'r$c�^�|j�t||j��}|jr |jd=|js |dd|�}|j|�||||f|j|j<|S#t$r}|j|�Yd}~�>d}~wwxYwr) r�rr8rr&rFr7rCr�r,)r r!rx�callbackr�r�rKs r#rzIocpProactor._register�s������� �b�t�z�z�2������#�#�B�'��z�z� $� ��t�R�0�����U�#�$%�b�#�x�"8����B�J�J������ #�����"�"�� #�s� B� B,�B'�'B,c�Z�|j�|jj|�y)a Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). N)r�r�ra)r r!s r#r�zIocpProactor._unregister�s$�� �������!�!�"�%r$c�R�tj|�}|jd�|SrX)rr2)r r:�ss r#r9zIocpProactor._get_accept_socket�s ���M�M�&�!�� ���Q���r$c �"�|�t}n<|dkrtd��tj|dz�}|tk\rtd�� t j |j|�}|�n�d}|\}}}} |jj|�\}} } }| |j vr|j#�nI|j%�s9 |||| �}|j'|�|j(j+|�d}��|j0D](} |jj| j2d��*|j0j5�y#t$rl|jj�r%|jjdd||||fzd��|dtjfvrtj|�Y��}wxYw#t,$r7} |j/| �|j(j+|�Yd} ~ ��d} ~ wwxYw#d}wxYw)Nrznegative timeoutrmztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r2�status)rp� ValueErrorrqrrrg�GetQueuedCompletionStatusr�r��pop�KeyErrorr8� get_debugr9r�rYr�r�r6�donerFr�rar7rCr�r,r�)r r�rur�err�transferredrr,r�r!rxrzr�rKs r#r]zIocpProactor._poll�s����?��B� �q�[��/�0�0����7�S�=�)�B��X�~� �!2�3�3�� �:�:�4�:�:�r�J�F��~���B�-3�*�C��c�7� �'+�{�{���w�'?�$��2�s�H� �d�+�+�+���� ��V�V�X� �$�[�#�r�:�E� �L�L��'��M�M�(�(��+��A�M�R�$�$�B��K�K�O�O�B�J�J��-�%���� � �"��E� ��:�:�'�'�)��J�J�5�5�%7�#N�&)�;��W�%E�$F�7���q�+�"B�"B�C�C��'�'��,�� ��,�,��O�O�A�&��M�M�(�(��+�+��,���A�sC�4 E� G�,H �A1G�G� H�,H�<H �H�H � Hc�:�|jj|�yrB)r�r�rws r#� _stop_servingzIocpProactor._stop_serving2s�� ���!�!�#�&r$c�4�|j�yt|jj��D]:\}}}}|j �r�t|t�r�* |j��<d}tj�}||z} |jrx| tj�krCtjd|tj�|z �tj�|z} |j!|�|jr�xg|_t%j&|j�d|_y#t$rS}|j�<d||d�}|jr|j|d<|jj|�Yd}~��ad}~wwxYw)NzCancelling a future failedr1r5g�?z,%r is running after closing for %.1f seconds)r��listr��values� cancelledrrqr6r7r8rr9�time� monotonicr�debugr]r�rYr�) r rcr!rxrzr:r;� msg_update� start_time�next_msgs r#r�zIocpProactor.close8s[���:�:���'+�4�;�;�+=�+=�+?�&@�"�C��S�(��}�}����C�!2�3��C��J�J�L�'A�0� ��^�^�%� �� �*���k�k��4�>�>�+�+����K�!�4�>�>�#3�j�#@�B��>�>�+�j�8�� �J�J�z�"��k�k��� ����D�J�J�'��� ��;� C��z�z�-�'C�),�&)�#�� �0�0�:=�:O�:O�G�$6�7�� � �9�9�'�B��� C�s�D;�; F�AF�Fc�$�|j�yrB)r�r\s r#r�zIocpProactor.__del__gs��� � �r$rB)rr!)%rIrJrKrLrprr�r�r�r�r��staticmethodr�classmethodrrrrr#r&r*r>rLrXr�r�rir�rhr rr�r9r]r�r�r�r�r$r#rr�s���-�#+�2�9�E�� �� ����� �� �A�A� C� A�A�A��88�> A�<�"0�&=�� �DO��@&�� 7#�r'�-�^r$rc��eZdZd�Zy)r�c ���tj|f|||||d�|���_�fd�}�jjjt �jj��} | j|�y)N)r�r�r�r�r�c�\���jj�}�j|�yrB)�_proc�poll�_process_exited)r�� returncoder s �r#rzz4_WindowsSubprocessTransport._start.<locals>.callbackrs!��������*�J�� � ��,r$) r �Popenr�r8r|ri�intrRr�) r r�r�r�r�r�r�r�rzr�s ` r#�_startz"_WindowsSubprocessTransport._startmso���"�(�(��'��U�6�&��'�%�'�� � -� �J�J� � �0�0��T�Z�Z�5G�5G�1H�I�� ���H�%r$N)rIrJrKr�r�r$r#r�r�ks�� &r$r�c��eZdZeZy)rN)rIrJrKr� _loop_factoryr�r$r#rr}���%�Mr$rc��eZdZeZy)rN)rIrJrKrr�r�r$r#rr�r�r$r)4rL�sys�platform�ImportErrorrgrYrG� functoolsrrqrPrr-r�r��rrrr r rrr �logr�__all__r�rp�ERROR_CONNECTION_REFUSED�ERROR_CONNECTION_ABORTEDr`rd�FuturerrPrqrz�objectr��BaseSelectorEventLoopr��BaseProactorEventLooprr�BaseSubprocessTransportr�r�BaseDefaultEventLoopPolicyrrrr�r$r#�<module>r�s\��4� ��<�<�7�� �l� #�#������ � � ���������������|�|���������� ����-����-�`G#�G�N�N�G#�T&�-�&�01P�-�1P�h8��8�v2�� E� E�2�g��=�=�g�TH�H�V&�/�"I�"I�&�.��&�V�%F�%F�&�&�V�%F�%F�&�8�r$__pycache__/windows_events.cpython-312.opt-2.pyc000064400000116736151706172560015525 0ustar00� T��hK���� ddlZejdk7red��ddlZddlZddlZddlmZddlZddl Z ddl Z ddlZddlZddl Z ddlmZddlmZddlmZdd lmZdd lmZddlmZddlmZdd lmZddlmZdZej4Zej6ZdZdZdZdZGd�dej@�Z!Gd�dej@�Z"Gd�de"�Z#Gd�de"�Z$Gd�de%�Z&Gd�dejN�Z(Gd �d!ejR�Z*Gd"�d#�Z+Gd$�d%ejX�Z-e(Z.Gd&�d'ej^�Z0Gd(�d)ej^�Z1e1Z2y)*�N�win32z win32 only)�partial�)�events)�base_subprocess)�futures)� exceptions)�proactor_events)�selector_events)�tasks)� windows_utils)�logger)�SelectorEventLoop�ProactorEventLoop�IocpProactor�DefaultEventLoopPolicy�WindowsSelectorEventLoopPolicy�WindowsProactorEventLoopPolicyi�i�g����MbP?g�������?c�V��eZdZ dd��fd� Z�fd�Zd�Zd �fd� Z�fd�Z�fd�Z�xZ S) �_OverlappedFutureN��loopc�f��t�|�|��|jr |jd=||_y�Nr���)�super�__init__�_source_traceback�_ov)�self�ovr� __class__s ��//usr/lib64/python3.12/asyncio/windows_events.pyrz_OverlappedFuture.__init__7s1��� ���d��#��!�!��&�&�r�*����c����t�|��}|j�H|jjrdnd}|j dd|�d|jj d�d��|S)N�pending� completedrzoverlapped=<z, �#x�>)r� _repr_inforr&�insert�address�r �info�stater"s �r#r*z_OverlappedFuture._repr_info=s\����w�!�#���8�8��!%���!1�!1�I�{�E��K�K��\�%���4�8�8�3C�3C�B�2G�q�I�J��r$c��|j�y |jj�d|_y#t$rM}d||d�}|jr|j|d<|jj|�Yd}~d|_yd}~wwxYw)Nz&Cancelling an overlapped future failed��message� exception�future�source_traceback)r�cancel�OSErrorr�_loop�call_exception_handler)r �exc�contexts r#�_cancel_overlappedz$_OverlappedFuture._cancel_overlappedDs����8�8��� 7��H�H�O�O������� 7�C� ���G� �%�%�.2�.D�.D��*�+��J�J�-�-�g�6�6����� 7�s�1� B�<B�Bc�D��|j�t�|� |��S�N)�msg)r<rr6�r r?r"s �r#r6z_OverlappedFuture.cancelTs ������!��w�~�#�~�&�&r$c�D��t�|�|�|j�y�N)r� set_exceptionr<�r r3r"s �r#rCz_OverlappedFuture.set_exceptionXs��� ���i�(����!r$c�2��t�|�|�d|_yrB)r� set_resultr�r �resultr"s �r#rFz_OverlappedFuture.set_result\s��� ���6�"���r$rB) �__name__� __module__�__qualname__rr*r<r6rCrF� __classcell__�r"s@r#rr1s0���� $(���� '�"��r$rc�b��eZdZ dd��fd� Zd�Z�fd�Zd�Zd�Zd�fd� Z�fd �Z �fd �Z �xZS)�_BaseWaitHandleFutureNrc���t�|�|��|jr |jd=||_||_||_d|_y)NrrT)rrrr�_handle�_wait_handle�_registered)r r!�handle�wait_handlerr"s �r#rz_BaseWaitHandleFuture.__init__dsL��� ���d��#��!�!��&�&�r�*�������'��� ��r$c�d�tj|jd�tjk(S�Nr)�_winapi�WaitForSingleObjectrQ� WAIT_OBJECT_0�r s r#�_pollz_BaseWaitHandleFuture._pollrs)���+�+�D�L�L�!�<��%�%�&� 'r$c���t�|��}|jd|jd���|j�%|j �rdnd}|j|�|j �|jd|j d���|S)Nzhandle=r(�signaled�waitingzwait_handle=)rr*�appendrQr\rRr-s �r#r*z _BaseWaitHandleFuture._repr_infows|����w�!�#�����g�d�l�l�2�.�/�0��<�<�#�"&�*�*�,�J�I�E��K�K������(��K�K�,�t�'8�'8��&<�=�>��r$c��d|_yrB)r)r �futs r#�_unregister_wait_cbz)_BaseWaitHandleFuture._unregister_wait_cb�s����r$c��|jsyd|_|j}d|_ tj|�|jd�y#t$rh}|j tjk7rAd||d�}|jr|j|d<|jj|�Yd}~yYd}~�~d}~wwxYw�NFz$Failed to unregister the wait handler1r5)rSrR�_overlapped�UnregisterWaitr7�winerror�ERROR_IO_PENDINGrr8r9rc�r rUr:r;s r#�_unregister_waitz&_BaseWaitHandleFuture._unregister_wait�s������� ����'�'�� ��� ��&�&�{�3� � � ��&��� ��|�|�{�;�;�;�E�!$�"��� �)�)�26�2H�2H�G�.�/�� � �1�1�'�:��<�� �s�A� C�AB<�<Cc�D��|j�t�|� |��Sr>)rkrr6r@s �r#r6z_BaseWaitHandleFuture.cancel�s ��������w�~�#�~�&�&r$c�D��|j�t�|� |�yrB)rkrrCrDs �r#rCz#_BaseWaitHandleFuture.set_exception�s������� ���i�(r$c�D��|j�t�|� |�yrB)rkrrFrGs �r#rFz _BaseWaitHandleFuture.set_result�s������� ���6�"r$rB)rIrJrKrr\r*rcrkr6rCrFrLrMs@r#rOrOas6���<�8<� �'� �� '�0'�)�#�#r$rOc�@��eZdZ dd��fd� Zd�Z�fd�Z�fd�Z�xZS)�_WaitCancelFutureNrc�:��t�|�||||��d|_y)Nr)rr�_done_callback)r r!�eventrUrr"s �r#rz_WaitCancelFuture.__init__�s!��� ����U�K�d��;�"��r$c��td��)Nz'_WaitCancelFuture must not be cancelled)�RuntimeErrorr[s r#r6z_WaitCancelFuture.cancel�s���D�E�Er$c�`��t�|�|�|j�|j|�yyrB)rrFrrrGs �r#rFz_WaitCancelFuture.set_result�s/��� ���6�"����*�����%�+r$c�`��t�|�|�|j�|j|�yyrB)rrCrrrDs �r#rCz_WaitCancelFuture.set_exception�s/��� ���i�(����*�����%�+r$)rIrJrKrr6rFrCrLrMs@r#rprp�s'����8<�#� F�&� &�&r$rpc�4��eZdZdd��fd� Z�fd�Zd�Z�xZS)�_WaitHandleFutureNrc���t�|�||||��||_d|_t j dddd�|_d|_y)NrTF)rr� _proactor�_unregister_proactorrf�CreateEvent�_event� _event_fut)r r!rTrU�proactorrr"s �r#rz_WaitHandleFuture.__init__�sG��� ����V�[�t��<�!���$(��!�!�-�-�d�D�%��F�����r$c����|j�-tj|j�d|_d|_|jj|j�d|_t�|�!|�yrB) r~rX�CloseHandlerr{�_unregisterrrrc)r rbr"s �r#rcz%_WaitHandleFuture._unregister_wait_cb�sY����;�;�"�������,��D�K�"�D�O� ���"�"�4�8�8�,���� ��#�C�(r$c���|jsyd|_|j}d|_ tj||j�|jj|j|j�|_y#t $rh}|jtjk7rAd||d�}|jr|j|d<|jj|�Yd}~yYd}~��d}~wwxYwre)rSrRrf�UnregisterWaitExr~r7rhrirr8r9r{�_wait_cancelrcrrjs r#rkz"_WaitHandleFuture._unregister_wait�s������� ����'�'�� ��� ��(�(��d�k�k�B��.�.�5�5�d�k�k�6:�6N�6N�P����� ��|�|�{�;�;�;�E�!$�"��� �)�)�26�2H�2H�G�.�/�� � �1�1�'�:��<�� �s� A?�? C0�AC+�+C0)rIrJrKrrcrkrLrMs@r#ryry�s���BF��)�$Pr$ryc�0�eZdZ d�Zd�Zd�Zd�Zd�ZeZy)� PipeServerc��||_tj�|_d|_d|_|j d�|_y�NT)�_address�weakref�WeakSet�_free_instances�_pipe�_accept_pipe_future�_server_pipe_handle)r r,s r#rzPipeServer.__init__�s;���� �&���0����� �#'�� ��-�-�d�3�� r$c�L�|j|jd�c}|_|S�NF)r�r�)r �tmps r#�_get_unconnected_pipez PipeServer._get_unconnected_pipes%�� �*�*�d�&>�&>�u�&E���T�Z�� r$c �,�|j�rytjtjz}|r|tjz}tj |j|tjtjztjztjtjtjtjtj�}tj|�}|j j#|�|SrB)�closedrX�PIPE_ACCESS_DUPLEX�FILE_FLAG_OVERLAPPED�FILE_FLAG_FIRST_PIPE_INSTANCE�CreateNamedPiper��PIPE_TYPE_MESSAGE�PIPE_READMODE_MESSAGE� PIPE_WAIT�PIPE_UNLIMITED_INSTANCESr �BUFSIZE�NMPWAIT_WAIT_FOREVER�NULL� PipeHandler��add)r �first�flags�h�pipes r#r�zPipeServer._server_pipe_handles����;�;�=���*�*�W�-I�-I�I����W�:�:�:�E��#�#��M�M�5��%�%��(E�(E�E���� ��,�,��!�!�=�#8�#8��(�(�'�,�,� 8���'�'��*����� � ��&��r$c��|jduSrB)r�r[s r#r�zPipeServer.closed s��� � ��%�&r$c� �|j�!|jj�d|_|j�J|jD]}|j ��d|_d|_|jj �yyrB)r�r6r�r��closer��clear)r r�s r#r�zPipeServer.close#sp���#�#�/��$�$�+�+�-�'+�D�$��=�=�$��,�,��� � ��-��D�J� �D�M�� � �&�&�(�%r$N) rIrJrKrr�r�r�r��__del__�r$r#r�r��s'���4���$'� )��Gr$r�c��eZdZy)�_WindowsSelectorEventLoopN)rIrJrKr�r$r#r�r�2s��1r$r�c�B��eZdZ d�fd� Z�fd�Zd�Zd�Z dd�Z�xZS)rc�<��|� t�}t�|� |�yrB)rrr)r r�r"s �r#rzProactorEventLoop.__init__9s�����#�~�H� ����"r$c��� |j|j�t�|� �|j�a|jj }|jj �|�'|js|jj|�d|_yy#|j�a|jj }|jj �|�'|js|jj|�d|_wwxYwrB) � call_soon�_loop_self_readingr�run_forever�_self_reading_futurerr6r&r{r�)r r!r"s �r#r�zProactorEventLoop.run_forever>s���� 1��N�N�4�2�2�3��G��!��(�(�4��.�.�2�2���)�)�0�0�2��>�"�*�*��N�N�.�.�r�2�,0��)�5��t�(�(�4��.�.�2�2���)�)�0�0�2��>�"�*�*��N�N�.�.�r�2�,0��)�5�s�)B�A/D c��K�|jj|�}|�d{���}|�}|j||d|i��}||fS7�%�w)N�addr��extra)r{�connect_pipe�_make_duplex_pipe_transport)r �protocol_factoryr,�fr��protocol�transs r#�create_pipe_connectionz(ProactorEventLoop.create_pipe_connectionQsZ�����N�N�'�'��0���w��#�%���0�0��x�8>��7H�1�J���h��� �s�!A�A �&Ac��f�����K�t���d�����fd� ��j���gS�w)Nc�J��d} |ri|j�}�jj|��j�r|j �y��}�j||d�i���j �}|�y�jj|�}|�_ |j��y#t$r9|r#|j�dk7r|j ��j��Yyt$rz}|r9|j�dk7r&�jd||d��|j �n$�j rt#j$d|d���j��Yd}~yd}~wt&j($r|r|j �YyYywxYw) Nr�r�rzPipe accept failed)r2r3r�zAccept pipe failed on pipe %rT)�exc_info)rHr��discardr�r�r�r�r{�accept_piper��add_done_callback�BrokenPipeError�filenor�r7r9�_debugr�warningr �CancelledError) r�r�r�r:r,�loop_accept_piper�r �servers �����r#r�z>ProactorEventLoop.start_serving_pipe.<locals>.loop_accept_pipe\st����D�) 6���8�8�:�D��*�*�2�2�4�8��}�}��� � ���/�1�H��4�4��h�v�w�.?�5�A��3�3�5���<���N�N�.�.�t�4��*./��*��#�#�$4�5��+#� 1��D�K�K�M�R�/��J�J�L����/�0�� 1��D�K�K�M�R�/��/�/�#7�%(� $�1�� �J�J�L��[�[��N�N�#B�#'�$�8����/�0�0���,�,� !���J�J�L�� !�s1�A B7�/B7�B7�7?F"�8F"�A0E5�5(F"�!F"rB)r�r�)r r�r,r�r�s```@@r#�start_serving_pipez$ProactorEventLoop.start_serving_pipeYs2������G�$��+ 6�+ 6�Z ���'�(��x��s�*1c ��K�|j�} t||||||||f| |d�| ��} | �d{���|S7�#ttf$r�t$r+|j�|j ��d{���7�wxYw�w)N)�waiterr�)� create_future�_WindowsSubprocessTransport� SystemExit�KeyboardInterrupt� BaseExceptionr��_wait)r r��args�shell�stdin�stdout�stderr�bufsizer��kwargsr��transps r#�_make_subprocess_transportz,ProactorEventLoop._make_subprocess_transport�s������#�#�%��,�T�8�T�5�-2�F�F�G�7�4:�%�7�06�7�� ��L�L�� � ���-�.� ��� ��L�L�N��,�,�.� � �� �s1�'A>�8�6�8�A>�8�;A;�3A6�4A;�;A>rB) rIrJrKrr�r�r�r�rLrMs@r#rr6s%���<�#� 1�&�1�j04�r$rc���eZdZ efd�Zd�Zd�Zd�Zd d�Zd�Z e d��Zed ��Z d!d �Zd!d�Zd!d�Zd!d �Zd"d�Zd!d�Zd�Zd�Zd�Zd�Zd�Zd d�Zd�Zd�Zd�Zd�Zd�Zd�Zd d�Z d�Z!d�Z"d�Z#y)#rc��d|_g|_tjtjt d|�|_i|_tj�|_ g|_tj�|_yrW) r8�_resultsrf�CreateIoCompletionPort�INVALID_HANDLE_VALUEr��_iocp�_cacher�r�rS� _unregistered�_stopped_serving)r �concurrencys r#rzIocpProactor.__init__�s_���� ��� � �7�7��,�,�d�A�{�D�� ����"�?�?�,������ '��� 1��r$c�2�|j�td��y)NzIocpProactor is closed)r�rur[s r#� _check_closedzIocpProactor._check_closed�s���:�:���7�8�8�r$c���dt|j�zdt|j�zg}|j�|j d�d|j j�ddj|��d�S)Nzoverlapped#=%sz result#=%sr��<� r))�lenr�r�r�r`r"rI�join)r r.s r#�__repr__zIocpProactor.__repr__�s_�� �3�t�{�{�#3�3��s�4�=�=�1�1�3���:�:���K�K��!�� �N�N�3�3�S�X�X�d�^�D�Dr$c��||_yrB)r8)r rs r#�set_loopzIocpProactor.set_loop�s ���� r$Nc�z�|js|j|�|j}g|_ |d}S#d}wxYwrB)r�r\)r �timeoutr�s r#�selectzIocpProactor.select�s:���}�}��J�J�w���m�m���� � ���C��$�C�s�6�:c�\�|jj�}|j|�|SrB)r8r�rF)r �valuerbs r#�_resultzIocpProactor._result�s%���j�j�&�&�(�����u��� r$c��� |j�S#t$rD}|jtjtj fvrt |j���d}~wwxYwrB)� getresultr7rhrf�ERROR_NETNAME_DELETED�ERROR_OPERATION_ABORTED�ConnectionResetErrorr�)r��keyr!r:s r#�finish_socket_funczIocpProactor.finish_socket_func�sY�� ��<�<�>�!��� ��|�|�� A� A� +� C� C� E�E�*�C�H�H�5�5��� �s�� A�?A�Ac�� |j|||�S#t$r,}|jtjk(r |dfcYd}~S�d}~wwxYwrB)rr7rhrf�ERROR_PORT_UNREACHABLE)�clsr�rr!�empty_resultr:s r#�_finish_recvfromzIocpProactor._finish_recvfrom�sN�� ��)�)�%��b�9�9��� ��|�|�{�A�A�A�#�T�)�)��� �s�� A � A�A �A�A c��|j|�tjt�} t |t j �r"|j |j�||�n |j|j�|�|j|||j�S#t$r|jd�cYSwxYw)Nr$) �_register_with_iocprf� Overlappedr�� isinstance�socket�WSARecvr��ReadFiler�r�� _registerr�r �conn�nbytesr�r!s r#�recvzIocpProactor.recv�s���� � ��&� � #� #�D� )�� %��$�� � �.�� � �4�;�;�=�&�%�8����D�K�K�M�6�2��~�~�b�$��(?�(?�@�@��� %��<�<��$�$� %���AB%�%C�Cc��|j|�tjt�} t |t j �r"|j |j�||�n |j|j�|�|j|||j�S#t$r|jd�cYSwxYwrW) r rfr r�rr�WSARecvIntor��ReadFileIntor�r�rr�r r�bufr�r!s r#� recv_intozIocpProactor.recv_into�s���� � ��&� � #� #�D� )�� #��$�� � �.����t�{�{�}�c�5�9������� �s�3��~�~�b�$��(?�(?�@�@��� #��<�<��?�"� #�rc�*�|j|�tjt�} |j |j�||�|j||t|jd���S#t$r|jd�cYSwxYw)N)r$Nr$�r)r rfr r��WSARecvFromr�r�r�rrrrs r#�recvfromzIocpProactor.recvfrom�s���� � ��&� � #� #�D� )�� -��N�N�4�;�;�=�&�%�8��~�~�b�$���0E�0E�=@�)B�C� C��� -��<�<��,�,� -���!A5�5B�Bc�*�|j|�tjt�} |j |j�||�|j||t|jd���S#t$r|jd�cYSwxYw)N�rNrr)r rfr r��WSARecvFromIntor�r�r�rrrrs r#� recvfrom_intozIocpProactor.recvfrom_intos���� � ��&� � #� #�D� )�� +����t�{�{�}�c�5�9��~�~�b�$���0E�0E�=>�)@�A� A��� +��<�<� �*�*� +�rc���|j|�tjt�}|j |j�|||�|j |||j�SrB)r rfr r�� WSASendTor�rr)r rrr�r�r!s r#�sendtozIocpProactor.sendtosQ��� � ��&� � #� #�D� )�� ���T�[�[�]�C���5��~�~�b�$��(?�(?�@�@r$c�H�|j|�tjt�}t |t j �r"|j |j�||�n |j|j�|�|j|||j�SrB)r rfr r�rr�WSASendr�� WriteFilerrrs r#�sendzIocpProactor.sendsq��� � ��&� � #� #�D� )���d�F�M�M�*��J�J�t�{�{�}�c�5�1��L�L������,��~�~�b�$��(?�(?�@�@r$c�|���|j��|j�j��tjt �}|j �j��j����fd�}d�}|j|�|�}||��}tj||j��|S)Nc�,��|j�tjd�j��}�j t jtj|��j�j����j�fS)Nz@P)r��struct�packr�� setsockoptr� SOL_SOCKETrf�SO_UPDATE_ACCEPT_CONTEXT� settimeout� gettimeout�getpeername)r�rr!rr�listeners ��r#� finish_acceptz*IocpProactor.accept.<locals>.finish_accept*sl����L�L�N��+�+�d�H�O�O�$5�6�C��O�O�F�-�-�'�@�@�#� G��O�O�H�/�/�1�2���)�)�+�+�+r$c��vK� |�d{���y7�#tj$r|j��wxYw�wrB)r r�r�)r4rs r#�accept_coroz(IocpProactor.accept.<locals>.accept_coro3s2���� ������,�,� �� � ��� �s �9����9��%6�9r)r �_get_accept_socket�familyrfr r��AcceptExr�rr� ensure_futurer8)r r5r!r6r8r4�corors ` @r#�acceptzIocpProactor.accept$s����� � ��*��&�&�x���7�� � #� #�D� )�� ���H�O�O�%�t�{�{�}�5� ,� �����H�m�<���6�4�(�� ���D�t�z�z�2�� r$c����jtjk(rQtj�j�|�|jj�}|jd�|S|j�� tj�j��j�tj"t$�}|j'�j�|��fd�}|j)|�|�S#t$r?}|jtjk7r��j!�ddk(r�Yd}~��d}~wwxYw)Nrrc���|j��jtjtj d��SrW)r�r/rr0rf�SO_UPDATE_CONNECT_CONTEXT)r�rr!rs �r#�finish_connectz,IocpProactor.connect.<locals>.finish_connectVs1����L�L�N��O�O�F�-�-�'�A�A�1� F��Kr$)�typer� SOCK_DGRAMrf� WSAConnectr�r8r�rFr � BindLocalr:r7rh�errno� WSAEINVAL�getsocknamer r�� ConnectExr)r rr,rb�er!rBs ` r#�connectzIocpProactor.connect@s����9�9��)�)�)� �"�"�4�;�;�=�'�:��*�*�*�*�,�C��N�N�4� ��J�� � ��&� ��!�!�$�+�+�-����=�� #� #�D� )�� ���T�[�[�]�G�,� ��~�~�b�$��7�7��!� ��z�z�U�_�_�,�����!�!�$��)��*�� �s�.D� E � 5E�E c �6�|j|�tjt�}|dz}|dz dz}|j |j�t j|j��|||dd�|j|||j�S)Nl��� r) r rfr r��TransmitFiler��msvcrt� get_osfhandlerr)r �sock�file�offset�countr!� offset_low�offset_highs r#�sendfilezIocpProactor.sendfile_s���� � ��&� � #� #�D� )���k�)� ���|�{�2�� ������ ��,�,�T�[�[�]�;�"�K��q�!� %� �~�~�b�$��(?�(?�@�@r$c����|j��tjt�}|j �j��}|r|j ��S�fd�}|j|�|�S)Nc�(��|j��SrB)r�)r�rr!r�s �r#�finish_accept_pipez4IocpProactor.accept_pipe.<locals>.finish_accept_pipevs����L�L�N��Kr$)r rfr r��ConnectNamedPiper�r�r)r r�r!� connectedr[s ` r#r�zIocpProactor.accept_pipeksf���� � ��&� � #� #�D� )���'�'���� �6� ���<�<��%�%� ��~�~�b�$�(:�;�;r$c��<K�t} tj|�} tj|�S#t$r(}|jtj k7r�Yd}~nd}~wwxYwt |dzt�}tj|��d{���7���w)N�)�CONNECT_PIPE_INIT_DELAYrf�ConnectPiper7rh�ERROR_PIPE_BUSY�min�CONNECT_PIPE_MAX_DELAYr�sleepr r�)r r,�delayrTr:s r#r�zIocpProactor.connect_pipe|s�����'��� �$�0�0��9����'�'��/�/��� ��<�<�;�#>�#>�>��?�� �� ��� �#9�:�E��+�+�e�$�$�$��s6�B�6�B� A'�A"�B�"A'�'.B�B�Bc�*� |j||d�Sr�)�_wait_for_handle)r rTr�s r#�wait_for_handlezIocpProactor.wait_for_handle�s�� � �$�$�V�W�e�<�<r$c�:�|j|dd�}||_|Sr�)rhrr)r rs� done_callbackrbs r#r�zIocpProactor._wait_cancel�s%���#�#�E�4��6��+���� r$c����|j�|�tj}ntj|dz�}tjt�}tj||j|j|�}|rt||||j���nt|||||j����jr �jd=�fd�}�|d|f|j|j<�S)N�@�@rrc�$���j�SrB)r\)r�rr!r�s �r#�finish_wait_for_handlez=IocpProactor._wait_for_handle.<locals>.finish_wait_for_handle�s����7�7�9�r$r)r�rX�INFINITE�math�ceilrfr r��RegisterWaitWithQueuer�r,rpr8ryrr�) r rTr�� _is_cancel�msr!rUror�s @r#rhzIocpProactor._wait_for_handle�s���������?��!�!�B����7�S�=�)�B�� #� #�D� )��!�7�7��D�J�J�� � �B�0���!�"�f�k�� � �K�A�!�"�f�k�4�'+�z�z�3�A�����#�#�B�'� �$%�b�!�-C�"D����B�J�J���r$c��||jvrL|jj|�tj|j �|j dd�yyrW)rSr�rfr�r�r��r �objs r#r z IocpProactor._register_with_iocp�sI���d�&�&�&���� � ��%��.�.�s�z�z�|�T�Z�Z��A�N�'r$c�^�|j�t||j��}|jr |jd=|js |dd|�}|j|�||||f|j|j<|S#t$r}|j|�Yd}~�>d}~wwxYwr) r�rr8rr&rFr7rCr�r,)r r!rx�callbackr�r�rKs r#rzIocpProactor._register�s������� �b�t�z�z�2������#�#�B�'��z�z� $� ��t�R�0�����U�#�$%�b�#�x�"8����B�J�J������ #�����"�"�� #�s� B� B,�B'�'B,c�\� |j�|jj|�yrB)r�r�r`)r r!s r#r�zIocpProactor._unregister�s)�� � �������!�!�"�%r$c�R�tj|�}|jd�|SrW)rr2)r r:�ss r#r9zIocpProactor._get_accept_socket�s ���M�M�&�!�� ���Q���r$c �"�|�t}n<|dkrtd��tj|dz�}|tk\rtd�� t j |j|�}|�n�d}|\}}}} |jj|�\}} } }| |j vr|j#�nI|j%�s9 |||| �}|j'|�|j(j+|�d}��|j0D](} |jj| j2d��*|j0j5�y#t$rl|jj�r%|jjdd||||fzd��|dtjfvrtj|�Y��}wxYw#t,$r7} |j/| �|j(j+|�Yd} ~ ��d} ~ wwxYw#d}wxYw)Nrznegative timeoutrmztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r2�status)rp� ValueErrorrqrrrf�GetQueuedCompletionStatusr�r��pop�KeyErrorr8� get_debugr9r�rXr�r�r6�donerFr�r`r7rCr�r,r�)r r�rur�err�transferredrr,r�r!rxrzr�rKs r#r\zIocpProactor._poll�s����?��B� �q�[��/�0�0����7�S�=�)�B��X�~� �!2�3�3�� �:�:�4�:�:�r�J�F��~���B�-3�*�C��c�7� �'+�{�{���w�'?�$��2�s�H� �d�+�+�+���� ��V�V�X� �$�[�#�r�:�E� �L�L��'��M�M�(�(��+��A�M�R�$�$�B��K�K�O�O�B�J�J��-�%���� � �"��E� ��:�:�'�'�)��J�J�5�5�%7�#N�&)�;��W�%E�$F�7���q�+�"B�"B�C�C��'�'��,�� ��,�,��O�O�A�&��M�M�(�(��+�+��,���A�sC�4 E� G�,H �A1G�G� H�,H�<H �H�H � Hc�:�|jj|�yrB)r�r�rws r#� _stop_servingzIocpProactor._stop_serving2s�� ���!�!�#�&r$c�4�|j�yt|jj��D]:\}}}}|j �r�t|t�r�* |j��<d}tj�}||z} |jrx| tj�krCtjd|tj�|z �tj�|z} |j!|�|jr�xg|_t%j&|j�d|_y#t$rS}|j�<d||d�}|jr|j|d<|jj|�Yd}~��ad}~wwxYw)NzCancelling a future failedr1r5g�?z,%r is running after closing for %.1f seconds)r��listr��values� cancelledrrpr6r7r8rr9�time� monotonicr�debugr\r�rXr�) r rbr!rxrzr:r;� msg_update� start_time�next_msgs r#r�zIocpProactor.close8s[���:�:���'+�4�;�;�+=�+=�+?�&@�"�C��S�(��}�}����C�!2�3��C��J�J�L�'A�0� ��^�^�%� �� �*���k�k��4�>�>�+�+����K�!�4�>�>�#3�j�#@�B��>�>�+�j�8�� �J�J�z�"��k�k��� ����D�J�J�'��� ��;� C��z�z�-�'C�),�&)�#�� �0�0�:=�:O�:O�G�$6�7�� � �9�9�'�B��� C�s�D;�; F�AF�Fc�$�|j�yrB)r�r[s r#r�zIocpProactor.__del__gs��� � �r$rB)rr!)$rIrJrKrprr�r�r�r�r��staticmethodr�classmethodrrrrr#r&r*r>rLrXr�r�rir�rhr rr�r9r\r�r�r�r�r$r#rr�s���-�#+�2�9�E�� �� ����� �� �A�A� C� A�A�A��88�> A�<�"0�&=�� �DO��@&�� 7#�r'�-�^r$rc��eZdZd�Zy)r�c ���tj|f|||||d�|���_�fd�}�jjjt �jj��} | j|�y)N)r�r�r�r�r�c�\���jj�}�j|�yrB)�_proc�poll�_process_exited)r�� returncoder s �r#rzz4_WindowsSubprocessTransport._start.<locals>.callbackrs!��������*�J�� � ��,r$) r �Popenr�r8r{ri�intrQr�) r r�r�r�r�r�r�r�rzr�s ` r#�_startz"_WindowsSubprocessTransport._startmso���"�(�(��'��U�6�&��'�%�'�� � -� �J�J� � �0�0��T�Z�Z�5G�5G�1H�I�� ���H�%r$N)rIrJrKr�r�r$r#r�r�ks�� &r$r�c��eZdZeZy)rN)rIrJrKr� _loop_factoryr�r$r#rr}���%�Mr$rc��eZdZeZy)rN)rIrJrKrr�r�r$r#rr�r�r$r)3�sys�platform�ImportErrorrfrXrG� functoolsrrqrPrr-r�r��rrrr r rrr �logr�__all__r�rp�ERROR_CONNECTION_REFUSED�ERROR_CONNECTION_ABORTEDr`rd�FuturerrOrpry�objectr��BaseSelectorEventLoopr��BaseProactorEventLooprr�BaseSubprocessTransportr�r�BaseDefaultEventLoopPolicyrrrr�r$r#�<module>r�s\��4� ��<�<�7�� �l� #�#������ � � ���������������|�|���������� ����-����-�`G#�G�N�N�G#�T&�-�&�01P�-�1P�h8��8�v2�� E� E�2�g��=�=�g�TH�H�V&�/�"I�"I�&�.��&�V�%F�%F�&�&�V�%F�%F�&�8�r$__pycache__/windows_events.cpython-312.pyc000064400000121065151706172560014554 0ustar00� T��hK����dZddlZejdk7red��ddlZddlZddlZddlmZddl Z ddl Z ddlZddlZddl Z ddlZddlmZddlmZdd lmZdd lmZddlmZddlmZdd lmZddlmZddlmZdZej6Zej8ZdZdZdZdZ Gd�dejB�Z"Gd�dejB�Z#Gd�de#�Z$Gd�de#�Z%Gd�de&�Z'Gd�d ejP�Z)Gd!�d"ejT�Z+Gd#�d$�Z,Gd%�d&ejZ�Z.e)Z/Gd'�d(ej`�Z1Gd)�d*ej`�Z2e2Z3y)+z.Selector and proactor event loops for Windows.�N�win32z win32 only)�partial�)�events)�base_subprocess)�futures)� exceptions)�proactor_events)�selector_events)�tasks)� windows_utils)�logger)�SelectorEventLoop�ProactorEventLoop�IocpProactor�DefaultEventLoopPolicy�WindowsSelectorEventLoopPolicy�WindowsProactorEventLoopPolicyi�i�g����MbP?g�������?c�X��eZdZdZdd��fd� Z�fd�Zd�Zd �fd� Z�fd�Z�fd �Z �xZ S)�_OverlappedFuturez�Subclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. N��loopc�f��t�|�|��|jr |jd=||_y�Nr���)�super�__init__�_source_traceback�_ov)�self�ovr� __class__s ��//usr/lib64/python3.12/asyncio/windows_events.pyrz_OverlappedFuture.__init__7s1��� ���d��#��!�!��&�&�r�*����c����t�|��}|j�H|jjrdnd}|j dd|�d|jj d�d��|S)N�pending� completedrzoverlapped=<z, �#x�>)r� _repr_inforr&�insert�address�r �info�stater"s �r#r*z_OverlappedFuture._repr_info=s\����w�!�#���8�8��!%���!1�!1�I�{�E��K�K��\�%���4�8�8�3C�3C�B�2G�q�I�J��r$c��|j�y |jj�d|_y#t$rM}d||d�}|jr|j|d<|jj|�Yd}~d|_yd}~wwxYw)Nz&Cancelling an overlapped future failed��message� exception�future�source_traceback)r�cancel�OSErrorr�_loop�call_exception_handler)r �exc�contexts r#�_cancel_overlappedz$_OverlappedFuture._cancel_overlappedDs����8�8��� 7��H�H�O�O������� 7�C� ���G� �%�%�.2�.D�.D��*�+��J�J�-�-�g�6�6����� 7�s�1� B�<B�Bc�D��|j�t�|� |��S�N)�msg)r<rr6�r r?r"s �r#r6z_OverlappedFuture.cancelTs ������!��w�~�#�~�&�&r$c�D��t�|�|�|j�y�N)r� set_exceptionr<�r r3r"s �r#rCz_OverlappedFuture.set_exceptionXs��� ���i�(����!r$c�2��t�|�|�d|_yrB)r� set_resultr�r �resultr"s �r#rFz_OverlappedFuture.set_result\s��� ���6�"���r$rB)�__name__� __module__�__qualname__�__doc__rr*r<r6rCrF� __classcell__�r"s@r#rr1s0���� $(���� '�"��r$rc�d��eZdZdZdd��fd� Zd�Z�fd�Zd�Zd�Zd�fd � Z �fd �Z �fd�Z�xZS) �_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.Nrc���t�|�|��|jr |jd=||_||_||_d|_y)NrrT)rrrr�_handle�_wait_handle�_registered)r r!�handle�wait_handlerr"s �r#rz_BaseWaitHandleFuture.__init__dsL��� ���d��#��!�!��&�&�r�*�������'��� ��r$c�d�tj|jd�tjk(S�Nr)�_winapi�WaitForSingleObjectrR� WAIT_OBJECT_0�r s r#�_pollz_BaseWaitHandleFuture._pollrs)���+�+�D�L�L�!�<��%�%�&� 'r$c���t�|��}|jd|jd���|j�%|j �rdnd}|j|�|j �|jd|j d���|S)Nzhandle=r(�signaled�waitingzwait_handle=)rr*�appendrRr]rSr-s �r#r*z _BaseWaitHandleFuture._repr_infows|����w�!�#�����g�d�l�l�2�.�/�0��<�<�#�"&�*�*�,�J�I�E��K�K������(��K�K�,�t�'8�'8��&<�=�>��r$c��d|_yrB)r)r �futs r#�_unregister_wait_cbz)_BaseWaitHandleFuture._unregister_wait_cb�s����r$c��|jsyd|_|j}d|_ tj|�|jd�y#t$rh}|j tjk7rAd||d�}|jr|j|d<|jj|�Yd}~yYd}~�~d}~wwxYw�NFz$Failed to unregister the wait handler1r5)rTrS�_overlapped�UnregisterWaitr7�winerror�ERROR_IO_PENDINGrr8r9rd�r rVr:r;s r#�_unregister_waitz&_BaseWaitHandleFuture._unregister_wait�s������� ����'�'�� ��� ��&�&�{�3� � � ��&��� ��|�|�{�;�;�;�E�!$�"��� �)�)�26�2H�2H�G�.�/�� � �1�1�'�:��<�� �s�A� C�AB<�<Cc�D��|j�t�|� |��Sr>)rlrr6r@s �r#r6z_BaseWaitHandleFuture.cancel�s ��������w�~�#�~�&�&r$c�D��|j�t�|� |�yrB)rlrrCrDs �r#rCz#_BaseWaitHandleFuture.set_exception�s������� ���i�(r$c�D��|j�t�|� |�yrB)rlrrFrGs �r#rFz _BaseWaitHandleFuture.set_result�s������� ���6�"r$rB) rIrJrKrLrr]r*rdrlr6rCrFrMrNs@r#rPrPas6���<�8<� �'� �� '�0'�)�#�#r$rPc�B��eZdZdZdd��fd� Zd�Z�fd�Z�fd�Z�xZS)�_WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. Nrc�:��t�|�||||��d|_y)Nr)rr�_done_callback)r r!�eventrVrr"s �r#rz_WaitCancelFuture.__init__�s!��� ����U�K�d��;�"��r$c��td��)Nz'_WaitCancelFuture must not be cancelled)�RuntimeErrorr\s r#r6z_WaitCancelFuture.cancel�s���D�E�Er$c�`��t�|�|�|j�|j|�yyrB)rrFrsrGs �r#rFz_WaitCancelFuture.set_result�s/��� ���6�"����*�����%�+r$c�`��t�|�|�|j�|j|�yyrB)rrCrsrDs �r#rCz_WaitCancelFuture.set_exception�s/��� ���i�(����*�����%�+r$) rIrJrKrLrr6rFrCrMrNs@r#rqrq�s'����8<�#� F�&� &�&r$rqc�4��eZdZdd��fd� Z�fd�Zd�Z�xZS)�_WaitHandleFutureNrc���t�|�||||��||_d|_t j dddd�|_d|_y)NrTF)rr� _proactor�_unregister_proactorrg�CreateEvent�_event� _event_fut)r r!rUrV�proactorrr"s �r#rz_WaitHandleFuture.__init__�sG��� ����V�[�t��<�!���$(��!�!�-�-�d�D�%��F�����r$c����|j�-tj|j�d|_d|_|jj|j�d|_t�|�!|�yrB) rrY�CloseHandler�r|�_unregisterrrrd)r rcr"s �r#rdz%_WaitHandleFuture._unregister_wait_cb�sY����;�;�"�������,��D�K�"�D�O� ���"�"�4�8�8�,���� ��#�C�(r$c���|jsyd|_|j}d|_ tj||j�|jj|j|j�|_y#t $rh}|jtjk7rAd||d�}|jr|j|d<|jj|�Yd}~yYd}~��d}~wwxYwrf)rTrSrg�UnregisterWaitExrr7rirjrr8r9r|�_wait_cancelrdr�rks r#rlz"_WaitHandleFuture._unregister_wait�s������� ����'�'�� ��� ��(�(��d�k�k�B��.�.�5�5�d�k�k�6:�6N�6N�P����� ��|�|�{�;�;�;�E�!$�"��� �)�)�26�2H�2H�G�.�/�� � �1�1�'�:��<�� �s� A?�? C0�AC+�+C0)rIrJrKrrdrlrMrNs@r#rzrz�s���BF��)�$Pr$rzc�2�eZdZdZd�Zd�Zd�Zd�Zd�ZeZ y)� PipeServerzXClass representing a pipe server. This is much like a bound, listening socket. c��||_tj�|_d|_d|_|j d�|_y�NT)�_address�weakref�WeakSet�_free_instances�_pipe�_accept_pipe_future�_server_pipe_handle)r r,s r#rzPipeServer.__init__�s;���� �&���0����� �#'�� ��-�-�d�3�� r$c�L�|j|jd�c}|_|S)NF)r�r�)r �tmps r#�_get_unconnected_pipez PipeServer._get_unconnected_pipes%�� �*�*�d�&>�&>�u�&E���T�Z�� r$c �,�|j�rytjtjz}|r|tjz}tj |j|tjtjztjztjtjtjtjtj�}tj|�}|j j#|�|SrB)�closedrY�PIPE_ACCESS_DUPLEX�FILE_FLAG_OVERLAPPED�FILE_FLAG_FIRST_PIPE_INSTANCE�CreateNamedPiper��PIPE_TYPE_MESSAGE�PIPE_READMODE_MESSAGE� PIPE_WAIT�PIPE_UNLIMITED_INSTANCESr �BUFSIZE�NMPWAIT_WAIT_FOREVER�NULL� PipeHandler��add)r �first�flags�h�pipes r#r�zPipeServer._server_pipe_handles����;�;�=���*�*�W�-I�-I�I����W�:�:�:�E��#�#��M�M�5��%�%��(E�(E�E���� ��,�,��!�!�=�#8�#8��(�(�'�,�,� 8���'�'��*����� � ��&��r$c��|jduSrB)r�r\s r#r�zPipeServer.closed s��� � ��%�&r$c� �|j�!|jj�d|_|j�J|jD]}|j ��d|_d|_|jj �yyrB)r�r6r�r��closer��clear)r r�s r#r�zPipeServer.close#sp���#�#�/��$�$�+�+�-�'+�D�$��=�=�$��,�,��� � ��-��D�J� �D�M�� � �&�&�(�%r$N) rIrJrKrLrr�r�r�r��__del__�r$r#r�r��s'���4���$'� )��Gr$r�c��eZdZdZy)�_WindowsSelectorEventLoopz'Windows version of selector event loop.N)rIrJrKrLr�r$r#r�r�2s��1r$r�c�D��eZdZdZd�fd� Z�fd�Zd�Zd�Z dd�Z�xZ S)rz2Windows version of proactor event loop using IOCP.c�<��|� t�}t�|� |�yrB)rrr)r r�r"s �r#rzProactorEventLoop.__init__9s�����#�~�H� ����"r$c�4�� |j�J�|j|j�t�|��|j�a|jj }|jj �|�'|js|jj|�d|_yy#|j�a|jj }|jj �|�'|js|jj|�d|_wwxYwrB) �_self_reading_future� call_soon�_loop_self_readingr�run_foreverrr6r&r|r�)r r!r"s �r#r�zProactorEventLoop.run_forever>s���� 1��,�,�4�4�4��N�N�4�2�2�3��G��!��(�(�4��.�.�2�2���)�)�0�0�2��>�"�*�*��N�N�.�.�r�2�,0��)�5��t�(�(�4��.�.�2�2���)�)�0�0�2��>�"�*�*��N�N�.�.�r�2�,0��)�5�s�7B(�(A/Dc��K�|jj|�}|�d{���}|�}|j||d|i��}||fS7�%�w)N�addr��extra)r|�connect_pipe�_make_duplex_pipe_transport)r �protocol_factoryr,�fr��protocol�transs r#�create_pipe_connectionz(ProactorEventLoop.create_pipe_connectionQsZ�����N�N�'�'��0���w��#�%���0�0��x�8>��7H�1�J���h��� �s�!A�A �&Ac��f�����K�t���d�����fd� ��j���gS�w)Nc�J��d} |ri|j�}�jj|��j�r|j �y��}�j||d�i���j �}|�y�jj|�}|�_ |j��y#t$r9|r#|j�dk7r|j ��j��Yyt$rz}|r9|j�dk7r&�jd||d��|j �n$�j rt#j$d|d���j��Yd}~yd}~wt&j($r|r|j �YyYywxYw) Nr�r�rzPipe accept failed)r2r3r�zAccept pipe failed on pipe %rT)�exc_info)rHr��discardr�r�r�r�r|�accept_piper��add_done_callback�BrokenPipeError�filenor�r7r9�_debugr�warningr �CancelledError) r�r�r�r:r,�loop_accept_piper�r �servers �����r#r�z>ProactorEventLoop.start_serving_pipe.<locals>.loop_accept_pipe\st����D�) 6���8�8�:�D��*�*�2�2�4�8��}�}��� � ���/�1�H��4�4��h�v�w�.?�5�A��3�3�5���<���N�N�.�.�t�4��*./��*��#�#�$4�5��+#� 1��D�K�K�M�R�/��J�J�L����/�0�� 1��D�K�K�M�R�/��/�/�#7�%(� $�1�� �J�J�L��[�[��N�N�#B�#'�$�8����/�0�0���,�,� !���J�J�L�� !�s1�A B7�/B7�B7�7?F"�8F"�A0E5�5(F"�!F"rB)r�r�)r r�r,r�r�s```@@r#�start_serving_pipez$ProactorEventLoop.start_serving_pipeYs2������G�$��+ 6�+ 6�Z ���'�(��x��s�*1c ��K�|j�} t||||||||f| |d�| ��} | �d{���|S7�#ttf$r�t$r+|j�|j ��d{���7�wxYw�w)N)�waiterr�)� create_future�_WindowsSubprocessTransport� SystemExit�KeyboardInterrupt� BaseExceptionr��_wait)r r��args�shell�stdin�stdout�stderr�bufsizer��kwargsr��transps r#�_make_subprocess_transportz,ProactorEventLoop._make_subprocess_transport�s������#�#�%��,�T�8�T�5�-2�F�F�G�7�4:�%�7�06�7�� ��L�L�� � ���-�.� ��� ��L�L�N��,�,�.� � �� �s1�'A>�8�6�8�A>�8�;A;�3A6�4A;�;A>rB) rIrJrKrLrr�r�r�r�rMrNs@r#rr6s%���<�#� 1�&�1�j04�r$rc���eZdZdZefd�Zd�Zd�Zd�Zd!d�Z d�Z ed ��Ze d ��Zd"d�Zd"d�Zd"d �Zd"d�Zd#d�Zd"d�Zd�Zd�Zd�Zd�Zd�Zd!d�Zd�Zd�Zd�Zd�Zd�Zd�Z d!d�Z!d�Z"d�Z#d �Z$y)$rz#Proactor implementation using IOCP.c��d|_g|_tjtjt d|�|_i|_tj�|_ g|_tj�|_yrX) r8�_resultsrg�CreateIoCompletionPort�INVALID_HANDLE_VALUEr��_iocp�_cacher�r�rT� _unregistered�_stopped_serving)r �concurrencys r#rzIocpProactor.__init__�s_���� ��� � �7�7��,�,�d�A�{�D�� ����"�?�?�,������ '��� 1��r$c�2�|j�td��y)NzIocpProactor is closed)r�rvr\s r#� _check_closedzIocpProactor._check_closed�s���:�:���7�8�8�r$c���dt|j�zdt|j�zg}|j�|j d�d|j j�ddj|��d�S)Nzoverlapped#=%sz result#=%sr��<� r))�lenr�r�r�rar"rI�join)r r.s r#�__repr__zIocpProactor.__repr__�s_�� �3�t�{�{�#3�3��s�4�=�=�1�1�3���:�:���K�K��!�� �N�N�3�3�S�X�X�d�^�D�Dr$c��||_yrB)r8)r rs r#�set_loopzIocpProactor.set_loop�s ���� r$Nc�z�|js|j|�|j}g|_ |d}S#d}wxYwrB)r�r])r �timeoutr�s r#�selectzIocpProactor.select�s:���}�}��J�J�w���m�m���� � ���C��$�C�s�6�:c�\�|jj�}|j|�|SrB)r8r�rF)r �valuercs r#�_resultzIocpProactor._result�s%���j�j�&�&�(�����u��� r$c��� |j�S#t$rD}|jtjtj fvrt |j���d}~wwxYwrB)� getresultr7rirg�ERROR_NETNAME_DELETED�ERROR_OPERATION_ABORTED�ConnectionResetErrorr�)r��keyr!r:s r#�finish_socket_funczIocpProactor.finish_socket_func�sY�� ��<�<�>�!��� ��|�|�� A� A� +� C� C� E�E�*�C�H�H�5�5��� �s�� A�?A�Ac�� |j|||�S#t$r,}|jtjk(r |dfcYd}~S�d}~wwxYwrB)rr7rirg�ERROR_PORT_UNREACHABLE)�clsr�rr!�empty_resultr:s r#�_finish_recvfromzIocpProactor._finish_recvfrom�sN�� ��)�)�%��b�9�9��� ��|�|�{�A�A�A�#�T�)�)��� �s�� A � A�A �A�A c��|j|�tjt�} t |t j �r"|j |j�||�n |j|j�|�|j|||j�S#t$r|jd�cYSwxYw)Nr$) �_register_with_iocprg� Overlappedr�� isinstance�socket�WSARecvr��ReadFiler�r�� _registerr�r �conn�nbytesr�r!s r#�recvzIocpProactor.recv�s���� � ��&� � #� #�D� )�� %��$�� � �.�� � �4�;�;�=�&�%�8����D�K�K�M�6�2��~�~�b�$��(?�(?�@�@��� %��<�<��$�$� %���AB%�%C�Cc��|j|�tjt�} t |t j �r"|j |j�||�n |j|j�|�|j|||j�S#t$r|jd�cYSwxYwrX) r rgr r�rr�WSARecvIntor��ReadFileIntor�r�rr�r r�bufr�r!s r#� recv_intozIocpProactor.recv_into�s���� � ��&� � #� #�D� )�� #��$�� � �.����t�{�{�}�c�5�9������� �s�3��~�~�b�$��(?�(?�@�@��� #��<�<��?�"� #�rc�*�|j|�tjt�} |j |j�||�|j||t|jd���S#t$r|jd�cYSwxYw)N)r$Nr$�r)r rgr r��WSARecvFromr�r�r�rrrrs r#�recvfromzIocpProactor.recvfrom�s���� � ��&� � #� #�D� )�� -��N�N�4�;�;�=�&�%�8��~�~�b�$���0E�0E�=@�)B�C� C��� -��<�<��,�,� -���!A5�5B�Bc�*�|j|�tjt�} |j |j�||�|j||t|jd���S#t$r|jd�cYSwxYw)N�rNrr)r rgr r��WSARecvFromIntor�r�r�rrrrs r#� recvfrom_intozIocpProactor.recvfrom_intos���� � ��&� � #� #�D� )�� +����t�{�{�}�c�5�9��~�~�b�$���0E�0E�=>�)@�A� A��� +��<�<� �*�*� +�rc���|j|�tjt�}|j |j�|||�|j |||j�SrB)r rgr r�� WSASendTor�rr)r rrr�r�r!s r#�sendtozIocpProactor.sendtosQ��� � ��&� � #� #�D� )�� ���T�[�[�]�C���5��~�~�b�$��(?�(?�@�@r$c�H�|j|�tjt�}t |t j �r"|j |j�||�n |j|j�|�|j|||j�SrB)r rgr r�rr�WSASendr�� WriteFilerrrs r#�sendzIocpProactor.sendsq��� � ��&� � #� #�D� )���d�F�M�M�*��J�J�t�{�{�}�c�5�1��L�L������,��~�~�b�$��(?�(?�@�@r$c�|���|j��|j�j��tjt �}|j �j��j����fd�}d�}|j|�|�}||��}tj||j��|S)Nc�,��|j�tjd�j��}�j t jtj|��j�j����j�fS)Nz@P)r��struct�packr�� setsockoptr� SOL_SOCKETrg�SO_UPDATE_ACCEPT_CONTEXT� settimeout� gettimeout�getpeername)r�rr!rr�listeners ��r#� finish_acceptz*IocpProactor.accept.<locals>.finish_accept*sl����L�L�N��+�+�d�H�O�O�$5�6�C��O�O�F�-�-�'�@�@�#� G��O�O�H�/�/�1�2���)�)�+�+�+r$c��vK� |�d{���y7�#tj$r|j��wxYw�wrB)r r�r�)r4rs r#�accept_coroz(IocpProactor.accept.<locals>.accept_coro3s2���� ������,�,� �� � ��� �s �9����9��%6�9r)r �_get_accept_socket�familyrgr r��AcceptExr�rr� ensure_futurer8)r r5r!r6r8r4�corors ` @r#�acceptzIocpProactor.accept$s����� � ��*��&�&�x���7�� � #� #�D� )�� ���H�O�O�%�t�{�{�}�5� ,� �����H�m�<���6�4�(�� ���D�t�z�z�2�� r$c����jtjk(rQtj�j�|�|jj�}|jd�|S|j�� tj�j��j�tj"t$�}|j'�j�|��fd�}|j)|�|�S#t$r?}|jtjk7r��j!�ddk(r�Yd}~��d}~wwxYw)Nrrc���|j��jtjtj d��SrX)r�r/rr0rg�SO_UPDATE_CONNECT_CONTEXT)r�rr!rs �r#�finish_connectz,IocpProactor.connect.<locals>.finish_connectVs1����L�L�N��O�O�F�-�-�'�A�A�1� F��Kr$)�typer� SOCK_DGRAMrg� WSAConnectr�r8r�rFr � BindLocalr:r7ri�errno� WSAEINVAL�getsocknamer r�� ConnectExr)r rr,rc�er!rBs ` r#�connectzIocpProactor.connect@s����9�9��)�)�)� �"�"�4�;�;�=�'�:��*�*�*�*�,�C��N�N�4� ��J�� � ��&� ��!�!�$�+�+�-����=�� #� #�D� )�� ���T�[�[�]�G�,� ��~�~�b�$��7�7��!� ��z�z�U�_�_�,�����!�!�$��)��*�� �s�.D� E � 5E�E c �6�|j|�tjt�}|dz}|dz dz}|j |j�t j|j��|||dd�|j|||j�S)Nl��� r) r rgr r��TransmitFiler��msvcrt� get_osfhandlerr)r �sock�file�offset�countr!� offset_low�offset_highs r#�sendfilezIocpProactor.sendfile_s���� � ��&� � #� #�D� )���k�)� ���|�{�2�� ������ ��,�,�T�[�[�]�;�"�K��q�!� %� �~�~�b�$��(?�(?�@�@r$c����|j��tjt�}|j �j��}|r|j ��S�fd�}|j|�|�S)Nc�(��|j��SrB)r�)r�rr!r�s �r#�finish_accept_pipez4IocpProactor.accept_pipe.<locals>.finish_accept_pipevs����L�L�N��Kr$)r rgr r��ConnectNamedPiper�r�r)r r�r!� connectedr[s ` r#r�zIocpProactor.accept_pipeksf���� � ��&� � #� #�D� )���'�'���� �6� ���<�<��%�%� ��~�~�b�$�(:�;�;r$c��<K�t} tj|�} tj|�S#t$r(}|jtj k7r�Yd}~nd}~wwxYwt |dzt�}tj|��d{���7���w)N�)�CONNECT_PIPE_INIT_DELAYrg�ConnectPiper7ri�ERROR_PIPE_BUSY�min�CONNECT_PIPE_MAX_DELAYr�sleepr r�)r r,�delayrUr:s r#r�zIocpProactor.connect_pipe|s�����'��� �$�0�0��9����'�'��/�/��� ��<�<�;�#>�#>�>��?�� �� ��� �#9�:�E��+�+�e�$�$�$��s6�B�6�B� A'�A"�B�"A'�'.B�B�Bc�(�|j||d�S)z�Wait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). F)�_wait_for_handle)r rUr�s r#�wait_for_handlezIocpProactor.wait_for_handle�s���$�$�V�W�e�<�<r$c�:�|j|dd�}||_|Sr�)rhrs)r rt� done_callbackrcs r#r�zIocpProactor._wait_cancel�s%���#�#�E�4��6��+���� r$c����|j�|�tj}ntj|dz�}tjt�}tj||j|j|�}|rt||||j���nt|||||j����jr �jd=�fd�}�|d|f|j|j<�S)N�@�@rrc�$���j�SrB)r])r�rr!r�s �r#�finish_wait_for_handlez=IocpProactor._wait_for_handle.<locals>.finish_wait_for_handle�s����7�7�9�r$r)r�rY�INFINITE�math�ceilrgr r��RegisterWaitWithQueuer�r,rqr8rzrr�) r rUr�� _is_cancel�msr!rVror�s @r#rhzIocpProactor._wait_for_handle�s���������?��!�!�B����7�S�=�)�B�� #� #�D� )��!�7�7��D�J�J�� � �B�0���!�"�f�k�� � �K�A�!�"�f�k�4�'+�z�z�3�A�����#�#�B�'� �$%�b�!�-C�"D����B�J�J���r$c��||jvrL|jj|�tj|j �|j dd�yyrX)rTr�rgr�r�r��r �objs r#r z IocpProactor._register_with_iocp�sI���d�&�&�&���� � ��%��.�.�s�z�z�|�T�Z�Z��A�N�'r$c�^�|j�t||j��}|jr |jd=|js |dd|�}|j|�||||f|j|j<|S#t$r}|j|�Yd}~�>d}~wwxYwr) r�rr8rr&rFr7rCr�r,)r r!rx�callbackr�r�rKs r#rzIocpProactor._register�s������� �b�t�z�z�2������#�#�B�'��z�z� $� ��t�R�0�����U�#�$%�b�#�x�"8����B�J�J������ #�����"�"�� #�s� B� B,�B'�'B,c�Z�|j�|jj|�y)a Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). N)r�r�ra)r r!s r#r�zIocpProactor._unregister�s$�� �������!�!�"�%r$c�R�tj|�}|jd�|SrX)rr2)r r:�ss r#r9zIocpProactor._get_accept_socket�s ���M�M�&�!�� ���Q���r$c �"�|�t}n<|dkrtd��tj|dz�}|tk\rtd�� t j |j|�}|�n�d}|\}}}} |jj|�\}} } }| |j vr|j#�nI|j%�s9 |||| �}|j'|�|j(j+|�d}��|j0D](} |jj| j2d��*|j0j5�y#t$rl|jj�r%|jjdd||||fzd��|dtjfvrtj|�Y��}wxYw#t,$r7} |j/| �|j(j+|�Yd} ~ ��d} ~ wwxYw#d}wxYw)Nrznegative timeoutrmztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r2�status)rp� ValueErrorrqrrrg�GetQueuedCompletionStatusr�r��pop�KeyErrorr8� get_debugr9r�rYr�r�r6�donerFr�rar7rCr�r,r�)r r�rur�err�transferredrr,r�r!rxrzr�rKs r#r]zIocpProactor._poll�s����?��B� �q�[��/�0�0����7�S�=�)�B��X�~� �!2�3�3�� �:�:�4�:�:�r�J�F��~���B�-3�*�C��c�7� �'+�{�{���w�'?�$��2�s�H� �d�+�+�+���� ��V�V�X� �$�[�#�r�:�E� �L�L��'��M�M�(�(��+��A�M�R�$�$�B��K�K�O�O�B�J�J��-�%���� � �"��E� ��:�:�'�'�)��J�J�5�5�%7�#N�&)�;��W�%E�$F�7���q�+�"B�"B�C�C��'�'��,�� ��,�,��O�O�A�&��M�M�(�(��+�+��,���A�sC�4 E� G�,H �A1G�G� H�,H�<H �H�H � Hc�:�|jj|�yrB)r�r�rws r#� _stop_servingzIocpProactor._stop_serving2s�� ���!�!�#�&r$c�4�|j�yt|jj��D]:\}}}}|j �r�t|t�r�* |j��<d}tj�}||z} |jrx| tj�krCtjd|tj�|z �tj�|z} |j!|�|jr�xg|_t%j&|j�d|_y#t$rS}|j�<d||d�}|jr|j|d<|jj|�Yd}~��ad}~wwxYw)NzCancelling a future failedr1r5g�?z,%r is running after closing for %.1f seconds)r��listr��values� cancelledrrqr6r7r8rr9�time� monotonicr�debugr]r�rYr�) r rcr!rxrzr:r;� msg_update� start_time�next_msgs r#r�zIocpProactor.close8s[���:�:���'+�4�;�;�+=�+=�+?�&@�"�C��S�(��}�}����C�!2�3��C��J�J�L�'A�0� ��^�^�%� �� �*���k�k��4�>�>�+�+����K�!�4�>�>�#3�j�#@�B��>�>�+�j�8�� �J�J�z�"��k�k��� ����D�J�J�'��� ��;� C��z�z�-�'C�),�&)�#�� �0�0�:=�:O�:O�G�$6�7�� � �9�9�'�B��� C�s�D;�; F�AF�Fc�$�|j�yrB)r�r\s r#r�zIocpProactor.__del__gs��� � �r$rB)rr!)%rIrJrKrLrprr�r�r�r�r��staticmethodr�classmethodrrrrr#r&r*r>rLrXr�r�rir�rhr rr�r9r]r�r�r�r�r$r#rr�s���-�#+�2�9�E�� �� ����� �� �A�A� C� A�A�A��88�> A�<�"0�&=�� �DO��@&�� 7#�r'�-�^r$rc��eZdZd�Zy)r�c ���tj|f|||||d�|���_�fd�}�jjjt �jj��} | j|�y)N)r�r�r�r�r�c�\���jj�}�j|�yrB)�_proc�poll�_process_exited)r�� returncoder s �r#rzz4_WindowsSubprocessTransport._start.<locals>.callbackrs!��������*�J�� � ��,r$) r �Popenr�r8r|ri�intrRr�) r r�r�r�r�r�r�r�rzr�s ` r#�_startz"_WindowsSubprocessTransport._startmso���"�(�(��'��U�6�&��'�%�'�� � -� �J�J� � �0�0��T�Z�Z�5G�5G�1H�I�� ���H�%r$N)rIrJrKr�r�r$r#r�r�ks�� &r$r�c��eZdZeZy)rN)rIrJrKr� _loop_factoryr�r$r#rr}���%�Mr$rc��eZdZeZy)rN)rIrJrKrr�r�r$r#rr�r�r$r)4rL�sys�platform�ImportErrorrgrYrG� functoolsrrqrPrr-r�r��rrrr r rrr �logr�__all__r�rp�ERROR_CONNECTION_REFUSED�ERROR_CONNECTION_ABORTEDr`rd�FuturerrPrqrz�objectr��BaseSelectorEventLoopr��BaseProactorEventLooprr�BaseSubprocessTransportr�r�BaseDefaultEventLoopPolicyrrrr�r$r#�<module>r�s\��4� ��<�<�7�� �l� #�#������ � � ���������������|�|���������� ����-����-�`G#�G�N�N�G#�T&�-�&�01P�-�1P�h8��8�v2�� E� E�2�g��=�=�g�TH�H�V&�/�"I�"I�&�.��&�V�%F�%F�&�&�V�%F�%F�&�8�r$__pycache__/windows_utils.cpython-312.opt-1.pyc000064400000016013151706172560015343 0ustar00� T��h����dZddlZejdk7red��ddlZddlZddlZddlZddlZddl Z ddl Z dZdZejZ ejZej�Zdded �d �ZGd�d�ZGd �dej&�Zy)z)Various Windows specific bits and pieces.�N�win32z win32 only)�pipe�Popen�PIPE� PipeHandlei F)TT)�duplex� overlapped�bufsizec ��tjdjtj�tt����}|r6tj}tjtjz}||}}n$tj}tj}d|}}|tjz}|dr|tjz}|drtj}nd}dx} } tj||tjd||tj tj"�} tj$||dtj"tj&|tj"�} tj(| d��}|j+d�| | fS#| �tj,| �| �tj,| ��xYw)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)�prefixr�NT�r )�tempfile�mktemp�format�os�getpid�next� _mmap_counter�_winapi�PIPE_ACCESS_DUPLEX�GENERIC_READ� GENERIC_WRITE�PIPE_ACCESS_INBOUND�FILE_FLAG_FIRST_PIPE_INSTANCE�FILE_FLAG_OVERLAPPED�CreateNamedPipe� PIPE_WAIT�NMPWAIT_WAIT_FOREVER�NULL� CreateFile� OPEN_EXISTING�ConnectNamedPipe�GetOverlappedResult�CloseHandle)rr r �address�openmode�access�obsize�ibsize�flags_and_attribs�h1�h2�ovs �./usr/lib64/python3.12/asyncio/windows_utils.pyrr s����o�o�1�8�8��I�I�K��m�,�.�/�G���-�-���%�%��(=�(=�=�� �'����.�.���&�&���G�����5�5�5�H��!�}��G�0�0�0���!�}�#�8�8�����N�B��� � $� $��X�w�0�0� �v�v�w�;�;�W�\�\�K��� � ��V�Q����g�.C�.C��w�|�|�-��� %� %�b�T� :�� ���t�$��2�v� ��� �>�����#� �>�����#� �s �*B6F!�!1Gc�|�eZdZdZd�Zd�Zed��Zd�Ze jd�d�Zejfd�Zd �Zd �Zy)rz�Wrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. c��||_y�N��_handle��self�handles r/�__init__zPipeHandle.__init__Vs �����c�x�|j�d|j��}nd}d|jj�d|�d�S)Nzhandle=�closed�<� �>)r4� __class__�__name__r5s r/�__repr__zPipeHandle.__repr__YsB���<�<�#��t�|�|�.�/�F��F��4�>�>�*�*�+�1�V�H�A�6�6r9c��|jSr2r3�r6s r/r7zPipeHandle.handle`s���|�|�r9c�H�|j�td��|jS)NzI/O operation on closed pipe)r4� ValueErrorrCs r/�filenozPipeHandle.filenods"���<�<���;�<�<��|�|�r9)r%c�P�|j�||j�d|_yyr2r3)r6r%s r/�closezPipeHandle.closeis$���<�<�#�����%��D�L�$r9c�b�|j�#|d|��t|��|j�yy)Nz unclosed )�source)r4�ResourceWarningrH)r6�_warns r/�__del__zPipeHandle.__del__ns-���<�<�#��I�d�X�&���E��J�J�L�$r9c��|Sr2�rCs r/� __enter__zPipeHandle.__enter__ss���r9c�$�|j�yr2)rH)r6�t�v�tbs r/�__exit__zPipeHandle.__exit__vs��� � �r9N)r@� __module__�__qualname__�__doc__r8rA�propertyr7rFrr%rH�warnings�warnrMrPrUrOr9r/rrQsR����7������ $+�#6�#6� � %�M�M�� �r9rc�$��eZdZdZd�fd� Z�xZS)rz�Replacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. c����dx}x}}dx} x} }|tk(r5tdd��\}} tj|tj �}n|}|tk(r&td��\} } tj| d�}n|}|tk(r&td��\}}tj|d�}n|tk(r|}n|} t�|� |f|||d�|��| �t| �|_ | �t| �|_|�t|�|_ |tk(rt j|�|tk(rt j|�|tk(rt j|�yy#| | |fD]}|��tj|���xYw#|tk(rt j|�|tk(rt j|�|tk(rt j|�wwxYw)N)FTT)r r)TFrr)�stdin�stdout�stderr)rr�msvcrt�open_osfhandler�O_RDONLY�STDOUT�superr8rr^r_r`rr%rH)r6�argsr^r_r`�kwds� stdin_rfd� stdout_wfd� stderr_wfd�stdin_wh� stdout_rh� stderr_rh�stdin_rh� stdout_wh� stderr_wh�hr?s �r/r8zPopen.__init__�s����/3�2� �2�J��+/�/��/�9�y��D�=�!%��t�!L��H�h��-�-�h����D�I��I��T�>�#'�=�#A� �I�y��.�.�y�!�<�J��J��T�>�#'�=�#A� �I�y��.�.�y�!�<�J� �v� �#�J��J� %��G��T� 8��:�$.� 8�26� 8��#�'��1�� ��$�(��3����$�(��3�����}�����#���~�����$���~�����$���# �� �9�5���=��'�'��*�6� ����}�����#���~�����$���~�����$��s%�=E$�7F�$F �1F � F�AG))NNN)r@rVrWrXr8� __classcell__)r?s@r/rr}s����+%�+%r9r)rX�sys�platform�ImportErrorr� itertoolsrar� subprocessrrZ�__all__�BUFSIZErrd�countrrrrrOr9r/�<module>r{s���/� ��<�<�7�� �l� #�#��� � ����0�������� � � ��� ���!� ��\�7�+�b&�&�X0%�J���0%r9__pycache__/windows_utils.cpython-312.opt-2.pyc000064400000015152151706172560015347 0ustar00� T��h���� ddlZejdk7red��ddlZddlZddlZddlZddlZddlZddl Z dZ dZejZejZ ej�Zdded�d �ZGd �d�ZGd�d ej$�Zy)�N�win32z win32 only)�pipe�Popen�PIPE� PipeHandlei F)TT)�duplex� overlapped�bufsizec �� tjdjtj�tt����}|r6tj}tjtjz}||}}n$tj}tj}d|}}|tjz}|dr|tjz}|drtj}nd}dx} } tj||tjd||tj tj"�} tj$||dtj"tj&|tj"�} tj(| d��}|j+d�| | fS#| �tj,| �| �tj,| ��xYw)Nz\\.\pipe\python-pipe-{:d}-{:d}-)�prefixr�T�r )�tempfile�mktemp�format�os�getpid�next� _mmap_counter�_winapi�PIPE_ACCESS_DUPLEX�GENERIC_READ� GENERIC_WRITE�PIPE_ACCESS_INBOUND�FILE_FLAG_FIRST_PIPE_INSTANCE�FILE_FLAG_OVERLAPPED�CreateNamedPipe� PIPE_WAIT�NMPWAIT_WAIT_FOREVER�NULL� CreateFile� OPEN_EXISTING�ConnectNamedPipe�GetOverlappedResult�CloseHandle)rr r �address�openmode�access�obsize�ibsize�flags_and_attribs�h1�h2�ovs �./usr/lib64/python3.12/asyncio/windows_utils.pyrr s���O��o�o�1�8�8��I�I�K��m�,�.�/�G���-�-���%�%��(=�(=�=�� �'����.�.���&�&���G�����5�5�5�H��!�}��G�0�0�0���!�}�#�8�8�����N�B��� � $� $��X�w�0�0� �v�v�w�;�;�W�\�\�K��� � ��V�Q����g�.C�.C��w�|�|�-��� %� %�b�T� :�� ���t�$��2�v� ��� �>�����#� �>�����#� �s �+B6F"�"1Gc�z�eZdZ d�Zd�Zed��Zd�Zejd�d�Z ejfd�Z d�Zd �Zy )rc��||_y�N��_handle��self�handles r/�__init__zPipeHandle.__init__Vs �����c�x�|j�d|j��}nd}d|jj�d|�d�S)Nzhandle=�closed�<� �>)r4� __class__�__name__r5s r/�__repr__zPipeHandle.__repr__YsB���<�<�#��t�|�|�.�/�F��F��4�>�>�*�*�+�1�V�H�A�6�6r9c��|jSr2r3�r6s r/r7zPipeHandle.handle`s���|�|�r9c�H�|j�td��|jS)NzI/O operation on closed pipe)r4� ValueErrorrCs r/�filenozPipeHandle.filenods"���<�<���;�<�<��|�|�r9)r%c�P�|j�||j�d|_yyr2r3)r6r%s r/�closezPipeHandle.closeis$���<�<�#�����%��D�L�$r9c�b�|j�#|d|��t|��|j�yy)Nz unclosed )�source)r4�ResourceWarningrH)r6�_warns r/�__del__zPipeHandle.__del__ns-���<�<�#��I�d�X�&���E��J�J�L�$r9c��|Sr2�rCs r/� __enter__zPipeHandle.__enter__ss���r9c�$�|j�yr2)rH)r6�t�v�tbs r/�__exit__zPipeHandle.__exit__vs��� � �r9N)r@� __module__�__qualname__r8rA�propertyr7rFrr%rH�warnings�warnrMrPrUrOr9r/rrQsR����7������ $+�#6�#6� � %�M�M�� �r9rc�"��eZdZ d�fd� Z�xZS)rc����dx}x}}dx} x} }|tk(r5tdd��\}} tj|tj �}n|}|tk(r&td��\} } tj| d�}n|}|tk(r&td��\}}tj|d�}n|tk(r|}n|} t�|� |f|||d�|��| �t| �|_ | �t| �|_|�t|�|_ |tk(rt j|�|tk(rt j|�|tk(rt j|�yy#| | |fD]}|��tj|���xYw#|tk(rt j|�|tk(rt j|�|tk(rt j|�wwxYw)N)FTT)r r)TFrr)�stdin�stdout�stderr)rr�msvcrt�open_osfhandler�O_RDONLY�STDOUT�superr8rr]r^r_rr%rH)r6�argsr]r^r_�kwds� stdin_rfd� stdout_wfd� stderr_wfd�stdin_wh� stdout_rh� stderr_rh�stdin_rh� stdout_wh� stderr_wh�hr?s �r/r8zPopen.__init__�s����/3�2� �2�J��+/�/��/�9�y��D�=�!%��t�!L��H�h��-�-�h����D�I��I��T�>�#'�=�#A� �I�y��.�.�y�!�<�J��J��T�>�#'�=�#A� �I�y��.�.�y�!�<�J� �v� �#�J��J� %��G��T� 8��:�$.� 8�26� 8��#�'��1�� ��$�(��3����$�(��3�����}�����#���~�����$���~�����$���# �� �9�5���=��'�'��*�6� ����}�����#���~�����$���~�����$��s%�=E$�7F�$F �1F � F�AG))NNN)r@rVrWr8� __classcell__)r?s@r/rr}s����+%�+%r9r)�sys�platform�ImportErrorr� itertoolsr`r� subprocessrrY�__all__�BUFSIZErrc�countrrrrrOr9r/�<module>rzs���/� ��<�<�7�� �l� #�#��� � ����0�������� � � ��� ���!� ��\�7�+�b&�&�X0%�J���0%r9__pycache__/windows_utils.cpython-312.pyc000064400000016247151706172560014415 0ustar00� T��h����dZddlZejdk7red��ddlZddlZddlZddlZddlZddl Z ddl Z dZdZejZ ejZej�Zdded �d �ZGd�d�ZGd �dej&�Zy)z)Various Windows specific bits and pieces.�N�win32z win32 only)�pipe�Popen�PIPE� PipeHandlei F)TT)�duplex� overlapped�bufsizec ��tjdjtj�tt����}|r6tj}tjtjz}||}}n$tj}tj}d|}}|tjz}|dr|tjz}|drtj}nd}dx} } tj||tjd||tj tj"�} tj$||dtj"tj&|tj"�} tj(| d��}|j+d�| | fS#| �tj,| �| �tj,| ��xYw)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)�prefixr�NT�r )�tempfile�mktemp�format�os�getpid�next� _mmap_counter�_winapi�PIPE_ACCESS_DUPLEX�GENERIC_READ� GENERIC_WRITE�PIPE_ACCESS_INBOUND�FILE_FLAG_FIRST_PIPE_INSTANCE�FILE_FLAG_OVERLAPPED�CreateNamedPipe� PIPE_WAIT�NMPWAIT_WAIT_FOREVER�NULL� CreateFile� OPEN_EXISTING�ConnectNamedPipe�GetOverlappedResult�CloseHandle)rr r �address�openmode�access�obsize�ibsize�flags_and_attribs�h1�h2�ovs �./usr/lib64/python3.12/asyncio/windows_utils.pyrr s����o�o�1�8�8��I�I�K��m�,�.�/�G���-�-���%�%��(=�(=�=�� �'����.�.���&�&���G�����5�5�5�H��!�}��G�0�0�0���!�}�#�8�8�����N�B��� � $� $��X�w�0�0� �v�v�w�;�;�W�\�\�K��� � ��V�Q����g�.C�.C��w�|�|�-��� %� %�b�T� :�� ���t�$��2�v� ��� �>�����#� �>�����#� �s �*B6F!�!1Gc�|�eZdZdZd�Zd�Zed��Zd�Ze jd�d�Zejfd�Zd �Zd �Zy)rz�Wrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. c��||_y�N��_handle��self�handles r/�__init__zPipeHandle.__init__Vs �����c�x�|j�d|j��}nd}d|jj�d|�d�S)Nzhandle=�closed�<� �>)r4� __class__�__name__r5s r/�__repr__zPipeHandle.__repr__YsB���<�<�#��t�|�|�.�/�F��F��4�>�>�*�*�+�1�V�H�A�6�6r9c��|jSr2r3�r6s r/r7zPipeHandle.handle`s���|�|�r9c�H�|j�td��|jS)NzI/O operation on closed pipe)r4� ValueErrorrCs r/�filenozPipeHandle.filenods"���<�<���;�<�<��|�|�r9)r%c�P�|j�||j�d|_yyr2r3)r6r%s r/�closezPipeHandle.closeis$���<�<�#�����%��D�L�$r9c�b�|j�#|d|��t|��|j�yy)Nz unclosed )�source)r4�ResourceWarningrH)r6�_warns r/�__del__zPipeHandle.__del__ns-���<�<�#��I�d�X�&���E��J�J�L�$r9c��|Sr2�rCs r/� __enter__zPipeHandle.__enter__ss���r9c�$�|j�yr2)rH)r6�t�v�tbs r/�__exit__zPipeHandle.__exit__vs��� � �r9N)r@� __module__�__qualname__�__doc__r8rA�propertyr7rFrr%rH�warnings�warnrMrPrUrOr9r/rrQsR����7������ $+�#6�#6� � %�M�M�� �r9rc�$��eZdZdZd�fd� Z�xZS)rz�Replacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. c�,��|jd�rJ�|jdd�dk(sJ�dx}x}}dx} x} }|tk(r5tdd��\}} tj|t j�}n|}|tk(r&td��\} } tj| d�}n|}|tk(r&td��\}}tj|d�}n|tk(r|}n|} t�|�$|f|||d �|��| �t| �|_| �t| �|_|�t|�|_ |tk(rtj |�|tk(rtj |�|tk(rtj |�yy#| | |fD]}|��tj|���xYw#|tk(rtj |�|tk(rtj |�|tk(rtj |�wwxYw) N�universal_newlinesr r)FTT)r r)TFr)�stdin�stdout�stderr)�getrr�msvcrt�open_osfhandler�O_RDONLY�STDOUT�superr8rr_r`rarr%rH)r6�argsr_r`ra�kwds� stdin_rfd� stdout_wfd� stderr_wfd�stdin_wh� stdout_rh� stderr_rh�stdin_rh� stdout_wh� stderr_wh�hr?s �r/r8zPopen.__init__�s�����8�8�0�1�1�1��x�x� �1�%��*�*�*�.2�2� �2�J��+/�/��/�9�y��D�=�!%��t�!L��H�h��-�-�h����D�I��I��T�>�#'�=�#A� �I�y��.�.�y�!�<�J��J��T�>�#'�=�#A� �I�y��.�.�y�!�<�J� �v� �#�J��J� %��G��T� 8��:�$.� 8�26� 8��#�'��1�� ��$�(��3����$�(��3�����}�����#���~�����$���~�����$���# �� �9�5���=��'�'��*�6� ����}�����#���~�����$���~�����$��s%�'F�;7F6�F3�F3�3F6�6AH)NNN)r@rVrWrXr8� __classcell__)r?s@r/rr}s����+%�+%r9r)rX�sys�platform�ImportErrorr� itertoolsrcr� subprocessrrZ�__all__�BUFSIZErrf�countrrrrrOr9r/�<module>r}s���/� ��<�<�7�� �l� #�#��� � ����0�������� � � ��� ���!� ��\�7�+�b&�&�X0%�J���0%r9__pycache__/__init__.cpython-312.opt-2.pyc000064400000002577151706172560014203 0ustar00� T��h���� ddlZddl�ddl�ddl�ddl�ddl�ddl�ddl�ddl�ddl �ddl �ddl�ddl�ddl �ddl�ddl�ddl�ej"ej"zej"zej"zej"zej"zej"zej"ze j"ze j"zej"zej"ze j"zej"zej"zej"zZej$dk(rddl�eej"z Zyddl�eej"z Zy)�N�)�*�win32)�sys�base_events� coroutines�events� exceptions�futures�locks� protocols�runners�queues�streams� subprocess�tasks� taskgroups�timeouts�threads� transports�__all__�platform�windows_events�unix_events���)/usr/lib64/python3.12/asyncio/__init__.py�<module>rsZ��-��������������������������>�>�������?�?� � �=�=����� ��?�?���>�>���?�?� ���� ��=�=�������?�?� ����������"�<�<�7��!��~�%�%�%�G���{�"�"�"�Gr__pycache__/__main__.cpython-312.opt-1.pyc000064400000012521151706172560014151 0ustar00� T��h� ��j�ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlmZGd�dej�ZGd�dej�Zedk(r�ej$d �ej&�Zej*e�d eiZdD]Ze�eee<�eee�Zdada ddlZe�Zd e_ejA� ejC�yy#e$rY�9wxYw#e"$r3t4r*t4jG�st4jI�d aY�VwxYw)�N�)�futuresc�$��eZdZ�fd�Zd�Z�xZS)�AsyncIOInteractiveConsolec����t�|�|�|jjxjt jzc_||_tj�|_ y)N)�super�__init__�compile�compiler�flags�ast�PyCF_ALLOW_TOP_LEVEL_AWAIT�loop�contextvars�copy_context�context)�self�localsr� __class__s ��)/usr/lib64/python3.12/asyncio/__main__.pyr z"AsyncIOInteractiveConsole.__init__sH��� ���� ������#�#�s�'E�'E�E�#��� �"�/�/�1���c�8����tjj�����fd�}tj |�j �� �j �S#t$r�t$r,tr�jd�Yy�j�YywxYw)Nc�&��dadatj��j�} |�}tj|�s�j|�y �jj|�j��atj t��y#t $r�t$r}da�j|�Yd}~yd}~wt$r}�j|�Yd}~yd}~wwxYw#t$r}�j|�Yd}~yd}~wwxYw)NFT�r)�repl_future�repl_future_interrupted�types�FunctionTyper� SystemExit�KeyboardInterrupt� set_exception� BaseException�inspect�iscoroutine� set_resultr�create_taskrr� _chain_future)�func�coro�ex�exc�code�futurers ���r�callbackz3AsyncIOInteractiveConsole.runcode.<locals>.callbacks�����K�&+�#��%�%�d�D�K�K�8�D� ��v���&�&�t�,��!�!�$�'�� *�"�i�i�3�3�D�$�,�,�3�O���%�%�k�6�:��!� ��$� �*.�'��$�$�R�(��� � ��$�$�R�(��� ��!� *��$�$�S�)�)�� *�s<�B�AC,�C)�*C�C)�C$�$C)�, D�5D�Drz KeyboardInterrupt )� concurrentr�Futurer�call_soon_threadsafer�resultrr"r�write� showtraceback)rr,r.r-s`` @r�runcodez!AsyncIOInteractiveConsole.runcodes|����#�#�*�*�,�� *�< �!�!�(�D�L�L�!�A� %��=�=�?�"��� ��� %�&�� � �2�3��"�"�$� %�s�A�)B�B�B)�__name__� __module__�__qualname__r r5� __classcell__)rs@rrrs ���2�+%rrc��eZdZd�Zy)� REPLThreadc �� dtj�dtj�dttdd��d�}tj|d��t jd d t��tjtj�y#t jd d t��tjtj�wxYw)Nz asyncio REPL z on zy Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. �ps1z>>> zimport asynciozexiting asyncio REPL...)�banner�exitmsg�ignorez ^coroutine .* was never awaited$)�message�category)�sys�version�platform�getattr�console�interact�warnings�filterwarnings�RuntimeWarningrr1�stop)rr>s r�runzREPLThread.runGs��� 1�����}�D�����?*��3��v�.�/�~� ?� � ����1� � 3� �#�#��;�'� )� �%�%�d�i�i�0�� �#�#��;�'� )� �%�%�d�i�i�0�s �AB�ACN)r6r7r8rM�rrr;r;Es��1rr;�__main__zcpython.run_stdin�asyncio>�__file__r6�__spec__� __loader__�__package__�__builtins__FT)%r rPr,�concurrent.futuresr/rr#rC� threadingrrI�r�InteractiveConsoler�Threadr;r6�audit�new_event_loopr�set_event_loop�repl_locals�keyrrGrr�readline�ImportError�repl_thread�daemon�start�run_foreverr �done�cancelrNrr�<module>rhsP�� ������ �����3%�� 7� 7�3%�l1��!�!�1�0�z�� �C�I�I�!�"�!�7�!�!�#�D��G���4� ��g�&�K�,��"�8�C�=��C��,� (��T�:�G��K�#�� ���,�K��K������ � ����� �G��&� �� ��!� ��;�#3�#3�#5��"�"�$�*.�'�� �s$�9C/�C:�/C7�6C7�:5D2�1D2__pycache__/__main__.cpython-312.opt-2.pyc000064400000012521151706172560014152 0ustar00� T��h� ��j�ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlmZGd�dej�ZGd�dej�Zedk(r�ej$d �ej&�Zej*e�d eiZdD]Ze�eee<�eee�Zdada ddlZe�Zd e_ejA� ejC�yy#e$rY�9wxYw#e"$r3t4r*t4jG�st4jI�d aY�VwxYw)�N�)�futuresc�$��eZdZ�fd�Zd�Z�xZS)�AsyncIOInteractiveConsolec����t�|�|�|jjxjt jzc_||_tj�|_ y)N)�super�__init__�compile�compiler�flags�ast�PyCF_ALLOW_TOP_LEVEL_AWAIT�loop�contextvars�copy_context�context)�self�localsr� __class__s ��)/usr/lib64/python3.12/asyncio/__main__.pyr z"AsyncIOInteractiveConsole.__init__sH��� ���� ������#�#�s�'E�'E�E�#��� �"�/�/�1���c�8����tjj�����fd�}tj |�j �� �j �S#t$r�t$r,tr�jd�Yy�j�YywxYw)Nc�&��dadatj��j�} |�}tj|�s�j|�y �jj|�j��atj t��y#t $r�t$r}da�j|�Yd}~yd}~wt$r}�j|�Yd}~yd}~wwxYw#t$r}�j|�Yd}~yd}~wwxYw)NFT�r)�repl_future�repl_future_interrupted�types�FunctionTyper� SystemExit�KeyboardInterrupt� set_exception� BaseException�inspect�iscoroutine� set_resultr�create_taskrr� _chain_future)�func�coro�ex�exc�code�futurers ���r�callbackz3AsyncIOInteractiveConsole.runcode.<locals>.callbacks�����K�&+�#��%�%�d�D�K�K�8�D� ��v���&�&�t�,��!�!�$�'�� *�"�i�i�3�3�D�$�,�,�3�O���%�%�k�6�:��!� ��$� �*.�'��$�$�R�(��� � ��$�$�R�(��� ��!� *��$�$�S�)�)�� *�s<�B�AC,�C)�*C�C)�C$�$C)�, D�5D�Drz KeyboardInterrupt )� concurrentr�Futurer�call_soon_threadsafer�resultrr"r�write� showtraceback)rr,r.r-s`` @r�runcodez!AsyncIOInteractiveConsole.runcodes|����#�#�*�*�,�� *�< �!�!�(�D�L�L�!�A� %��=�=�?�"��� ��� %�&�� � �2�3��"�"�$� %�s�A�)B�B�B)�__name__� __module__�__qualname__r r5� __classcell__)rs@rrrs ���2�+%rrc��eZdZd�Zy)� REPLThreadc �� dtj�dtj�dttdd��d�}tj|d��t jd d t��tjtj�y#t jd d t��tjtj�wxYw)Nz asyncio REPL z on zy Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. �ps1z>>> zimport asynciozexiting asyncio REPL...)�banner�exitmsg�ignorez ^coroutine .* was never awaited$)�message�category)�sys�version�platform�getattr�console�interact�warnings�filterwarnings�RuntimeWarningrr1�stop)rr>s r�runzREPLThread.runGs��� 1�����}�D�����?*��3��v�.�/�~� ?� � ����1� � 3� �#�#��;�'� )� �%�%�d�i�i�0�� �#�#��;�'� )� �%�%�d�i�i�0�s �AB�ACN)r6r7r8rM�rrr;r;Es��1rr;�__main__zcpython.run_stdin�asyncio>�__file__r6�__spec__� __loader__�__package__�__builtins__FT)%r rPr,�concurrent.futuresr/rr#rC� threadingrrI�r�InteractiveConsoler�Threadr;r6�audit�new_event_loopr�set_event_loop�repl_locals�keyrrGrr�readline�ImportError�repl_thread�daemon�start�run_foreverr �done�cancelrNrr�<module>rhsP�� ������ �����3%�� 7� 7�3%�l1��!�!�1�0�z�� �C�I�I�!�"�!�7�!�!�#�D��G���4� ��g�&�K�,��"�8�C�=��C��,� (��T�:�G��K�#�� ���,�K��K������ � ����� �G��&� �� ��!� ��;�#3�#3�#5��"�"�$�*.�'�� �s$�9C/�C:�/C7�6C7�:5D2�1D2__pycache__/__main__.cpython-312.pyc000064400000012521151706172560013212 0ustar00� T��h� ��j�ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlmZGd�dej�ZGd�dej�Zedk(r�ej$d �ej&�Zej*e�d eiZdD]Ze�eee<�eee�Zdada ddlZe�Zd e_ejA� ejC�yy#e$rY�9wxYw#e"$r3t4r*t4jG�st4jI�d aY�VwxYw)�N�)�futuresc�$��eZdZ�fd�Zd�Z�xZS)�AsyncIOInteractiveConsolec����t�|�|�|jjxjt jzc_||_tj�|_ y)N)�super�__init__�compile�compiler�flags�ast�PyCF_ALLOW_TOP_LEVEL_AWAIT�loop�contextvars�copy_context�context)�self�localsr� __class__s ��)/usr/lib64/python3.12/asyncio/__main__.pyr z"AsyncIOInteractiveConsole.__init__sH��� ���� ������#�#�s�'E�'E�E�#��� �"�/�/�1���c�8����tjj�����fd�}tj |�j �� �j �S#t$r�t$r,tr�jd�Yy�j�YywxYw)Nc�&��dadatj��j�} |�}tj|�s�j|�y �jj|�j��atj t��y#t $r�t$r}da�j|�Yd}~yd}~wt$r}�j|�Yd}~yd}~wwxYw#t$r}�j|�Yd}~yd}~wwxYw)NFT�r)�repl_future�repl_future_interrupted�types�FunctionTyper� SystemExit�KeyboardInterrupt� set_exception� BaseException�inspect�iscoroutine� set_resultr�create_taskrr� _chain_future)�func�coro�ex�exc�code�futurers ���r�callbackz3AsyncIOInteractiveConsole.runcode.<locals>.callbacks�����K�&+�#��%�%�d�D�K�K�8�D� ��v���&�&�t�,��!�!�$�'�� *�"�i�i�3�3�D�$�,�,�3�O���%�%�k�6�:��!� ��$� �*.�'��$�$�R�(��� � ��$�$�R�(��� ��!� *��$�$�S�)�)�� *�s<�B�AC,�C)�*C�C)�C$�$C)�, D�5D�Drz KeyboardInterrupt )� concurrentr�Futurer�call_soon_threadsafer�resultrr"r�write� showtraceback)rr,r.r-s`` @r�runcodez!AsyncIOInteractiveConsole.runcodes|����#�#�*�*�,�� *�< �!�!�(�D�L�L�!�A� %��=�=�?�"��� ��� %�&�� � �2�3��"�"�$� %�s�A�)B�B�B)�__name__� __module__�__qualname__r r5� __classcell__)rs@rrrs ���2�+%rrc��eZdZd�Zy)� REPLThreadc �� dtj�dtj�dttdd��d�}tj|d��t jd d t��tjtj�y#t jd d t��tjtj�wxYw)Nz asyncio REPL z on zy Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. �ps1z>>> zimport asynciozexiting asyncio REPL...)�banner�exitmsg�ignorez ^coroutine .* was never awaited$)�message�category)�sys�version�platform�getattr�console�interact�warnings�filterwarnings�RuntimeWarningrr1�stop)rr>s r�runzREPLThread.runGs��� 1�����}�D�����?*��3��v�.�/�~� ?� � ����1� � 3� �#�#��;�'� )� �%�%�d�i�i�0�� �#�#��;�'� )� �%�%�d�i�i�0�s �AB�ACN)r6r7r8rM�rrr;r;Es��1rr;�__main__zcpython.run_stdin�asyncio>�__file__r6�__spec__� __loader__�__package__�__builtins__FT)%r rPr,�concurrent.futuresr/rr#rC� threadingrrI�r�InteractiveConsoler�Threadr;r6�audit�new_event_loopr�set_event_loop�repl_locals�keyrrGrr�readline�ImportError�repl_thread�daemon�start�run_foreverr �done�cancelrNrr�<module>rhsP�� ������ �����3%�� 7� 7�3%�l1��!�!�1�0�z�� �C�I�I�!�"�!�7�!�!�#�D��G���4� ��g�&�K�,��"�8�C�=��C��,� (��T�:�G��K�#�� ���,�K��K������ � ����� �G��&� �� ��!� ��;�#3�#3�#5��"�"�$�*.�'�� �s$�9C/�C:�/C7�6C7�:5D2�1D2__pycache__/base_events.cpython-312.opt-1.pyc000064400000251165151706172560014740 0ustar00� T��h�2��6�dZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlZddlZddl Z ddlZddlZddlZddlZ ddlZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZddlmZddlmZdd lmZddlmZddlm 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!ejb�Z2Gd"�d#ejf�Z4Gd$�d%ejj�Z6y#e$rdZY��wxYw)(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)�timeouts)� 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 �,/usr/lib64/python3.12/asyncio/base_events.py�_format_handler Gs=�� � � �B��'�"�j�$�/����<��B�K�K� � ��6�{��c�h�|tjk(ry|tjk(ryt|�S)Nz<pipe>z<stdout>)� subprocess�PIPE�STDOUTr)�fds r�_format_piper'Ps+�� �Z�_�_��� �z� � � ���B�x�r!c���ttd�std�� |jtjtj d�y#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_reuseportr2Ys`���6�>�*��D�E�E� J��O�O�F�-�-�v�/B�/B�A�F��� J��I�J� J� J�s�/A � A"c �P�ttd�sy|dtjtjhvs|�y|tjk(rtj}n%|tj k(rtj}ny|�d}n<t |t�r|dk(rd}n$t |t�r|dk(rd}n t|�}|tjk(r7tjg}tr#|jtj �n|g}t |t�r|j#d�}d|vry|D]I} tj$||�tr |tj k(r |||d||||ffcS|||d||ffcSy#ttf$rYywxYw#t&$rY�mwxYw)N� inet_ptonrr!��idna�%)r*r+�IPPROTO_TCP�IPPROTO_UDP�SOCK_STREAM� SOCK_DGRAMr�bytesr�int� TypeErrorr,� AF_UNSPEC�AF_INET� _HAS_IPv6�appendr�decoder4r/) �host�port�family�type�proto�flowinfo�scopeid�afs�afs r�_ipaddr_inforMds����6�;�'���Q��*�*�F�,>�,>�?�?��L���v�!�!�!��"�"�� ��"�"� "��"�"����|��� �D�%� �T�S�[��� �D�#� �4�2�:��� ��t�9�D���!�!�!��~�~�����J�J�v���'��h���$����{�{�6�"�� �d�{���� ����R��&��R�6�?�?�2��4���T�4��7�,K�K�K��4���T�4�L�8�8����;�:�&� �� ��2� �� �s*�7F�;9F�7F�F�F� F%�$F%c��tj�}|D]$}|d}||vrg||<||j|��&t|j ��}g}|dkDr%|j|dd|dz �|dd|dz �=|jd�tjjt j|��D��|S)z-Interleave list of addrinfo tuples by family.rrNc3�$K�|]}|�|��� y�w�N�)�.0�as r� <genexpr>z(_interleave_addrinfos.<locals>.<genexpr>�s!����� �a� �]� � �s�) �collections�OrderedDictrB�list�values�extend� itertools�chain� from_iterable�zip_longest)� addrinfos�first_address_family_count�addrinfos_by_family�addrrF�addrinfos_lists� reordereds r�_interleave_addrinfosrd�s���&�1�1�3�����a����,�,�*,���'��F�#�*�*�4�0� � �.�5�5�7�8�O��I�!�A�%������+�,K�-G�!�-K�L�M��A��>� :�Q� >�>�?� �����?�?�0�0��!�!�?�3� ����r!c��|j�s'|j�}t|ttf�rytj|�j�yrP)� cancelled� exceptionr� SystemExit�KeyboardInterruptr� _get_loop�stop)�fut�excs r�_run_until_complete_cbrn�sB���=�=�?��m�m�o���c�J�(9�:�;� ����c����!r!�TCP_NODELAYc�4�|jtjtjhvrl|jtj k(rN|jtjk(r0|jtjtjd�yyyy�Nr) rFr+r@rrGr:rHr8r-ror0s r�_set_nodelayrr�sj���K�K�F�N�N�F�O�O�<�<�� � �V�/�/�/�� � �f�0�0�0��O�O�F�.�.��0B�0B�A�F�1�0� =r!c��yrPrQr0s rrrrr�s��r!c�\�t�&t|tj�rtd��yy)Nz"Socket cannot be of type SSLSocket)�sslr� SSLSocketr>r0s r�_check_ssl_socketrw�s'�� ��:�d�C�M�M�:��<�=�=�;�r!c�B�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zy )�_SendfileFallbackProtocolc��t|tj�std��||_|j�|_|j�|_|j|_ |j�|j|�|jr*|jjj�|_yd|_y)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����&�*�">�">�?��L�M�M� ����)�)�+���&,�&7�&7�&9��#�&,�&=�&=��#��������D�!��&�&�$(�O�O�$9�$9�$G�$G�$I�D�!�$(�D�!r!c��K�|jj�rtd��|j}|�y|�d{���y7��w)NzConnection closed by peer)r|� is_closing�ConnectionErrorr�)r�rls r�drainz_SendfileFallbackProtocol.drain�s<�����?�?�%�%�'�!�"=�>�>��#�#���;��� � �s�:A�A�Ac��td��)Nz?Invalid state: connection should have been established already.��RuntimeError)r�� transports r�connection_madez)_SendfileFallbackProtocol.connection_made�s���N�O� Or!c���|j�B|�%|jjtd��n|jj|�|jj |�y)NzConnection is closed by peer)r�� set_exceptionr�r~�connection_lost)r�rms rr�z)_SendfileFallbackProtocol.connection_lost�s[��� � �,��{��%�%�3�3�#�$B�C�E��%�%�3�3�C�8����#�#�C�(r!c�p�|j�y|jjj�|_yrP)r�r|r�r��r�s r� pause_writingz'_SendfileFallbackProtocol.pause_writing�s,��� � �,�� $��� 5� 5� C� C� E��r!c�b�|j�y|jjd�d|_y)NF)r�� set_resultr�s r�resume_writingz(_SendfileFallbackProtocol.resume_writing�s-��� � �(�����(�(��/� $��r!c��td���Nz'Invalid state: reading should be pausedr�)r��datas r� data_receivedz'_SendfileFallbackProtocol.data_received����D�E�Er!c��td��r�r�r�s r�eof_receivedz&_SendfileFallbackProtocol.eof_receivedr�r!c��<K�|jj|j�|jr|jj �|j �|j j �|jr|jj�yy�wrP) r|r�r~r��resume_readingr��cancelr�r�r�s r�restorez!_SendfileFallbackProtocol.restoress�������$�$�T�[�[�1��&�&��O�O�*�*�,�� � �,� �!�!�(�(�*��&�&��K�K�&�&�(�'�s�BBN)�__name__� __module__�__qualname__r�r�r�r�r�r�r�r�r�rQr!rryry�s3��)��O� )�F� %�F�F� )r!ryc�h�eZdZ dd�Zd�Zd�Zd�Zd�Zd�Zd�Z d �Z ed ��Zd�Z d�Zd �Zd�Zy)rNc��||_||_d|_g|_||_||_||_||_||_d|_ d|_ y)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__sU���� ��� ������ �!1����� �'���&;��#�%9��"��� �$(��!r!c�P�d|jj�d|j�d�S)N�<z sockets=�>)� __class__r�r�r�s r�__repr__zServer.__repr__#s'���4�>�>�*�*�+�9�T�\�\�4D�A�F�Fr!c�.�|xjdz c_yrq)r�r�s r�_attachzServer._attach&s�����a��r!c��|xjdzc_|jdk(r|j�|j�yyy)Nrr)r�r��_wakeupr�s r�_detachzServer._detach*s;�����a�������"�t�}�}�'<��L�L�N�(=�"r!c�|�|j}d|_|D]$}|j�r�|jd��&yrP)r��doner�)r��waiters�waiters rr�zServer._wakeup0s3���-�-���� ��F��;�;�=��!�!�$�'�r!c �*�|jryd|_|jD]p}|j|j�|jj|j||j||j|j|j��ry)NT) r�r��listenr�r��_start_servingr�r�r�r�)r�r1s rr�zServer._start_serving7sp���=�=���� ��M�M�D��K�K�� � �&��J�J�%�%��&�&��d�.?�.?��d�m�m�T�%@�%@��*�*� ,�"r!c��|jSrP)r�r�s r�get_loopzServer.get_loopBs���z�z�r!c��|jSrP)r�r�s r� is_servingzServer.is_servingEs���}�}�r!c�T�|j�ytd�|jD��S)NrQc3�FK�|]}tj|����y�wrP)r�TransportSocket)rR�ss rrTz!Server.sockets.<locals>.<genexpr>Ls����F� �1�V�+�+�A�.� �s�!)r��tupler�s rr�zServer.socketsHs$���=�=� ���F�� � �F�F�Fr!c�P�|j}|�yd|_|D]}|jj|��d|_|j�;|jj�s!|jj �d|_|jdk(r|j�yy)NFr) r�r�� _stop_servingr�r�r�r�r�r�)r�r�r1s r�closezServer.closeNs����-�-���?���� ��D��J�J�$�$�T�*���� ��%�%�1��-�-�2�2�4��%�%�,�,�.�(,�D�%�����"��L�L�N�#r!c��jK�|j�tjd��d{���y7��w)Nr)r�r�sleepr�s r� start_servingzServer.start_servingas%���������k�k�!�n���s�)3�1�3c��K�|j�td|�d���|j�td|�d���|j�|jj�|_ |j�d{��� d|_y7� #tj$r1 |j�|j��d{���7�#�xYwwxYw#d|_wxYw�w)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���$��!M�N�P� P��=�=� ����� �;�<�<�����$(�J�J�$<�$<�$>��!� -��+�+�+�+�)-�D�%� ,���(�(� � �� � ���&�&�(�(�(����� ��)-�D�%�s`�A&C�)B�8B�9B�>C�B�C�#C�?C�C�C�C�C�C� C�Cc��K�|j�y|jj�}|jj|�|�d{���y7��w)a�Wait until server is closed and all connections are dropped. - If the server is not closed, wait. - If it is closed, but there are still active connections, wait. Anyone waiting here will be unblocked once both conditions (server is closed and all connections have been dropped) have become true, in either order. Historical note: In 3.11 and before, this was broken, returning immediately if the server was already closed, even if there were still active connections. An attempted fix in 3.12.0 was still broken, returning immediately if the server was still open and there were no active connections. Hopefully in 3.12.1 we have it right. N)r�r�r�rB)r�r�s rr�zServer.wait_closed|s@����*�=�=� �����)�)�+��� � ���V�$����s�AA� A�ArP)r�r�r�r�r�r�r�r�r�r�r��propertyr�r�r�r�r�rQr!rrrs[��>B�)�G� ��(� ,����G��G� �&�-�*r!rc��eZdZd�Zd�Zd�Zddd�d�Zd�Zd�Zd\ddd �d �Z d\dddddddd �d�Z d]d�Z d^d�Z d^d�Z d\d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd\d�Zd�Zd�Zd�Zd�Zd�Zd �Zd!�Zej>fd"�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`dd4�d5�Z/d6�Z0d7�Z1d8�Z2d\d9�Z3 d^dd0d0d0ddddddddd:�d;�Z4 dad<�Z5d`dd4�d=�Z6d>�Z7d?�Z8ddddd@�dA�Z9 d^d0d0d0ddddB�dC�Z:d0e;jxd0d0d1�dD�Z=dE�Z> d^e;j~e;j�ddFdddddddG� dH�ZAddddI�dJ�ZBdK�ZCdL�ZDdM�ZEeFj�eFj�eFj�ddd0ddddN� dO�ZHeFj�eFj�eFj�ddd0ddddN� dP�ZIdQ�ZJdR�ZKdS�ZLdT�ZMdU�ZNdV�ZOdW�ZPdX�ZQdY�ZRdZ�ZSd[�ZTy)brc���d|_d|_d|_tj�|_g|_d|_d|_d|_ tjd�j|_ d|_|jt!j"��d|_d|_d|_d|_d|_t/j0�|_d|_d|_y)NrF� monotonicg�������?)�_timer_cancelled_count�_closed� _stoppingrU�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�!4�[�!A�!L�!L���"&������z�0�0�2�3�'*��#�#���!���27��/�6:��3�"�/�/�+���*/��'�).��&r!c ��d|jj�d|j��d|j��d|j ��d� S)Nr�z running=z closed=z debug=r�)r�r�� is_running� is_closed� get_debugr�s rr�zBaseEventLoop.__repr__�sP������'�'�(� �$�/�/�2C�1D�E��n�n�&�'�w�t�~�~�/?�.@�� 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�2�|j�|j�3tj||||��}|jrM|jd=n?|�|j||�}n|j|||��}tj ||� |~S#~wxYw)zDSchedule a coroutine object. Return a task object. )r�rr ����r )� _check_closedr�rr�_source_traceback�_set_task_name)r��cororr �tasks r�create_taskzBaseEventLoop.create_task�s��� �������%��:�:�d��D�'�J�D��%�%��*�*�2�.����)�)�$��5���)�)�$��g�)�F��� � ��t�,� �����s�B�Bc�B�|�t|�std��||_y)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�s%����x��'8��E�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�r1�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�r1r�addressr�rs r�_make_datagram_transportz&BaseEventLoop._make_datagram_transport�r r!c��t�)zCreate read pipe transport.r�r��piperr�rs r�_make_read_pipe_transportz'BaseEventLoop._make_read_pipe_transportr r!c��t�)zCreate write pipe transport.rr,s r�_make_write_pipe_transportz(BaseEventLoop._make_write_pipe_transportr r!c ��K�t��w)zCreate subprocess transport.r) r�r�args�shell�stdin�stdout�stderr�bufsizer�kwargss r�_make_subprocess_transportz(BaseEventLoop._make_subprocess_transports����"�!�s� 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_selfs ��"�!r!c��t�)zProcess selector events.r)r�� event_lists r�_process_eventszBaseEventLoop._process_eventss��!�!r!c�2�|jrtd��y)NzEvent loop is closed)r�r�r�s rr zBaseEventLoop._check_closeds���<�<��5�6�6�r!c�2�|jrtd��y)Nz!Executor shutdown has been called)rr�r�s r�_check_default_executorz%BaseEventLoop._check_default_executor#s���)�)��B�C�C�*r!c��|jj|�|j�s+|j|j|j��yyrP)r��discardr�call_soon_threadsafer�aclose�r��agens r�_asyncgen_finalizer_hookz&BaseEventLoop._asyncgen_finalizer_hook's?��������%��~�~���%�%�d�&6�&6���� �F� r!c��|jr tjd|�d�t|��|jj|�y)Nzasynchronous generator z3 was scheduled after loop.shutdown_asyncgens() call��source)r��warnings�warn�ResourceWarningr��addrFs r�_asyncgen_firstiter_hookz&BaseEventLoop._asyncgen_firstiter_hook,sA���*�*��M�M�)�$��21�2��� .� �����D�!r!c��K�d|_t|j�syt|j�}|jj �tj|D�cgc]}|j���c}ddi��d{���}t||�D].\}}t|t�s�|jd|��||d���0ycc}w7�G�w)z,Shutdown all active asynchronous generators.TN�return_exceptionsz;an error occurred during closing of asynchronous generator )�messagerg�asyncgen)r��lenr�rW�clearr�gatherrE�zipr� Exception�call_exception_handler)r�� closing_agens�ag�results�resultrGs r�shutdown_asyncgensz BaseEventLoop.shutdown_asyncgens5s�����*.��'��4�?�?�#� ��T�_�_�-� ����������$1� 2�M�b�b�i�i�k�M� 2�$�"�$�$�� ���7�L�F�D��&�)�,��+�+�"9�9=�� B�!'� $� -��8��3�$�s$�A C �"C�9 C �C�&C �+!C c��K�d|_|j�y|j�}tj|j |f��}|j � tj|�4�d{���|�d{���ddd��d{���|j�y7�/7�'7�#1�d{���7swY�)xYw#t$r?tjd|�d�td��|jjd� �YywxYw�w) aSchedule the shutdown of the default executor. The timeout parameter specifies the amount of time the executor will be given to finish joining. The default value is None, which means that the executor will be given an unlimited amount of time. TN)�targetr2z:The executor did not finishing joining its threads within z seconds.�)� stacklevelF��wait)rr�r�� threading�Thread�_do_shutdown�startr �timeout�join�TimeoutErrorrLrM�RuntimeWarning�shutdown)r�rj�future�threads r�shutdown_default_executorz'BaseEventLoop.shutdown_default_executorNs�����*.��&��!�!�)���#�#�%���!�!��):�):�&��K������ ��'�'��0�0����1�0� �K�K�M�1����1��0�0�0��� 8��M�M�0�07�y� �C�(�Q� 8� �"�"�+�+��+�7� 8�s��AD �B>�3B#�4B>�7B)�=B%�>B)�B>� B'�B>�D �#B>�%B)�'B>�)B;�/B2�0B;�7B>�>AD�D �D�D c�Z� |jjd��|j�s"|jtj |d�yy#t$rP}|j�s6|j�s!|j|j|�Yd}~yYd}~yYd}~yd}~wwxYw)NTrd) r�rnrrDr�_set_result_unless_cancelledrYrfr�)r�ro�exs rrhzBaseEventLoop._do_shutdownfs��� D��"�"�+�+��+�6��>�>�#��)�)�'�*N�*N�*0�$�8�$��� D��>�>�#�F�,<�,<�,>��)�)�&�*>�*>��C�C�-?�#�� D�s�A A� B*�<B%�%B*c�x�|j�rtd��tj��td��y)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_runningps>���?�?���C�D�D��#�#�%�1��I�K� K�2r!c��|j�|j�|j|j�t j �} t j�|_t j|j|j��tj|� |j�|jrn� d|_d|_tjd�|jd�t j|�y#d|_d|_tjd�|jd�t j|�wxYw)zRun until stop() is called.)� firstiter� finalizerFN)r rw�_set_coroutine_origin_tracking�_debug�sys�get_asyncgen_hooksrf� get_identr��set_asyncgen_hooksrPrHr�_set_running_loop� _run_oncer�)r��old_agen_hookss r�run_foreverzBaseEventLoop.run_foreverws�����������+�+�D�K�K�8��/�/�1�� 4�'�1�1�3�D�O��"�"�T�-J�-J�-1�-J�-J� L� �$�$�T�*����� ��>�>����"�D�N�"�D�O��$�$�T�*��/�/��6��"�"�N�3�� #�D�N�"�D�O��$�$�T�*��/�/��6��"�"�N�3�s�A8D�AEc� �|j�|j�tj|�}t j ||��}|rd|_|jt� |j� |jt�|j�std��|j�S#|r0|j�r |j�s|j��xYw#|jt�wxYw)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 rwr�isfuturer� ensure_future�_log_destroy_pending�add_done_callbackrnr�r�rfrg�remove_done_callbackr�r^)r�ro�new_tasks r�run_until_completez BaseEventLoop.run_until_complete�s��� ���������'�'��/�/���$�$�V�$�7���+0�F�'�� � �!7�8� @����� �'�'�(>�?��{�{�}��L�M�M��}�}���� ��F�K�K�M�&�2B�2B�2D�� � �"����'�'�(>�?�s�-B>�>5C3�3C6�6D c��d|_y)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 rrkzBaseEventLoop.stop�s����r!c�l�|j�rtd��|jry|jrt j d|�d|_|jj�|jj�d|_ |j}|�d|_ |jd��yy)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 %rTFrd)rr�r�r|r�debugr�rVr�rr�rn�r��executors rr�zBaseEventLoop.close�s����?�?���B�C�C��<�<���;�;��L�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��|j�s4|d|��t|��|j�s|j�yyy)Nzunclosed event loop rJ)rrNrr�)r��_warns r�__del__zBaseEventLoop.__del__�s=���~�~���(���1�?�4�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|j�|z|g|��d|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. zdelay must not be Noner r)r>�call_atr�r)r��delay�callbackr r2�timers r� call_laterzBaseEventLoop.call_later�s_�� �=��4�5�5�����T�Y�Y�[�5�0�(�.�T�.�%,�.���"�"��'�'��+��r!c�N�|�td��|j�|jr"|j�|j |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. zwhen cannot be Noner�rT)r>r r|� _check_thread�_check_callbackr�TimerHandler�heapq�heappushr�)r��whenr�r r2r�s rr�zBaseEventLoop.call_ats��� �<��1�2�2������;�;���� �� � ��9�5��"�"�4��4��w�G���"�"��'�'��+� ���t����.�����r!c���|j�|jr"|j�|j|d�|j |||�}|j r |j d=|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 r|r�r�� _call_soonr�r�r�r r2rs rr�zBaseEventLoop.call_soonsa�� �����;�;���� �� � ��;�7�����4��9���#�#��(�(��,�� r!c��tj|�stj|�rtd|�d���t |�std|�d|����y)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_callback(sg���"�"�8�,��.�.�x�8��1�&���<�>� >���!��4�V�H�=��l�$�%� %�"r!c��tj||||�}|jr |jd=|jj |�|S)Nr)r�Handlerr�rB)r�r�r2r rs rr�zBaseEventLoop._call_soon2sD�����x��t�W�=���#�#��(�(��,������6�"�� r!c�z�|j�ytj�}||jk7rtd��y)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�rfrr�)r�� thread_ids rr�zBaseEventLoop._check_thread9sB���?�?�"���'�'�)� �����'��'�(� (�(r!c���|j�|jr|j|d�|j|||�}|jr |jd=|j�|S)z"Like call_soon(), but thread-safe.rDr)r r|r�r�rr;r�s rrDz"BaseEventLoop.call_soon_threadsafeJs`�������;�;�� � ��+A�B�����4��9���#�#��(�(��,������ r!c�<�|j�|jr|j|d�|�E|j}|j �|�'t jjd��}||_t j|j|g|���|��S)N�run_in_executor�asyncio)�thread_name_prefixr) r r|r�r�rA� concurrentr�ThreadPoolExecutor�wrap_future�submit)r�r��funcr2s rr�zBaseEventLoop.run_in_executorUs��������;�;�� � ��'8�9����-�-�H��(�(�*���%�-�-�@�@�'0�A���*2��&��"�"��H�O�O�D�(�4�(�t�5� 5r!c�p�t|tjj�st d��||_y)Nz,executor must be ThreadPoolExecutor instance)rr�rr�r>r�r�s r�set_default_executorz"BaseEventLoop.set_default_executores,���(�J�$6�$6�$I�$I�J��J�K�K�!)��r!c�"�|�d|��g}|r|jd|���|r|jd|���|r|jd|���|r|jd|���dj|�}tjd|�|j �}tj||||||�} |j �|z } d|�d | d zd�d| ��}| |jk\rtj|�| Stj|�| S) N�:zfamily=ztype=zproto=zflags=�, zGet address info %szGetting address info z took g@�@z.3fzms: ) rBrkrr�r�r+�getaddrinfor��info)r�rDrErFrGrH�flags�msg�t0�addrinfo�dts r�_getaddrinfo_debugz BaseEventLoop._getaddrinfo_debugjs����q���!�"����J�J��� �+�,���J�J��t�h�'�(���J�J���y�)�*���J�J���y�)�*��i�i��n�����*�C�0� �Y�Y�[���%�%�d�D�&�$��u�M�� �Y�Y�[�2� ��%�c�U�&��c��#��d�8�,�O�� ��,�,�,��K�K����� �L�L����r!r�rFrGrHr�c ��K�|jr |j}ntj}|j d|||||||��d{���S7��wrP)r|r�r+r�r�)r�rDrErFrGrHr��getaddr_funcs rr�zBaseEventLoop.getaddrinfo�sU�����;�;��2�2�L�!�-�-�L��)�)��,��d�F�D�%��H�H� H�H�s�AA�A�Ac��bK�|jdtj||��d{���S7��wrP)r�r+�getnameinfo)r��sockaddrr�s rr�zBaseEventLoop.getnameinfo�s2�����)�)��&�$�$�h��7�7� 7�7�s�&/�-�/)�fallbackc��ZK�|jr|j�dk7rtd��t|�|j ||||� |j||||��d{���S7�#tj$r }|s�Yd}~nd}~wwxYw|j||||��d{���7S�w)Nrzthe socket must be non-blocking) r|� gettimeoutr,rw�_check_sendfile_params�_sock_sendfile_nativer�SendfileNotAvailableError�_sock_sendfile_fallback)r�r1�file�offset�countr�rms r� sock_sendfilezBaseEventLoop.sock_sendfile�s������;�;�4�?�?�,��1��>�?�?��$���#�#�D�$���>� ��3�3�D�$�4:�E�C�C� C�C���3�3� ����� ���1�1�$��28�%�A�A�A� A�sN�A B+� A+�$A)�%A+�(B+�)A+�+B�>B�B+�B�B+�%B(�&B+c��BK�tjd|�d|�d����w)Nz-syscall sendfile is not available for socket z and file z combination�rr��r�r1r�r�r�s rr�z#BaseEventLoop._sock_sendfile_native�s4�����2�2�;�D�8�D��x�|� -�.� .�s�c��8K�|r|j|�|rt|tj�ntj}t |�}d} |rt||z |�}|dkrnYt|�d|}|j d|j|��d{���} | sn#|j||d| ��d{���|| z }�p||dkDr"t|d�r|j||z�SSS7�S7�5#|dkDr"t|d�r|j||z�wwwxYw�w)Nr�seek) r��minr�!SENDFILE_FALLBACK_READBUFFER_SIZE� bytearray� memoryviewr��readinto�sock_sendallr*) r�r1r�r�r�� blocksize�buf� total_sent�view�reads rr�z%BaseEventLoop._sock_sendfile_fallback�s1������I�I�f��� ��y�B�B�C�#�E�E� �� �"��� � /��� #�E�J�$6� � B�I� �A�~��!�#��z� �2��!�1�1�$�� � �t�L�L�����'�'��d�5�D�k�:�:�:��d�"� ����A�~�'�$��"7�� � �&�:�-�.�#8�~�M��;���A�~�'�$��"7�� � �&�:�-�.�#8�~�sC�A D�AC.�C*�C.�6C,�7C.�(D�*C.�,C.�.)D�Dc��dt|dd�vrtd��|jtjk(std��|�It|t�stdj|���|dkrtdj|���t|t�stdj|���|dkrtdj|���y)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,rGr+r:rr=r>�formatr�s rr�z$BaseEventLoop._check_sendfile_params�s����g�d�F�C�0�0��C�D�D��y�y�F�.�.�.��J�K�K����e�S�)��A�H�H��O�Q�Q���z� �A�H�H��O�Q�Q��&�#�&��B�I�I���� ��A�:��B�I�I���� �r!c���K�g}|j|�|\}}}}} d} tj|||��} | jd�|�G|D]!\}}}}}||k7r� | j|�n"|r|j��t d|�d���|j| | ��d{���| dx}}S#t$rP} d|�dt| �j ���}t | j|�} |j| �Yd} ~ ��d} ~ wwxYw7�f#t$r)} |j| �| �| j��d} ~ w| �| j��xYw#dx}}wxYw�w)z$Create, bind and connect one socket.N�rFrGrHF�*error while attempting to bind on address �: z&no matching local address with family=z found)rBr+�setblocking�bindr/r�lower�errno�pop�sock_connectr�)r�r� addr_info�local_addr_infos� my_exceptionsrF�type_rH�_r)r1�lfamily�laddrrmr�s r� _connect_sockzBaseEventLoop._connect_sock�s������ �� ���-�(�+4�(���u�a����# .��=�=��U�%�H�D����U�#��+�/?�+�G�Q��1�e��&�(� � 2�� � �%�(�� 0@�%�+�/�/�1�1�%�(O��y�PV�&W�X�X��#�#�D�'�2�2�2��*.�-�J���1#�2�'�',�i�r�#�c�(�.�.�2B�1C�E��&�c�i�i��5��%�,�,�S�1�1�� 2�� 3��� �� � ��%���� � ���� ���� � ����)-�-�J��sk�E#�<D�B4�09D�)D�*D�/E#�4 D �=AD�D�D � D� E�$D?�?E�E�E � E#)rurFrHr�r1� local_addrr"r�r��happy_eyeballs_delay� interleave� all_errorsc��B����K�| � |std��| �|r|std��|} |� |std��|� |std��|�t|�| �|�d}|�|���|�td���j||f|tj||����d{���}|std ��| �:�j| |tj||����d{�����s td ��d�|rt ||�}g�| �%|D]} �j�|���d{���}n0n.tj���fd �|D�| ����d{���d}|�ʉD��cgc]}|D]}|��� c}}� |rtd ���t��dk(r�d�t�d��t�fd��D��r�d�tdjdjd��D�����|�td��|j tjk7rtd|�����j#|||| ||���d{���\}}�j$r+|j'd�}t)j*d|||||�||fS7���7���7��f#t $rY���wxYw7��Jcc}}w#d�wxYw7�k�w)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�rFrGrHr�r��!getaddrinfo() returned empty listc3�0�K�|] }|f���fd� ���y�w)c�*���j�|��SrP)r�)r�r�laddr_infosr�s ���r�<lambda>z;BaseEventLoop.create_connection.<locals>.<genexpr>.<lambda>]s���$�2D�2D�&��+�3r!NrQ)rRr�rrr�s ���rrTz2BaseEventLoop.create_connection.<locals>.<genexpr>Zs'������).�H�)1���).�s�rrzcreate_connection failedc3�:�K�|]}t|��k(���y�wrP�r)rRrm�models �rrTz2BaseEventLoop.create_connection.<locals>.<genexpr>ps�����G�J�S�s�3�x�5�0�J�s�zMultiple exceptions: {}r�c3�2K�|]}t|����y�wrPr)rRrms rrTz2BaseEventLoop.create_connection.<locals>.<genexpr>us����%E�*�3�c�#�h�*�s�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,rw�_ensure_resolvedr+r:r/rdr�r�staggered_race�ExceptionGrouprUr�allr�rkrG�_create_connection_transportr|�get_extra_inforr�)r�r�rDrErurFrHr�r1r�r"r�r�rrr�infosr��subrmr�rrrrs` @@@r�create_connectionzBaseEventLoop.create_connectionsq�����(�&�s��J�K�K��"�s�� �"A�B�B�"�O� �,�S��C�E� E� �+�C��B�D� D����d�#��+� �0B��J���t�/��� �N�P�P��/�/��t��V��'�'�u�E��0�N�N�E���A�B�B��%�$(�$9�$9��v��+�+�5��d�%:�%,�,��#�!�"E�F�F�"���-�e�Z�@���J�#�+� %�H�!�%)�%7�%7�&��+�&?� ?��� !&�(�6�6��).� �)��������|�-7�G�Z�c�3�C�c�3�c�Z�G� �&�!�,�-G��T�T��:��!�+�(��m�+�!$�J�q�M� 2���G�J�G�G�",�Q�-�/�&�&?�&F�&F� �I�I�%E�*�%E�E�'G�H�H��|� �K�M�M��y�y�F�.�.�.�!�8���A�C�C�%)�$E�$E��"�C��"7�!5�%F�%7�7�� �8��;�;��+�+�H�5�D��L�L�:��t�T�9�h� @��(�"�"�mN��,��" ?��#�!� �!����H�� "&�J�� 7�s��BJ�I4�;J�I7�*J�>I=�I:�I=�*J�J �J�J�"J�'A8J�AJ�1J�2AJ�7J�:I=�= J �J� J � J�J�J�Jc ��.K�|jd�|�}|j�} |r.t|t�rdn|} |j ||| | ||||��}n|j||| �} | �d{���||fS7�#|j ��xYw�w)NF�r!r"r�r�)r�r�r�boolr'rr�)r�r1r�rur"r!r�r�rr�r&r�s rrz*BaseEventLoop._create_connection_transport�s����� �����#�%���#�#�%���!+�C��!6��C�J��0�0��h� �F�'��&;�%9� 1�;�I��3�3�D�(�F�K�I� ��L�L� �(�"�"� �� ��O�O���s0�A,B�/A?�4A=�5A?�9B�=A?�?B�Bc��K�|j�rtd��t|dtjj �}|tjj urtd|����|tjjur |j||||��d{���S|std|����|j||||��d{���S7�0#tj$r }|s�Yd}~�Id}~wwxYw7�)�w)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�rms r�sendfilezBaseEventLoop.sendfile�s����0���!��5�6�6��y�"8� �.�.�:�:�<���9�*�*�6�6�6��:�9�-�H�J� J��9�*�*�5�5�5� �!�2�2�9�d�39�5�B�B�B���+�+4�-�9�:� :��,�,�Y��-3�U�<�<� <�B���7�7� ��� �� ��<�sN�BC9� C�!C�"C�%(C9� C7�C9�C�C4�'C/�*C9�/C4�4C9c��4K�tjd���w)Nz!sendfile syscall is not supportedr�)r�r�r�r�r�s rr#zBaseEventLoop._sendfile_native�s�����2�2�/�1� 1�s�c��K�|r|j|�|rt|d�nd}t|�}d}t|�} |rSt||z |�}|dkr?||dkDr t |d�r|j||z�|j��d{���St |�d|} |jd|j| ��d{���} | s?||dkDr t |d�r|j||z�|j��d{���S|j| d| �|j��d{���|| z }��7��7�y7�;7�#|dkDr t |d�r|j||z�|j��d{���7wxYw�w)Ni@rr�)r�r�r�ryr*r�r�r�r��writer�)r�r�r�r�r�r�r�r�rHr�r�s rr$z BaseEventLoop._sendfile_fallback�sx������I�I�f��).�C��u�%�E� �� �"��� �)�&�1�� "��� #�E�J�$6� � B�I� �A�~�)��A�~�'�$��"7�� � �&�:�-�.��-�-�/�!�!�"�#��z� �2��!�1�1�$�� � �t�L�L���%� �A�~�'�$��"7�� � �&�:�-�.��-�-�/�!�!� ���T�%�4�[�)��k�k�m�#�#��d�"� �� "��M�� "��$���A�~�'�$��"7�� � �&�:�-�.��-�-�/�!�!�s��<F�E�8F�D;�F�.E�D=�E�8F�D?�F� 'E�0E�1 E�;F�=E�?F�E�9F�<E?�=F�Frc��nK�t�td��t|tj�st d|����t|dd�st d|�d���|j �}tj||||||||d�� } |j�|j| �|j| j|�} |j|j�} |�d{���| j"S7�#t$r2|j�| j!�|j!��wxYw�w) 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#)rur�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��*�c�n�n�5���!�n�&�'� '��y�"9�5�A���Y�M�)I�J�L� L��#�#�%���+�+��(�J����"7�!5�!&�(�� ���!����|�,��^�^�L�$@�$@�)�L� ��N�N�9�#;�#;�<� � ��L�L��*�*�*� ��� ��O�O����������� �s0�CD5�C7�$C5�%C7�)D5�5C7�7;D2�2D5)rFrHr�� reuse_port�allow_broadcastr1c ��DK�| ��| jtjk(rtd| ����|s|s |s|s|s|s|rGt |||||||��} djd�| j �D��}td|�d���| jd�d}�nb|s|s|d k(rtd ��||fdff} �n�ttd�r�|tjk(r�||fD] }|��t|t�r�td ��|rO|d dvrH tjtj|�j �rtj"|�||f||fff} n�i}d |fd|ffD]�\}}|�� t|t,�rt/|�dk(std��|j1||tj2|||���d{���}|st'd��|D]\}}}}}||f}||vrddg||<||||<�!��|j �D��cgc]\}}|r|d �|r|d�||f��} }}| std��g}| D]�\\}}\}}d} d} tj|tj2|��} |rt5| �|r/| j7tj8tj:d�| jd�|r| j=|�|r|s|j?| |��d{���|}n|d �|�}|jE�}|jG| |||�}|jHr4|rt)jJd||||�nt)jLd|||� |�d{���||fS#t$$rY��0t&$r"}t)j*d||�Yd}~��Ud}~wwxYw7���cc}}w7��#t&$r/}| �| jA�|jB|�Yd}~���d}~w| �| jA��xYw7��#|jA��xYw�w)zCreate datagram connection.Nz$A datagram socket was expected, got )r��remote_addrrFrHr�r3r4r�c3�6K�|]\}}|s� |�d|�����y�w)�=NrQ)rR�k�vs rrTz9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>=s!����$N�L�D�A�q�A��s�!�A�3�Z�L�s� �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: %rrrbz2-tuple is expectedrrzcan not get address informationr�z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))'rGr+r:r,�dictrk�itemsr�r*r=rrr>�stat�S_ISSOCK�os�st_mode�remove�FileNotFoundErrorr/r�errorr�rUrr;r2r-r.�SO_BROADCASTr�r�r�rBr�r*r|r�r�) r�r�r�r6rFrHr�r3r4r1�opts�problems�r_addr�addr_pairs_infora�err� addr_infos�idxr�famr��pror)�key� addr_pairr� local_address�remote_addressrmrr�r�s r�create_datagram_endpointz&BaseEventLoop.create_datagram_endpoint+s��������y�y�F�.�.�.� �:�4�(�C�E�E��k��e�u��/��z�{�#)��e�'1�,;�=�� �9�9�$N�D�J�J�L�$N�N�� �0�08�z��<�=�=� ���U�#��F��+��Q�;�$�%@�A�A�%+�U�O�\�#B�"D�����+��&�.�.�0H�'��5�D��'� �4��0E�'�(<�=�=�6��*�Q�-�{�"B� 6��=�=�����)<�)D�)D�E��I�I�j�1�&,�U�O�%/��$=�$?�#B�� � �#$�j�/�A�{�3C�!D�I�C���'� *�4�� 7�C��I��N�"+�,A�"B�B�&*�&;�&;� ��f�6G�6G�"'�u�4�'<�'A�!A�� %�")�*M�"N�N�7<�3�C��C��G�#&��*�C�"�*�4�37��,� �3��3:�J�s�O�C�0� 8=�"E�&<F�;K�;K�;M�#E�;M���i�'�I�a�L�,@�(�Y�q�\�-A��)�$�;M� �#E� '�$�%F�G�G��J�6E�2��&�%�0�-�������!�=�=�%�F�,=�,=�U�L�D�!�&�t�,�&����"�-�-�v�/B�/B�A�G��$�$�U�+�!�� � �-�0�"�.�"&�"3�"3�D�.�"I�I�I�!/���96E�<!��m�#�#�%���#�#�%���1�1��(�F�F�,� ��;�;�����0�&��Y��J����(�(�)�X�?� ��L�L� �(�"�"��}-���"�6����&5�%/��6�6��6�� !A��#E�8J���+��'�� � ��%�J�%�%�c�*�*����'�� � ����* �� ��O�O���s��C!P �$P �5P �AM6�P �/AP �N/�A P �N2�'$P �B!N:�-N8�.N:�4A3P �(P �-P�.P �2P �6 N,�?P �N,� N'�!P �'N,�,P �2P �8N:�: P�$O-�'P �-P�P �P � P�P c��K�|dd\}}t|||||g|dd���} | �| gS|j||||||���d{���S7��w)Nrbr�)rMr�) r�r)rFrGrHr�r�rDrEr�s rrzBaseEventLoop._ensure_resolved�st�����R�a�[� ��d��D�$���e�J�g�a�b�k�J�����6�M��)�)�$��V�$�05�U�*�D�D� D�D�s�;A�A�Ac��K�|j||f|tj||���d{���}|std|�d���|S7��w)N)rFrGr�r�zgetaddrinfo(z) returned empty list)rr+r:r/)r�rDrErFr�rs r�_create_server_getaddrinfoz(BaseEventLoop._create_server_getaddrinfo�s]�����+�+�T�4�L��17�1C�1C�27�d�,�D�D����L���0E�F�G�G���D�s�*A�A�Ar) rFr�r1r�ru� reuse_addressr3r�r�r�c ��K�t|t�rtd��|� |�td��|� |�td��|�t |�|�|��"|�td��| �(t jdk(xrtjdk7} g}|dk(rdg}n:t|t�s$t|tjj�s|g}n|}|D�cgc]}|j||||� ���}}tj|��d{���}t!t"j$j'|��}d } |D]�}|\}}}}} t)j(|||�}|j3|�| r/|j5t(j6t(j8d�| r-|t(j:t(j<fvrt?|�t@rR|t(j<k(r?tCt(d�r/|j5t(jDt(jFd� |jI|���|stKd|D�cgc]}|d�� c}����d}|sS|D]}|jU��n;|�td��|jVt(jXk7rtd|����|g}|D]}|j[d ��t]|||||||�}| r-|j_�tj`d��d{���|j,rt/jbd|�|Scc}w7��+#t(j*$r*|j,rt/j0d|||d� �Y��8wxYw#tJ$r�}d|�dt|�jM���}|jNtNjPk(rG|jS�|jU�|j,rt/j0|�Yd}~���tK|jN|�d�d}~wwxYwcc}w#|s|D]}|jU��wwxYw7��@�w)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 NoneNrrr�posix�cygwinr5)rFr�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 �z)Neither host/port nor sock were specifiedrrz %r is serving)2rrr>r,rwrCrr}�platformrrU�abc�IterablerYrrW�setrZr[r\r+rGr|r�warningrBr-r.�SO_REUSEADDRr@rr2rAr*r`�IPV6_V6ONLYr�r/r�r�� EADDRNOTAVAILr�r�rGr:r�rr�r�r�)r�r�rDrErFr�r1r�rurZr3r�r�r�r��hosts�fsr� completed�resrL�socktyperH� canonname�sarMr�r�rs r� create_serverzBaseEventLoop.create_server�s����8�c�4� ��H�I�I� �,����C�E� E� �+����B�D� D����d�#���t�/��� �N�P�P��$� "���7� 2� O�s�|�|�x�7O� ��G��r�z�����T�3�'� ��{���'?�'?�@������$�%�#�d��1�1�$��V�8=�2�?�#� �%� �,�,��+�+�E�� ���5�5�e�<�=�E��I�4 %� �C�9<�6�B��%��B�!�%�}�}�R��5�A���N�N�4�(�$����"�-�-�v�/B�/B�D�J�"�b�V�^�^�V�_�_�,M�&M�&�t�,�"��&�/�/�1�#�F�N�;�����(;�(;�(.�(:�(:�(,�.� @�� � �"� �;!�V�!�:?�%@�%�$�d�1�g�%�%@�#C�D�D�!� � � '��� � ��!(��|� �!L�M�M��y�y�F�.�.�.� �#E�d�X�!N�O�O��f�G��D����U�#����g�'7��W�&;�,�.����!�!�#��+�+�a�.� � ��;�;��K�K���0�� ��c%�,��"�<�<�!��;�;�"�N�N�,G�+-�x���O�!� !��4#�@�#%�c�#�h�n�n�&6� 8���9�9��(;�(;�;�#�K�K�M� �J�J�L�#�{�{� &���s� 3�$�%�c�i�i��5�4�?��@��&A��!� '��� � ��!(�!��( !�s��CQ�L'�*Q�L,�.Q�1 P�?L/�C P� M/�1P�?P �P�B(Q�>P>�?.Q�/9M,�(P�+M,�,P�/ P�8A=P�5P�;P�P�P�P;�;Q)rur�r�c ��rK�|jtjk7rtd|����|� |std��|� |std��|�t |�|j|||dd||���d{���\}}|jr)|jd�}tjd|||�||fS7�@�w) Nrrrr5T)r!r�r�r+z%r handled: (%r, %r)) rGr+r:r,rwrr|rrr�)r�r�r1rur�r�r�rs r�connect_accepted_socketz%BaseEventLoop.connect_accepted_socketRs����� �9�9��*�*�*��A�$��J�K�K� �,�S��C�E� E� �+�C��B�D� D����d�#�$(�$E�$E��"�C���"7�!5�%F�%7�7�� �8��;�;��+�+�H�5�D��L�L�/��y�(�K��(�"�"�7�s�A2B7�4B5�5AB7c��K�|�}|j�}|j|||�} |�d{���|jr&t j d|j �||�||fS7�:#|j��xYw�w)Nz Read pipe %r connected: (%r, %r))r�r.r�r|rr��fileno�r�r�r-rr�r�s r�connect_read_pipezBaseEventLoop.connect_read_pipeps�����#�%���#�#�%���2�2�4��6�J� � ��L�L� �;�;��L�L�;����� �8� =��(�"�"� �� ��O�O����+�+B�A0�A.�A0�6B�.A0�0B�Bc��K�|�}|j�}|j|||�} |�d{���|jr&t j d|j �||�||fS7�:#|j��xYw�w)Nz!Write pipe %r connected: (%r, %r))r�r0r�r|rr�rurvs r�connect_write_pipez BaseEventLoop.connect_write_pipe�s�����#�%���#�#�%���3�3�D�(�F�K� � ��L�L� �;�;��L�L�<����� �8� =��(�"�"� �� ��O�O���rxc�r�|g}|�|jdt|����|�1|tjk(r|jdt|����n>|�|jdt|����|�|jdt|����t j dj |��y)Nzstdin=zstdout=stderr=zstdout=zstderr=� )rBr'r#r%rr�rk)r�r�r4r5r6r�s r�_log_subprocesszBaseEventLoop._log_subprocess�s����u�����K�K�&��e�!4� 5�6�7���&�J�,=�,=�"=��K�K�.��f�)=�(>�?�@��!����g�l�6�&:�%;�<�=��!����g�l�6�&:�%;�<�=����S�X�X�d�^�$r!) r4r5r6�universal_newlinesr3r7�encoding�errors�textc ���K�t|ttf�std��|rtd��|std��|dk7rtd��|rtd��| �td��| �td��|�} d}|jrd |z}|j||||�|j| |d ||||fi|���d{���}|jr|�tjd||�|| fS7�-�w)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,r|r}r9rr�)r�r��cmdr4r5r6r~r3r7rr�r�r8r� debug_logr�s r�subprocess_shellzBaseEventLoop.subprocess_shell�s�����#��s�|�,��3�4�4���?�@�@���1�2�2��a�<��0�1�1���1�2�2����4�5�5����2�3�3�#�%��� ��;�;�/��4�I�� � ��E�6�6�B�9�$�9�9��c�4�����K�CI�K�K� ��;�;�9�0��K�K��)�Y�7��(�"�"� K�s�B=C/�?C-�.C/c ��K�|rtd��|rtd��|dk7rtd��|rtd��| �td��| �td��|f|z}|�}d}|jrd|��}|j||||�|j||d ||||fi| ���d{���}|jr|�t j d ||�||fS7�-�w)Nr�zshell must be Falserr�r�r�r�zexecute program Fr�)r,r|r}r9rr�)r�r��programr4r5r6r~r3r7rr�r�r2r8� popen_argsrr�r�s r�subprocess_execzBaseEventLoop.subprocess_exec�s������?�@�@���2�3�3��a�<��0�1�1���1�2�2����4�5�5����2�3�3��Z�$�&� �#�%��� ��;�;�+�7�+�6�I�� � ��E�6�6�B�9�$�9�9��j�%��������� ��;�;�9�0��K�K��)�Y�7��(�"�"��s�B"C�$C�%.Cc��|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�H�|�t|�std|����||_y)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�s5����x��'8��#�#*�+�/�0� 0�")��r!c���|jd�}|sd}|jd�}|�t|�||jf}nd}d|vr;|j�/|jjr|jj|d<|g}t|�D]�}|dvr�||}|dk(r:d j tj|��}d }||j�z }nJ|dk(r:d j tj|��}d}||j�z }nt|�}|j|�d|�����tjd j |�|��y)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()`. rSz!Unhandled exception in event looprgNF�source_traceback�handle_traceback>rSrgr5z+Object created at (most recent call last): z+Handle created at (most recent call last): r�� r^)�getrG� __traceback__r�r�sortedrk� traceback�format_list�rstriprrBrrG) r�r rSrgr_� log_linesrR�value�tbs r�default_exception_handlerz'BaseEventLoop.default_exception_handler�s[���+�+�i�(���9�G��K�K��,� �� ��Y���I�4K�4K�L�H��H��g�-��$�$�0��$�$�6�6��$�$�6�6� �&�'��I� ��'�?�C��.�.���C�L�E��(�(��W�W�Y�2�2�5�9�:��F�������$���*�*��W�W�Y�2�2�5�9�:��F�������$���U�������u�B�u�g�.�/�#� ���T�Y�Y�y�)�H�=r!c���|j� |j|�y d}|jd�}|�|jd�}|�|jd�}|�t|d�r|j�}|�*t|d �r|j|j||�y|j||�y#ttf$r�t$rtjdd��YywxYw#ttf$r�t$r[} |jd ||d��n:#ttf$r�t$rtjdd��YnwxYwYd}~yYd}~yd}~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^rror�get_context�runz$Unhandled error in exception handler)rSrgr zeException in default exception handler while handling an unexpected error in custom exception handler)r�r�rhrir-rrGr�r*r�r�)r�r �ctx�thingrms rrZz$BaseEventLoop.call_exception_handler+sq��,�"�"�*� ,��.�.�w�7�$ 0������F�+���=�$�K�K��1�E��=�#�K�K��1�E��$��� �)F��+�+�-�C��?�w�s�E�':��G�G�D�3�3�T�7�C��+�+�D�'�:��3� 1�2� �� � ,����E�&*�,� ,��0� 1�2� �� � 0�0��2�2�#I�%(�#*�4��� #�$5�6���$�0��L�L�"?�+/�0�0��0��� 0�sM�B7�BC,�$C,�7/C)�(C)�,E�D�E�/E � E�E � E�Ec�T�|js|jj|�yy)zAdd a Handle to _ready.N)� _cancelledr�rB�r�rs r� _add_callbackzBaseEventLoop._add_callbackss"��� � ��K�K���v�&�!r!c�F�|j|�|j�y)z6Like _add_callback() but called from a signal handler.N)r�r;r�s r�_add_callback_signalsafez&BaseEventLoop._add_callback_signalsafexs�����6�"����r!c�H�|jr|xjdz c_yy)z3Notification that a TimerHandle has been cancelled.rN)r�r�r�s r�_timer_handle_cancelledz%BaseEventLoop._timer_handle_cancelled}s!������'�'�1�,�'�r!c�b�t|j�}|tkDrr|j|ztkDr\g}|jD]'}|j rd|_�|j |��)tj|�||_d|_n�|jrz|jdj ra|xjdzc_tj|j�}d|_|jr|jdj r�ad}|js|jrd}nP|jrD|jdj}ttd||j�z �t �}|j"j%|�}|j'|�d}|j�|j(z}|jrm|jd}|j|k\rnNtj|j�}d|_|jj |�|jr�mt|j�}t+|�D]�} |jj-�}|j r�*|j.rr ||_|j�} |j3�|j�| z }||j4k\r t7j8dt;|�|�d|_��|j3���d}y#d|_wxYw)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)rUr��_MIN_SCHEDULED_TIMER_HANDLESr��%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr�rBr��heapify�heappopr�r��_whenr��maxr��MAXIMUM_SELECT_TIMEOUT� _selector�selectr>r��range�popleftr|r��_runr�rrfr )r��sched_count� new_scheduledrrjr�r=�end_time�ntodo�ir�r�s rr�zBaseEventLoop._run_once�s����$�/�/�*���6�6��'�'�+�5�5� 6��M��/�/���$�$�(-�F�%�!�(�(��0� *� �M�M�-�(�+�D�O�*+�D�'��/�/�d�o�o�a�&8�&C�&C��+�+�q�0�+����t���7��$)��!��/�/�d�o�o�a�&8�&C�&C� ���;�;�$�.�.��G� �_�_��?�?�1�%�+�+�D��#�a��� � ��!3�4�6L�M�G��^�^�*�*�7�3� ����Z�(�� ��9�9�;��!7�!7�7���o�o��_�_�Q�'�F��|�|�x�'���]�]�4�?�?�3�F� %�F���K�K���v�&� �o�o��D�K�K� ���u��A��[�[�(�(�*�F�� � ���{�{� 0�+1�D�(�����B��K�K�M�����r�)�B��T�8�8�8����'G�'5�f�'=�r�C�,0�D�(���� �!�"���,0�D�(�s �A)L%�% L.c� �t|�t|j�k(ry|rDtj�|_tj tj�||_ytj |j�||_yrP)rr�r}�#get_coroutine_origin_tracking_depthr��#set_coroutine_origin_tracking_depthr�DEBUG_STACK_DEPTH�r��enableds rr{z,BaseEventLoop._set_coroutine_origin_tracking�sw����=�D��!H�!H�I�I����7�7�9� �7��3�3��+�+� -�3:��/� �3�3��;�;� =�3:��/r!c��|jSrP)r|r�s rrzBaseEventLoop.get_debug�s���{�{�r!c�l�||_|j�r|j|j|�yyrP)r|rrDr{r�s rr�zBaseEventLoop.set_debug�s.������?�?���%�%�d�&I�&I�7�S�r!rP)NNNr<)r)rN)FNN)Ur�r�r�r�r�r�rrrrr'r*r.r0r9r;r>r rArHrPr_rqrhrwr�r�rkr�rrLrMr�rr�r�r�r�r�r�r�rDr�r�r�r�r�r�r�r�r�r�rrr%r#r$r2rVr+r:rrYr?� AI_PASSIVErqrsrwrzr}r#r$r�r�r�r�r�rZr�r�r�r�r{rr�rQr!rrr�s��/�< �)�)-�d��4%�"�"�%)�$�"�9=�"� �$��t�"&�!%�!%� "�CG�"� @D�(,�"� AE�)-�"�04�"�"�"�7�D�G� "��2�0D�K�4�0$�L�*�.�%�M�M��-� �:>��06:��$26��&%��(�"=A� �5� *� �2"#��!�1�H�7� A�(,� A�.�/�4�*).�X59�Q#����1�4��T�"&�!%�!%�$��Q#�j*/�"&�!%� #�8-<�#'�-<�^1�"�4%*�(,�.2�-1� .+�bEI�D#�./�q��26�7;�$� D#�N'(�f�.@�.@�%&�a� D��59�K��#�#��#�#������"&�!%��K�^�"&�!%� #�<#� #� %�&0�_�_�&0�o�o�&0�o�o�27�%)�1�(,�T�� "#�J%/�O�O�J�O�O�%/�_�_��$)�1�'+�D�t� #�D'� *�"0>�dF0�P'� � -� N�` :��Tr!r)rr)r)7�__doc__rU�collections.abc�concurrent.futuresr�r�r�rZrCr+rAr#rfr�r�r}rLr�ru�ImportErrorr5rrrrrr r rrr rr�logr�__all__r�r�r*rAr�r r'r2rMrdrnrrrw�Protocolry�AbstractServerr�AbstractEventLooprrQr!r�<module>r�s-�� ������� � ������ ������������������$�� #��),�%� �F�J�'� �#����J�8�v�,"��6�=�!�G� �>� A)� � 2� 2�A)�HB�V� "� "�B�JPT�F�,�,�PT��k�� �C��s�D�D�D__pycache__/base_futures.cpython-312.opt-2.pyc000064400000005442151706172560015125 0ustar00� T��h���h�dZddlZddlmZdZdZdZd�Zd �Zd �Z ej�d��Zy)��N�)�format_helpers�PENDING� CANCELLED�FINISHEDc�P� t|jd�xr|jduS)N�_asyncio_future_blocking)�hasattr� __class__r )�objs �-/usr/lib64/python3.12/asyncio/base_futures.py�isfuturer s0��� �C�M�M�#=�>� 5��(�(��4�6�c�"� t|�}|sd}d�}|dk(r||dd�}nc|dk(r+dj||dd�||dd��}n3|dkDr.dj||dd�|dz ||dd��}d |�d �S)N�c�.�tj|d�S)Nr)r�_format_callback_source)�callbacks r� format_cbz$_format_callbacks.<locals>.format_cbs���5�5�h��C�Crrr�z{}, {}z{}, <{} more>, {}���zcb=[�])�len�format)�cb�sizers r�_format_callbacksrs���-��r�7�D�� ��D��q�y� �r�!�u�Q�x� �� ��� �_�_�Y�r�!�u�Q�x�0�)�B�q�E�!�H�2E� F�� ��� � '� '� �"�Q�%��(�(;�(,�q��(1�"�R�&��)�(<�>���"��Q�<�rc��� |jj�g}|jtk(r^|j�|j d|j���n3tj|j�}|j d|���|jr$|j t|j��|jr,|jd}|j d|d�d|d���|S)Nz exception=zresult=rzcreated at r�:r)�_state�lower� _FINISHED� _exception�append�reprlib�repr�_result� _callbacksr�_source_traceback)�future�info�result�frames r�_future_repr_infor/,s���-��M�M���!�"�D� �}�}� �!����(��K�K�*�V�%6�%6�$9�:�;��\�\�&�.�.�1�F��K�K�'�&��*�+� ������%�f�&7�&7�8�9� ����(�(��,�����k�%��(��1�U�1�X�J�7�8��Krc�p�djt|��}d|jj�d|�d�S)N� �<�>)�joinr/r�__name__)r+r,s r�_future_reprr6@s8���8�8�%�f�-�.�D� �v���(�(�)��4�&��2�2r)�__all__r&rr�_PENDING� _CANCELLEDr#rrr/�recursive_reprr6rrr�<module>r;sO�� ������ � �� �6��(�(�����3��3r__pycache__/base_subprocess.cpython-312.opt-1.pyc000064400000037003151706172560015615 0ustar00� T��h�"���ddlZddlZddlZddlmZddlmZddlmZGd�dej�Z Gd�d ej�ZGd �deej�Z y)�N�)� protocols)� transports)�loggerc���eZdZ d�fd� Zd�Zd�Zd�Zd�Zd�Zd�Z e jfd�Zd �Z d �Zd�Zd�Zd �Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z�xZS)�BaseSubprocessTransportc �n��t� |�| �d|_||_||_d|_d|_d|_g|_tj�|_i|_d|_ |tjk(rd|jd<|tjk(rd|jd<|tjk(rd|jd< |j d||||||d�|��|j j$|_|j |j&d<|jj)�r?t+|t,t.f�r|}n|d}t1j2d||j�|jj5|j7| ��y#|j#��xYw) NFrr�)�args�shell�stdin�stdout�stderr�bufsize� subprocesszprocess %r created: pid %s�)�super�__init__�_closed� _protocol�_loop�_proc�_pid�_returncode� _exit_waiters�collections�deque�_pending_calls�_pipes� _finishedr�PIPE�_start�close�pid�_extra� get_debug� isinstance�bytes�strr�debug�create_task�_connect_pipes)�self�loop�protocolrrr rrr�waiter�extra�kwargs�program� __class__s ��0/usr/lib64/python3.12/asyncio/base_subprocess.pyrz BaseSubprocessTransport.__init__sx��� ��������!����� ��� ��� �������)�/�/�1����������J�O�O�#�!�D�K�K��N��Z�_�_�$�!�D�K�K��N��Z�_�_�$�!�D�K�K��N� ��D�K�K� B�T��e�F�%�w� B�:@� B��J�J�N�N�� �$(�J�J����L�!��:�:���!��$����-����q�'���L�L�5� �$�)�)� -� � � ���t�2�2�6�:�;�� ��J�J�L��s�F!�!F4c�^�|jjg}|jr|jd�|j�|jd|j���|j �|jd|j ���n/|j�|jd�n|jd�|jjd�}|�|jd|j���|jjd�}|jjd �}|�#||ur|jd |j���n@|�|jd|j���|�|jd|j���d jdj|��S)N�closedzpid=zreturncode=�runningznot startedrzstdin=rr zstdout=stderr=zstdout=zstderr=z<{}>� )r4�__name__r�appendrrr�get�pipe�format�join)r-�infor rrs r5�__repr__z BaseSubprocessTransport.__repr__7sX�����'�'�(���<�<��K�K��!��9�9� ��K�K�$�t�y�y�k�*�+����'��K�K�+�d�&6�&6�%7�8�9� �Y�Y� "��K�K� �"��K�K� �&�������"�����K�K�&�����-�.�������#��������#����&�F�"2��K�K�.���� �6�7��!����g�f�k�k�]�3�4��!����g�f�k�k�]�3�4��}�}�S�X�X�d�^�,�,�c��t��N)�NotImplementedError)r-rrr rrrr2s r5r"zBaseSubprocessTransport._startTs��!�!rBc��||_yrD�r)r-r/s r5�set_protocolz$BaseSubprocessTransport.set_protocolWs ��!��rBc��|jSrDrG�r-s r5�get_protocolz$BaseSubprocessTransport.get_protocolZs���~�~�rBc��|jSrD)rrJs r5� is_closingz"BaseSubprocessTransport.is_closing]s���|�|�rBc���|jryd|_|jj�D]}|��|jj ��!|j �t|j�g|j j��L|jj�rtjd|� |j j�yyyy#t$rYywxYw)NTz$Close running child process: kill %r)rr�valuesr=r#rr�pollrr&r�warning�kill�ProcessLookupError)r-�protos r5r#zBaseSubprocessTransport.close`s����<�<������[�[�'�'�)�E��}���J�J����*� �J�J�"�� � �(�� � ���!�)��z�z�#�#�%����E�t�L� �� � ���!� *�)� #��&� �� �s�4C� C�Cc�b�|js#|d|��t|��|j�yy)Nzunclosed transport )�source)r�ResourceWarningr#)r-�_warns r5�__del__zBaseSubprocessTransport.__del__{s+���|�|��'��x�0�/�$�O��J�J�L�rBc��|jSrD)rrJs r5�get_pidzBaseSubprocessTransport.get_pid�s���y�y�rBc��|jSrD)rrJs r5�get_returncodez&BaseSubprocessTransport.get_returncode�s�����rBc�R�||jvr|j|jSyrD)rr=)r-�fds r5�get_pipe_transportz*BaseSubprocessTransport.get_pipe_transport�s%�� ������;�;�r�?�'�'�'�rBc�0�|j� t��yrD)rrSrJs r5�_check_procz#BaseSubprocessTransport._check_proc�s���:�:��$�&�&�rBc�Z�|j�|jj|�yrD)rbr�send_signal)r-�signals r5rdz#BaseSubprocessTransport.send_signal�s ������� � ���v�&rBc�X�|j�|jj�yrD)rbr� terminaterJs r5rgz!BaseSubprocessTransport.terminate�s������� � ���rBc�X�|j�|jj�yrD)rbrrRrJs r5rRzBaseSubprocessTransport.kill�s������� � ���rBc���K� �j}�j}|j�9|j�fd�|j��d{���\}}|�jd<|j �9|j �fd�|j ��d{���\}}|�jd<|j�9|j �fd�|j��d{���\}}|�jd<|j�jj���jD]\}}|j|g|����d�_|�#|j�s|jd�yyy7��7��7��#ttf$r�t $r7}|�+|j�s|j#|�Yd}~yYd}~yYd}~yd}~wwxYw�w)Nc���t�d�S)Nr)�WriteSubprocessPipeProtorJs�r5�<lambda>z8BaseSubprocessTransport._connect_pipes.<locals>.<lambda>�s ���4�T�1�=rBrc���t�d�S)Nr��ReadSubprocessPipeProtorJs�r5rlz8BaseSubprocessTransport._connect_pipes.<locals>.<lambda>�� ���3�D�!�<rBrc���t�d�S)Nr rnrJs�r5rlz8BaseSubprocessTransport._connect_pipes.<locals>.<lambda>�rprBr )rrr �connect_write_piperr�connect_read_piper� call_soonr�connection_mader� cancelled� set_result� SystemExit�KeyboardInterrupt� BaseException� set_exception) r-r0�procr.�_r=�callback�data�excs ` r5r,z&BaseSubprocessTransport._connect_pipes�s������# (��:�:�D��:�:�D��z�z�%� $� 7� 7�=��J�J�! � ���4�"&����A���{�{�&� $� 6� 6�<��K�K�!!�!���4�"&����A���{�{�&� $� 6� 6�<��K�K�!!�!���4�"&����A�� �N�N�4�>�>�9�9�4�@�"&�"5�"5���$�����x�/�$�/�#6�"&�D���!�&�*:�*:�*<��!�!�$�'�+=�!�; ��!��!���-�.� ��� *��!�&�*:�*:�*<��$�$�S�)�)�+=�!�� *�sh�F?�AE-�E&�AE-�E)�AE-�E+�A*E-�&F?�&E-�)E-�+E-�-F<�#F7�(F?�7F<�<F?c��|j�|jj||f�y|jj|g|���yrD)rr;rrt)r-�cbrs r5�_callzBaseSubprocessTransport._call�s?�����*����&�&��D�z�2� �D�J�J� � ��+�d�+rBc�r�|j|jj||�|j�yrD)r�r�pipe_connection_lost�_try_finish)r-r_r�s r5�_pipe_connection_lostz-BaseSubprocessTransport._pipe_connection_lost�s(��� � �4�>�>�6�6��C�@����rBc�R�|j|jj||�yrD)r�r�pipe_data_received)r-r_rs r5�_pipe_data_receivedz+BaseSubprocessTransport._pipe_data_received�s��� � �4�>�>�4�4�b�$�?rBc�,�|jj�rtjd||�||_|j j�||j _|j|jj�|j�y)Nz%r exited with return code %r)rr&rr@rr� returncoder�r�process_exitedr�)r-r�s r5�_process_exitedz'BaseSubprocessTransport._process_exited�sm���:�:���!��K�K�7��z�J�%����:�:� � �(�%/�D�J�J�!�� � �4�>�>�0�0�1����rBc��K�|j�|jS|jj�}|jj |�|�d{���S7��w)zdWait until the process exit and return the process return code. This method is a coroutine.N)rr� create_futurerr;)r-r0s r5�_waitzBaseSubprocessTransport._wait�sP�������'��#�#�#����)�)�+�����!�!�&�)��|��|�s�AA�A�Ac��|j�ytd�|jj�D��r$d|_|j|jd�yy)Nc3�@K�|]}|duxr|j���y�wrD)�disconnected)�.0�ps r5� <genexpr>z6BaseSubprocessTransport._try_finish.<locals>.<genexpr>�s(����.�,�1���}�/����/�,�s�T)r�allrrOr r��_call_connection_lostrJs r5r�z#BaseSubprocessTransport._try_finish�sS�����#���.����*�*�,�.�.�!�D�N��J�J�t�1�1�4�8�.rBc�� |jj|�|jD].}|j�r�|j |j ��0d|_d|_d|_d|_y#|jD].}|j�r�|j |j ��0d|_d|_d|_d|_wxYwrD)r�connection_lostrrvrwrrr)r-r�r0s r5r�z-BaseSubprocessTransport._call_connection_lost�s��� "��N�N�*�*�3�/��,�,���'�'�)��%�%�d�&6�&6�7�-�"&�D���D�J��D�J�!�D�N�� �,�,���'�'�)��%�%�d�&6�&6�7�-�"&�D���D�J��D�J�!�D�N�s�A7�7 C�:C)NN)r:� __module__�__qualname__rrAr"rHrKrMr#�warnings�warnrYr[r]r`rbrdrgrRr,r�r�r�r�r�r�r�� __classcell__)r4s@r5rr s����%)�)<�V-�:"�"����6%�M�M�� � ��'�'���$(�L,��@�� �9�"rBrc�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)rkc�<�||_||_d|_d|_y)NF)r|r_r=r�)r-r|r_s r5rz!WriteSubprocessPipeProto.__init__s���� ������ �!��rBc��||_yrD)r=)r-� transports r5ruz(WriteSubprocessPipeProto.connection_mades ���� rBc�j�d|jj�d|j�d|j�d�S)N�<z fd=z pipe=�>)r4r:r_r=rJs r5rAz!WriteSubprocessPipeProto.__repr__ s0���4�>�>�*�*�+�4����y��t�y�y�m�1�M�MrBc�l�d|_|jj|j|�d|_y)NT)r�r|r�r_)r-r�s r5r�z(WriteSubprocessPipeProto.connection_lost s)�� ���� � �'�'�����5��� rBc�L�|jjj�yrD)r|r� pause_writingrJs r5r�z&WriteSubprocessPipeProto.pause_writings��� � ���)�)�+rBc�L�|jjj�yrD)r|r�resume_writingrJs r5r�z'WriteSubprocessPipeProto.resume_writings��� � ���*�*�,rBN) r:r�r�rrurAr�r�r�rrBr5rkrk�s!��"��N�� ,�-rBrkc��eZdZd�Zy)roc�P�|jj|j|�yrD)r|r�r_)r-rs r5� data_receivedz%ReadSubprocessPipeProto.data_receiveds��� � �%�%�d�g�g�t�4rBN)r:r�r�r�rrBr5roros��5rBro)rrr��rr�logr�SubprocessTransportr�BaseProtocolrk�ProtocolrorrBr5�<module>r�sT��������r"�j�<�<�r"�j-�y�5�5�-�45�6�'�0�0�5rB__pycache__/base_tasks.cpython-312.opt-2.pyc000064400000007760151706172560014562 0ustar00� T��hp ��t�ddlZddlZddlZddlmZddlmZd�Zej�d��Zd�Z d�Z y) �N�)�base_futures)� coroutinesc��tj|�}|j�r|j�sd|d<|j dd|j�z�|j�|j dd|j���|jr5tj|j�}|j dd|�d��|S) N� cancellingrrzname=%r�z wait_for=zcoro=<�>) r�_future_repr_infor�done�insert�get_name�_fut_waiter�_coror�_format_coroutine)�task�info�coros �+/usr/lib64/python3.12/asyncio/base_tasks.py�_task_repr_infor s����)�)�$�/�D�����������Q���K�K��9�t�}�}��.�/����#����A��4�#3�#3�"6�7�8��z�z��+�+�D�J�J�7�����A���v�Q�'�(��K�c�p�djt|��}d|jj�d|�d�S)N� �<r )�joinr� __class__�__name__)rrs r� _task_reprrs5���8�8�O�D�)�*�D� �t�~�~�&�&�'�q���a�0�0rc�\�g}t|jd�r|jj}n\t|jd�r|jj}n/t|jd�r|jj}nd}|�A|�-|�|dkrn%|dz}|j|�|j}|��-|j�|S|j�Q|jj}|�9|� |dkr |S|dz}|j|j�|j}|��9|S)N�cr_frame�gi_frame�ag_framerr)�hasattrrrr r!�append�f_back�reverse� _exception� __traceback__�tb_frame�tb_next)r�limit�frames�f�tbs r�_task_get_stackr."s �� �F��t�z�z�:�&��J�J���� ����Z� (��J�J���� ����Z� (��J�J���� ���}��m�� ��A�:���� ���M�M�!�����A� �m� �����M� ��� $� �_�_� *� *���n�� ��A�:���M��� ���M�M�"�+�+�&����B� �n��Mrc��g}t�}|j|��D]�}|j}|j}|j}|j } ||vr&|j |�tj|�tj|||j�} |j||| | f���|j}|std|��|��n%|�td|�d�|��ntd|�d�|��tj||��|�4tj |j"|�D]} t| |d���yy) N)r*z No stack for )�filezTraceback for z (most recent call last):z Stack for �)r0�end)�set� get_stack�f_lineno�f_code�co_filename�co_name�add� linecache� checkcache�getline� f_globalsr#r&�print� traceback� print_list�format_exception_onlyr)rr*r0�extracted_list�checkedr,�lineno�co�filename�name�line�excs r�_task_print_stackrJEs&���N��e�G� �^�^�%�^� (������ �X�X���>�>���z�z���7�"��K�K��!�� � ��*�� � ��6�1�;�;�?�����x���t�<�=�)��/�/�C�� � �d�X�&�T�2� �� ��t�h�&?�@�t�L� � �4�(�";�<�4�H� ����d�3� ���3�3�C�M�M�3�G�D��$�T�r�*�H�r)r:�reprlibr?r1rrr�recursive_reprrr.rJ�rr�<module>rNsC��������&�����1��1� �F+r__pycache__/constants.cpython-312.opt-1.pyc000064400000001675151706172560014455 0ustar00� T��h���Z�ddlZdZdZdZdZdZdZdZd Zd Z Gd�dej�Zy) �N��� gN@g>@i�ii,c�r�eZdZej�Zej�Zej�Zy)� _SendfileModeN)�__name__� __module__�__qualname__�enum�auto�UNSUPPORTED� TRY_NATIVE�FALLBACK���*/usr/lib64/python3.12/asyncio/constants.pyrr&s)���$�)�)�+�K������J��t�y�y�{�Hrr)r�!LOG_THRESHOLD_FOR_CONNLOST_WRITES�ACCEPT_RETRY_DELAY�DEBUG_STACK_DEPTH�SSL_HANDSHAKE_TIMEOUT�SSL_SHUTDOWN_TIMEOUT�!SENDFILE_FALLBACK_READBUFFER_SIZE� FLOW_CONTROL_HIGH_WATER_SSL_READ�!FLOW_CONTROL_HIGH_WATER_SSL_WRITE�THREAD_JOIN_TIMEOUT�Enumrrrr�<module>rs^�� �%&�!��� ������%/�!�#&� �$'�!����D�I�I�r__pycache__/mixins.cpython-312.opt-2.pyc000064400000001747151706172560013751 0ustar00� T��h���P� ddlZddlmZej�ZGd�d�Zy)�N�)�eventsc��eZdZdZd�Zy)�_LoopBoundMixinNc���tj�}|j�"t5|j�||_ddd�||jurt |�d���|S#1swY�'xYw)Nz# is bound to a different event loop)r�_get_running_loop�_loop�_global_lock�RuntimeError)�self�loops �'/usr/lib64/python3.12/asyncio/mixins.py� _get_loopz_LoopBoundMixin._get_loopsa���'�'�)���:�:����:�:�%�!%�D�J���t�z�z�!��$��)L�M�N�N�����s�A!�!A*)�__name__� __module__�__qualname__r r��rrr s���E� rr)� threading�r�Lockr rrrr�<module>rs&������y�~�~����r__pycache__/__init__.cpython-312.opt-1.pyc000064400000002663151706172560014176 0ustar00� T��h����dZddlZddl�ddl�ddl�ddl�ddl�ddl�ddl�ddl �ddl �ddl�ddl�ddl �ddl�ddl�ddl�ddl�ej$ej$zej$zej$zej$zej$zej$ze j$ze j$zej$zej$ze j$zej$zej$zej$zej$zZej&dk(rddl�eej$z Zyddl�eej$z Zy)z'The asyncio package, tracking PEP 3156.�N�)�*�win32)�__doc__�sys�base_events� coroutines�events� exceptions�futures�locks� protocols�runners�queues�streams� subprocess�tasks� taskgroups�timeouts�threads� transports�__all__�platform�windows_events�unix_events���)/usr/lib64/python3.12/asyncio/__init__.py�<module>rsZ��-��������������������������>�>�������?�?� � �=�=����� ��?�?���>�>���?�?� ���� ��=�=�������?�?� ����������"�<�<�7��!��~�%�%�%�G���{�"�"�"�Gr__pycache__/constants.cpython-312.pyc000064400000001675151706172560013516 0ustar00� T��h���Z�ddlZdZdZdZdZdZdZdZd Zd Z Gd�dej�Zy) �N��� gN@g>@i�ii,c�r�eZdZej�Zej�Zej�Zy)� _SendfileModeN)�__name__� __module__�__qualname__�enum�auto�UNSUPPORTED� TRY_NATIVE�FALLBACK���*/usr/lib64/python3.12/asyncio/constants.pyrr&s)���$�)�)�+�K������J��t�y�y�{�Hrr)r�!LOG_THRESHOLD_FOR_CONNLOST_WRITES�ACCEPT_RETRY_DELAY�DEBUG_STACK_DEPTH�SSL_HANDSHAKE_TIMEOUT�SSL_SHUTDOWN_TIMEOUT�!SENDFILE_FALLBACK_READBUFFER_SIZE� FLOW_CONTROL_HIGH_WATER_SSL_READ�!FLOW_CONTROL_HIGH_WATER_SSL_WRITE�THREAD_JOIN_TIMEOUT�Enumrrrr�<module>rs^�� �%&�!��� ������%/�!�#&� �$'�!����D�I�I�r__pycache__/coroutines.cpython-312.opt-1.pyc000064400000007216151706172560014630 0ustar00� T��h ���dZddlZddlZddlZddlZddlZd�Ze�Z d�Z ejejjfZe�Zd�Zd�Zy))�iscoroutinefunction�iscoroutine�Nc���tjjxsEtjjxr(t t jjd��S)N�PYTHONASYNCIODEBUG)�sys�flags�dev_mode�ignore_environment�bool�os�environ�get���+/usr/lib64/python3.12/asyncio/coroutines.py�_is_debug_moder sF���9�9���N�c�i�i�&B�&B�"B�#M�"&�r�z�z�~�~�6J�'K�"L�Nrc�V�tj|�xst|dd�tuS)z6Return True if func is a decorated coroutine function.� _is_coroutineN)�inspectr�getattrr)�funcs rrrs-���'�'��-� B��D�/�4�0�M�A�Crc��t|�tvryt|t�r1t t�dkrtjt|��yy)z)Return True if obj is a coroutine object.T�dF)�type�_iscoroutine_typecache� isinstance�_COROUTINE_TYPES�len�add)�objs rrr sE���C�y�*�*���#�'�(��%�&��,�"�&�&�t�C�y�1��rc���d�}d�}d}t|d�r|jr |j}n$t|d�r|jr|j}||�}|s||�r|�d�S|Sd}t|d�r|jr |j}n$t|d�r|jr|j}|j xsd}d }|�|j}|�d |�d|��}|S|j}|�d|�d|��}|S) Nc���t|d�r|jr |j}n>t|d�r|jr |j}ndt|�j�d�}|�d�S)N�__qualname__�__name__�<z without __name__>z())�hasattrr#r$r)�coro� coro_names r�get_namez#_format_coroutine.<locals>.get_name3sc�� �4��(�T�->�->��)�)�I� �T�:� &�4�=�=�� � �I��D��J�/�/�0�0B�C�I���B��rc�t� |jS#t$r |jcYS#t$rYYywxYwwxYw)NF)� cr_running�AttributeError� gi_running)r's r� is_runningz%_format_coroutine.<locals>.is_runningAsA�� ��?�?�"��� � ����&��!� �� �� �s �� 7�&�7� 3�7�3�7�cr_code�gi_codez running�gi_frame�cr_framez<empty co_filename>rz running at �:z done, defined at )r&r/r0r1r2�co_filename�f_lineno�co_firstlineno) r'r)r.� coro_coder(� coro_frame�filename�lineno� coro_reprs r�_format_coroutiner<0s�� ���I��t�Y��D�L�L��L�L� � ��y� !�d�l�l��L�L� ����I���d���[��)�)����J��t�Z� �T�]�]��]�]� � ��z� "�t�}�}��]�]� ��$�$�=�(=�H� �F����$�$�� �k��h�Z�q���A� ����)�)�� �k�!3�H�:�Q�v�h�G� ��r)�__all__�collections.abc�collectionsrrr�typesr�objectrr� CoroutineType�abc� Coroutiner�setrrr<rrr�<module>rFs]�� .���� � ��N��� �C��'�'����)B�)B�C����� � =r__pycache__/events.cpython-312.opt-2.pyc000064400000065513151706172560013747 0ustar00� T��h�r��� dZddlZddlZddlZddlZddlZddlZddlZddlm Z Gd�d�Z Gd�de �ZGd �d �ZGd�d�Z Gd �d�ZGd�de�Zdaej"�ZGd�dej&�Ze�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z eZ!eZ"eZ#eZ$ ddl%mZmZmZmZeZ&eZ'eZ(eZ)e+ed�rd �Z,ejZe,�!�yy#e*$rY�(wxYw)")�AbstractEventLoopPolicy�AbstractEventLoop�AbstractServer�Handle�TimerHandle�get_event_loop_policy�set_event_loop_policy�get_event_loop�set_event_loop�new_event_loop�get_child_watcher�set_child_watcher�_set_running_loop�get_running_loop�_get_running_loop�N�)�format_helpersc�>�eZdZ dZd d�Zd�Zd�Zd�Zd�Zd�Z d �Z y)r)� _callback�_args� _cancelled�_loop�_source_traceback�_repr�__weakref__�_contextNc�"�|�tj�}||_||_||_||_d|_d|_|jj�r.tjtjd��|_ yd|_ y)NFr)�contextvars�copy_contextrrrrrr� get_debugr� extract_stack�sys� _getframer)�self�callback�args�loop�contexts �'/usr/lib64/python3.12/asyncio/events.py�__init__zHandle.__init__$sx���?�!�.�.�0�G��� ��� �!����� ������ ��:�:���!�%3�%A�%A�� � �a� �&"�D�"�&*�D�"�c�h�|jjg}|jr|jd�|j�9|jtj|j|j��|jr,|jd}|jd|d�d|d���|S)N� cancelled���zcreated at r�:r) � __class__�__name__r�appendrr�_format_callback_sourcerr)r$�info�frames r)� _repr_infozHandle._repr_info3s������'�'�(���?�?��K�K��$��>�>�%��K�K��>�>����� � �,� -��!�!��*�*�2�.�E��K�K�+�e�A�h�Z�q��q�� �;�<��r+c��|j�|jS|j�}djdj|��S)Nz<{}>� )rr6�format�join)r$r4s r)�__repr__zHandle.__repr__?s9���:�:�!��:�:����� ���}�}�S�X�X�d�^�,�,r+c��|jS�N)r�r$s r)�get_contextzHandle.get_contextEs���}�}�r+c��|js@d|_|jj�rt|�|_d|_d|_yy)NT)rrr �reprrrrr>s r)�cancelz Handle.cancelHs@�����"�D�O��z�z�#�#�%�"�$�Z�� �!�D�N��D�J�r+c��|jSr=)rr>s r)r-zHandle.cancelledSs�����r+c�� |jj|jg|j���d}y#tt f$r�t$rw}tj|j|j�}d|��}|||d�}|jr|j|d<|jj|�Yd}~d}yd}~wwxYw)NzException in callback )�message� exception�handle�source_traceback)r�runrr� SystemExit�KeyboardInterrupt� BaseExceptionrr3rr�call_exception_handler)r$�exc�cb�msgr(s r)�_runzHandle._runVs��� 7��D�M�M���d�n�n�:�t�z�z�:�����-�.� ��� 7��7�7����� � �,�B�*�2�$�/�C�� ���G� �%�%�.2�.D�.D��*�+��J�J�-�-�g�6�6���� 7�s�16�C�A+C�Cr=)r1� __module__�__qualname__� __slots__r*r6r;r?rBr-rQ�r+r)rrs/��;��I� *� �-�� ��r+rc�h��eZdZ ddgZd �fd� Z�fd�Zd�Zd�Zd�Zd�Z d �Z d �Z�fd�Zd�Z �xZS)r� _scheduled�_whenc�x��t�|�||||�|jr |jd=||_d|_y)Nr.F)�superr*rrXrW)r$�whenr%r&r'r(r0s �r)r*zTimerHandle.__init__os;��� ����4��w�7��!�!��&�&�r�*��� ���r+c���t�|��}|jrdnd}|j|d|j���|S)N�rzwhen=)rZr6r�insertrX)r$r4�posr0s �r)r6zTimerHandle._repr_infovs;����w�!�#���?�?�a������C�5�����-�.��r+c�,�t|j�Sr=)�hashrXr>s r)�__hash__zTimerHandle.__hash__|s���D�J�J��r+c�`�t|t�r|j|jkStSr=�� isinstancerrX�NotImplemented�r$�others r)�__lt__zTimerHandle.__lt__�%���e�[�)��:�:����+�+��r+c��t|t�r,|j|jkxs|j|�StSr=�rerrX�__eq__rfrgs r)�__le__zTimerHandle.__le__��3���e�[�)��:�:����+�A�t�{�{�5�/A�A��r+c�`�t|t�r|j|jkDStSr=rdrgs r)�__gt__zTimerHandle.__gt__�rjr+c��t|t�r,|j|jkDxs|j|�StSr=rlrgs r)�__ge__zTimerHandle.__ge__�ror+c��t|t�rj|j|jk(xrO|j|jk(xr4|j|jk(xr|j |j k(StSr=)rerrXrrrrfrgs r)rmzTimerHandle.__eq__�sl���e�[�)��J�J�%�+�+�-�8��N�N�e�o�o�5�8��J�J�%�+�+�-�8��O�O�u�'7�'7�7� 9��r+c�p��|js|jj|�t�|��yr=)rr�_timer_handle_cancelledrZrB)r$r0s �r)rBzTimerHandle.cancel�s&�������J�J�.�.�t�4� ���r+c�� |jSr=)rXr>s r)r[zTimerHandle.when�s�� � �z�z�r+r=)r1rRrSrTr*r6rbrirnrqrsrmrBr[� __classcell__)r0s@r)rrjsB���A��w�'�I� �� �� � � � �� r+rc�>�eZdZ d�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z y ) rc�� t�r=��NotImplementedErrorr>s r)�closezAbstractServer.close�s��C�!�!r+c�� t�r=r{r>s r)�get_loopzAbstractServer.get_loop�s��B�!�!r+c�� t�r=r{r>s r)� is_servingzAbstractServer.is_serving����A�!�!r+c��K� t��wr=r{r>s r)� start_servingzAbstractServer.start_serving�s���� � "�!��� c��K� t��wr=r{r>s r)� serve_foreverzAbstractServer.serve_forever�s���� �"�!�r�c��K� t��wr=r{r>s r)�wait_closedzAbstractServer.wait_closed�s����8�!�!�r�c��K�|S�wr=rUr>s r)� __aenter__zAbstractServer.__aenter__�s������s�c��`K�|j�|j��d{���y7��wr=)r}r�)r$rNs r)� __aexit__zAbstractServer.__aexit__�s!����� � ����� � � �s�$.�,�.N)r1rRrSr}rr�r�r�r�r�r�rUr+r)rr�s-��6�"�"�"�"�"�"��!r+rc ���eZdZ d�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Zd d�d�Zd d�d �Z d d�d�Zd�Zd�Zd d d�d�Zd d�d�Zd�Zd�Zddddd�d�ZdId�Z dJd dddd d d d d d d d�d�Z dJej2ej4d dd d d d d dd� d�ZdKdd �d!�Zd"d d d d#�d$�Z dLd d d d d d%�d&�Z dLd dd d d dd'�d(�Zd d d d)�d*�Z dJdddd d d d d+�d,�Z!d-�Z"d.�Z#e$jJe$jJe$jJd/�d0�Z&e$jJe$jJe$jJd/�d1�Z'd2�Z(d3�Z)d4�Z*d5�Z+d6�Z,d7�Z-d8�Z.dId9�Z/d:�Z0d;�Z1d<�Z2d=�Z3dKd d �d>�Z4d?�Z5d@�Z6dA�Z7dB�Z8dC�Z9dD�Z:dE�Z;dF�Z<dG�Z=dH�Z>y )Mrc�� t�r=r{r>s r)�run_foreverzAbstractEventLoop.run_forever����8�!�!r+c�� t�r=r{)r$�futures r)�run_until_completez$AbstractEventLoop.run_until_complete�s�� �"�!r+c�� t�r=r{r>s r)�stopzAbstractEventLoop.stop�s�� � "�!r+c�� t�r=r{r>s r)� is_runningzAbstractEventLoop.is_running�r�r+c�� t�r=r{r>s r)� is_closedzAbstractEventLoop.is_closed�r�r+c�� t�r=r{r>s r)r}zAbstractEventLoop.close�s�� �"�!r+c��K� t��wr=r{r>s r)�shutdown_asyncgensz$AbstractEventLoop.shutdown_asyncgens�s����:�!�!�r�c��K� t��wr=r{r>s r)�shutdown_default_executorz+AbstractEventLoop.shutdown_default_executors����<�!�!�r�c�� t�r=r{)r$rGs r)rvz)AbstractEventLoop._timer_handle_cancelledr�r+N)r(c�0�|jd|g|��d|i�S)Nrr()� call_later�r$r%r(r&s r)� call_soonzAbstractEventLoop.call_soons���t���q�(�C�T�C�7�C�Cr+c��t�r=r{)r$�delayr%r(r&s r)r�zAbstractEventLoop.call_later���!�!r+c��t�r=r{)r$r[r%r(r&s r)�call_atzAbstractEventLoop.call_atr�r+c��t�r=r{r>s r)�timezAbstractEventLoop.timer�r+c��t�r=r{r>s r)� create_futurezAbstractEventLoop.create_futurer�r+)�namer(c��t�r=r{)r$�coror�r(s r)�create_taskzAbstractEventLoop.create_taskr�r+c��t�r=r{r�s r)�call_soon_threadsafez&AbstractEventLoop.call_soon_threadsafe"r�r+c��t�r=r{)r$�executor�funcr&s r)�run_in_executorz!AbstractEventLoop.run_in_executor%r�r+c��t�r=r{)r$r�s r)�set_default_executorz&AbstractEventLoop.set_default_executor(r�r+r)�family�type�proto�flagsc��K�t��wr=r{)r$�host�portr�r�r�r�s r)�getaddrinfozAbstractEventLoop.getaddrinfo-�����!�!��� c��K�t��wr=r{)r$�sockaddrr�s r)�getnameinfozAbstractEventLoop.getnameinfo1�����!�!�r�)�sslr�r�r��sock� local_addr�server_hostname�ssl_handshake_timeout�ssl_shutdown_timeout�happy_eyeballs_delay� interleavec��K�t��wr=r{)r$�protocol_factoryr�r�r�r�r�r�r�r�r�r�r�r�r�s r)�create_connectionz#AbstractEventLoop.create_connection4s����"�!�r��dT) r�r�r��backlogr�� reuse_address� reuse_portr�r�r�c ��K� t��wr=r{)r$r�r�r�r�r�r�r�r�r�r�r�r�r�s r)� create_serverzAbstractEventLoop.create_server>s����/ �`"�!�r�)�fallbackc��K� t��wr=r{)r$� transport�file�offset�countr�s r)�sendfilezAbstractEventLoop.sendfilexs���� �"�!�r�F)�server_sider�r�r�c��K� t��wr=r{)r$r��protocol� sslcontextr�r�r�r�s r)� start_tlszAbstractEventLoop.start_tls�s���� � "�!�r�)r�r�r�r�r�c��K�t��wr=r{)r$r��pathr�r�r�r�r�s r)�create_unix_connectionz(AbstractEventLoop.create_unix_connection�s����"�!�r�)r�r�r�r�r�r�c��K� t��wr=r{) r$r�r�r�r�r�r�r�r�s r)�create_unix_serverz$AbstractEventLoop.create_unix_server�s���� �8"�!�r�)r�r�r�c��K� t��wr=r{)r$r�r�r�r�r�s r)�connect_accepted_socketz)AbstractEventLoop.connect_accepted_socket�s���� �"�!�r�)r�r�r�r�r��allow_broadcastr�c��K� t��wr=r{)r$r�r��remote_addrr�r�r�r�r�r�r�s r)�create_datagram_endpointz*AbstractEventLoop.create_datagram_endpoint�s���� �8"�!�r�c��K� t��wr=r{�r$r��pipes r)�connect_read_pipez#AbstractEventLoop.connect_read_pipe�s���� $�"�!�r�c��K� t��wr=r{r�s r)�connect_write_pipez$AbstractEventLoop.connect_write_pipe�s���� %�"�!�r�)�stdin�stdout�stderrc��K�t��wr=r{)r$r��cmdr�r�r��kwargss r)�subprocess_shellz"AbstractEventLoop.subprocess_shell����� "�!�r�c��K�t��wr=r{)r$r�r�r�r�r&r�s r)�subprocess_execz!AbstractEventLoop.subprocess_exec r�r�c��t�r=r{�r$�fdr%r&s r)� add_readerzAbstractEventLoop.add_readerr�r+c��t�r=r{�r$rs r)� remove_readerzAbstractEventLoop.remove_readerr�r+c��t�r=r{rs r)� add_writerzAbstractEventLoop.add_writerr�r+c��t�r=r{rs r)� remove_writerzAbstractEventLoop.remove_writer"r�r+c��K�t��wr=r{)r$r��nbytess r)� sock_recvzAbstractEventLoop.sock_recv'r�r�c��K�t��wr=r{)r$r��bufs r)�sock_recv_intoz AbstractEventLoop.sock_recv_into*r�r�c��K�t��wr=r{)r$r��bufsizes r)� sock_recvfromzAbstractEventLoop.sock_recvfrom-r�r�c��K�t��wr=r{)r$r�rrs r)�sock_recvfrom_intoz$AbstractEventLoop.sock_recvfrom_into0r�r�c��K�t��wr=r{)r$r��datas r)�sock_sendallzAbstractEventLoop.sock_sendall3r�r�c��K�t��wr=r{)r$r�r�addresss r)�sock_sendtozAbstractEventLoop.sock_sendto6r�r�c��K�t��wr=r{)r$r�rs r)�sock_connectzAbstractEventLoop.sock_connect9r�r�c��K�t��wr=r{)r$r�s r)�sock_acceptzAbstractEventLoop.sock_accept<r�r�c��K�t��wr=r{)r$r�r�r�r�r�s r)� sock_sendfilezAbstractEventLoop.sock_sendfile?r�r�c��t�r=r{)r$�sigr%r&s r)�add_signal_handlerz$AbstractEventLoop.add_signal_handlerEr�r+c��t�r=r{)r$r#s r)�remove_signal_handlerz'AbstractEventLoop.remove_signal_handlerHr�r+c��t�r=r{)r$�factorys r)�set_task_factoryz"AbstractEventLoop.set_task_factoryMr�r+c��t�r=r{r>s r)�get_task_factoryz"AbstractEventLoop.get_task_factoryPr�r+c��t�r=r{r>s r)�get_exception_handlerz'AbstractEventLoop.get_exception_handlerUr�r+c��t�r=r{)r$�handlers r)�set_exception_handlerz'AbstractEventLoop.set_exception_handlerXr�r+c��t�r=r{�r$r(s r)�default_exception_handlerz+AbstractEventLoop.default_exception_handler[r�r+c��t�r=r{r2s r)rMz(AbstractEventLoop.call_exception_handler^r�r+c��t�r=r{r>s r)r zAbstractEventLoop.get_debugcr�r+c��t�r=r{)r$�enableds r)� set_debugzAbstractEventLoop.set_debugfr�r+)r�NN)rNr=)?r1rRrSr�r�r�r�r�r}r�r�rvr�r�r�r�r�r�r�r�r�r�r�r��socket� AF_UNSPEC� AI_PASSIVEr�r�r�r�r�r�r�r�r�� subprocess�PIPEr�r�rrrr r rrrrrrrr!r$r&r)r+r-r0r3rMr r8rUr+r)rr�s?���"�"�"�"�"� "�"�"�"�26�D�:>�"�6:�"�"�"� )-�d�"� =A�"�"�"�"#��!�1�"�"�59�"�����$�4� �"&�!%�!%�$�"�59�8"��&�&��#�#�$���D�T�"&�!%��8"�t"�#'�"�%*�(,�.2�-1� "�*.�"��4� �"&�!%�"�*.�""��s��"&�!%��""�L�"&�!%� "� EI�!"�./�q��59�d�7;�$� !"�J"�"�&0�_�_�&0�o�o�&0�o�o�"�%/�O�O�%/�_�_�%/�_�_�"�"�"�"�"� "�"�"�"�"�"�"�"�"�(,�"�"�"� "�"� "�"�"�"� "�"r+rc�,�eZdZ d�Zd�Zd�Zd�Zd�Zy)rc�� t�r=r{r>s r)r z&AbstractEventLoopPolicy.get_event_loopms�� (�"�!r+c�� t�r=r{�r$r's r)r z&AbstractEventLoopPolicy.set_event_loopwr�r+c�� t�r=r{r>s r)rz&AbstractEventLoopPolicy.new_event_loop{s�� J�"�!r+c�� t�r=r{r>s r)rz)AbstractEventLoopPolicy.get_child_watcher�s��.�!�!r+c�� t�r=r{)r$�watchers r)r z)AbstractEventLoopPolicy.set_child_watcher�s��2�!�!r+N)r1rRrSr r rrr rUr+r)rrjs��7�"�"�"�"�"r+rc�T�eZdZ dZGd�dej �Zd�Zd�Zd�Z d�Z y)�BaseDefaultEventLoopPolicyNc��eZdZdZdZy)�!BaseDefaultEventLoopPolicy._LocalNF)r1rRrSr�_set_calledrUr+r)�_LocalrJ�s�����r+rLc�.�|j�|_yr=)rL�_localr>s r)r*z#BaseDefaultEventLoopPolicy.__init__�s���k�k�m��r+c�� |jj��|jjs�tj�tj �ur�d} t jd�}|rG|jjd�}|dk(s|jd�sn|j}|dz }|r�F ddl }|jdt|��|j!|j#��|jj�*t%d tj�j&z��|jjS#t$rY��wxYw) Nr]rr1�asynciozasyncio.rzThere is no current event loop)� stacklevelz,There is no current event loop in thread %r.)rNrrK� threading�current_thread�main_threadr"r#� f_globals�get� startswith�f_back�AttributeError�warnings�warn�DeprecationWarningr r�RuntimeErrorr�)r$rQ�f�modulerZs r)r z)BaseDefaultEventLoopPolicy.get_event_loop�s4�� � �K�K���%��K�K�+�+��(�(�*�i�.C�.C�.E�E��J� $��M�M�!�$����[�[�_�_�Z�8�F�"�i�/�6�3D�3D�Z�3P�����A��!�O�J�� ��M�M�:�,�� � E����� 3� 3� 5�6��;�;���$��M�!*�!9�!9�!;�!@�!@� A�B� B��{�{� � � ��)"� �� �s�E� E�Ec�� d|j_|�2t|t�s"t dt|�j�d���||j_y)NTz<loop must be an instance of AbstractEventLoop or None, not '�')rNrKrer� TypeErrorr�r1rrBs r)r z)BaseDefaultEventLoopPolicy.set_event_loop�sQ��!�"&�������J�t�5F�$G��Z�[_�`d�[e�[n�[n�Zo�op�q�r�r� ����r+c�$� |j�Sr=)� _loop_factoryr>s r)rz)BaseDefaultEventLoopPolicy.new_event_loop�s�� � �!�!�#�#r+)r1rRrSrdrR�localrLr*r r rrUr+r)rHrH�s3�� ��M������$�!�B!�$r+rHc��eZdZdZy)�_RunningLoopr9N)r1rRrS�loop_pidrUr+r)rgrg�s���Hr+rgc�6� t�}|�td��|S)Nzno running event loop)rr]�r's r)rr�s'��� ��D��|��2�3�3��Kr+c�d� tj\}}|�|tj�k(r|Syyr=)� _running_looprh�os�getpid)�running_loop�pids r)rr�s:���&�.�.��L�#���C�2�9�9�;�$6���%7�r+c�D� |tj�ft_yr=)rmrnrlrhrjs r)rr�s���#�B�I�I�K�0�M�r+c�`�t5t� ddlm}|�addd�y#1swYyxYw)Nr��DefaultEventLoopPolicy)�_lock�_event_loop_policy�rtrss r)�_init_event_loop_policyrxs!�� ��%�0�!7�!9�� ���s�$�-c�0� t� t�tSr=)rvrxrUr+r)rrs��,��!��!��r+c�r� |�2t|t�s"tdt|�j�d���|ay)NzDpolicy must be an instance of AbstractEventLoopPolicy or None, not 'ra)rerrbr�r1rv)�policys r)rrsC��:���*�V�5L�"M��^�_c�dj�_k�_t�_t�^u�uv�w�x�x��r+c�P� t�}|�|St�j�Sr=)rrr )�current_loops r)r r s/���%�&�L����� �"�1�1�3�3r+c�8� t�j|�yr=)rr rjs r)r r 0s��M���*�*�4�0r+c�4� t�j�Sr=)rrrUr+r)rr5s��I� �"�1�1�3�3r+c�4� t�j�Sr=)rrrUr+r)rr:s��L� �"�4�4�6�6r+c�6� t�j|�Sr=)rr )rFs r)r r ?s��;� �"�4�4�W�=�=r+)rrrr �forkc��t�tj�t_t d�tjd�y)Nr.)rvrHrLrNr�signal� set_wakeup_fdrUr+r)�on_forkr�]s0���)�(B�(I�(I�(K��%��$�����R� r+)�after_in_child).�__all__rrmr�r:r=r"rRrwrrrrrrrHrv�Lockrurergrlrrrrxrrr r rrr �_py__get_running_loop�_py__set_running_loop�_py_get_running_loop�_py_get_event_loop�_asyncio�_c__get_running_loop�_c__set_running_loop�_c_get_running_loop�_c_get_event_loop�ImportError�hasattrr��register_at_forkrUr+r)�<module>r�s]��'� ��� � � �� ���J�J�Z<�&�<�~'!�'!�TT"�T"�n"�"�DD$�!8�D$�V�� � ������9�?�?���� � � �1�:�� � 4� 1� 4� 7� >�*��)��'��#�� '�<�<�-��,��*��&���2�v��!��B���w�/���� �� �s�=C2�2C:�9C:__pycache__/exceptions.cpython-312.opt-2.pyc000064400000004623151706172560014617 0ustar00� T��h���� dZGd�de�ZeZGd�de�ZGd�de�ZGd�de�Z Gd �d e�Z Gd�de�Zy ))�BrokenBarrierError�CancelledError�InvalidStateError�TimeoutError�IncompleteReadError�LimitOverrunError�SendfileNotAvailableErrorc��eZdZy)rN��__name__� __module__�__qualname__���+/usr/lib64/python3.12/asyncio/exceptions.pyrr s��+rrc��eZdZy)rNr rrrrrs��5rrc��eZdZy)rNr rrrrrs��rrc�&��eZdZ �fd�Zd�Z�xZS)rc�|��|�dn t|�}t�|� t|��d|�d��||_||_y)N� undefinedz bytes read on a total of z expected bytes)�repr�super�__init__�len�partial�expected)�selfrr� r_expected� __class__s �rrzIncompleteReadError.__init__$sE���$,�$4�[�$�x�.� � ���C��L�>�)C�&�<��8� 9���� �� rc�H�t|�|j|jffS�N)�typerr�rs r� __reduce__zIncompleteReadError.__reduce__+s���D�z�D�L�L�$�-�-�8�8�8r�rrr rr#� __classcell__�rs@rrrs����!�9rrc�&��eZdZ �fd�Zd�Z�xZS)rc�2��t�|�|�||_yr )rr�consumed)r�messager)rs �rrzLimitOverrunError.__init__5s��� ����!� �� rc�N�t|�|jd|jffS)N�)r!�argsr)r"s rr#zLimitOverrunError.__reduce__9s"���D�z�D�I�I�a�L�$�-�-�8�8�8rr$r&s@rrr/s���� !�9rrc��eZdZy)rNr rrrrr=s��4rrN)�__all__� BaseExceptionrr� Exceptionr�RuntimeErrorr�EOFErrorrrrrrr�<module>r4s^���(��,�]�,���6� �6����9�(�9�$9� �9�5��5r__pycache__/format_helpers.cpython-312.opt-1.pyc000064400000007435151706172560015453 0ustar00� T��hd ��Z�ddlZddlZddlZddlZddlZddlmZd�Zd�Zd�Z d d�Z d d�Zy)�N�)� constantsc�\�tj|�}tj|�r$|j}|j|j fSt |tj�rt|j�St |tj�rt|j�Sy�N)�inspect�unwrap� isfunction�__code__�co_filename�co_firstlineno� isinstance� functools�partial�_get_function_source�func� partialmethod)r�codes �//usr/lib64/python3.12/asyncio/format_helpers.pyrr s���>�>�$��D����$���}�}��� � �$�"5�"5�6�6��$� �)�)�*�#�D�I�I�.�.��$� �/�/�0�#�D�I�I�.�.��c�\�t||d�}t|�}|r|d|d�d|d��z }|S)Nz at r�:r)�_format_callbackr)r�args� func_repr�sources r�_format_callback_sourcersB�� ��t�T�2�I� !�$� '�F� ��t�F�1�I�;�a��q� �{�3�3� ��rc���g}|r|jd�|D��|r&|jd�|j�D��djdj|��S)z�Format function arguments and keyword arguments. Special case for a single parameter: ('hello',) is formatted as ('hello'). c3�FK�|]}tj|����y�wr��reprlib�repr)�.0�args r� <genexpr>z*_format_args_and_kwargs.<locals>.<genexpr>&s����7�$�3�W�\�\�#�&�$�s�!c3�VK�|]!\}}|�dtj|������#y�w)�=Nr)r"�k�vs rr$z*_format_args_and_kwargs.<locals>.<genexpr>(s)����I�.�$�!�Q��s�!�G�L�L��O�,�-�.�s�')z({})z, )�extend�items�format�join)r�kwargsr*s r�_format_args_and_kwargsr.sQ�� �E�� ���7�$�7�7� � ���I�&�,�,�.�I�I��=�=����5�)�*�*rc��t|tj�r;t||�|z}t |j |j|j|�St|d�r|jr |j}n0t|d�r|jr |j}nt|�}|t||�z }|r||z }|S)N�__qualname__�__name__)r rrr.rrr�keywords�hasattrr0r1r!)rrr-�suffixrs rrr,s����$� �)�)�*�(��v�6��?���� � �4�9�9�d�m�m�V�L�L��t�^�$��):�):��%�%� � ��z� "�t�}�}��M�M� ���J� � �(��v�6�6�I� ��V�� ��rc���|�tj�j}|�tj}t jjtj|�|d��}|j�|S)zlReplacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. F)�limit�lookup_lines) �sys� _getframe�f_backr�DEBUG_STACK_DEPTH� traceback�StackSummary�extract� walk_stack�reverse)�fr6�stacks r� extract_stackrC>sj�� �y��M�M�O�"�"���}��+�+���"�"�*�*�9�+?�+?��+B�16�8=� +� ?�E� �M�M�O��Lr)�)NN)rrr r8r<rDrrrr.rrC�rr�<module>rFs0����� ��� ��+��$r__pycache__/format_helpers.cpython-312.opt-2.pyc000064400000007070151706172560015447 0ustar00� T��hd ��Z�ddlZddlZddlZddlZddlZddlmZd�Zd�Zd�Z d d�Z d d�Zy)�N�)� constantsc�\�tj|�}tj|�r$|j}|j|j fSt |tj�rt|j�St |tj�rt|j�Sy�N)�inspect�unwrap� isfunction�__code__�co_filename�co_firstlineno� isinstance� functools�partial�_get_function_source�func� partialmethod)r�codes �//usr/lib64/python3.12/asyncio/format_helpers.pyrr s���>�>�$��D����$���}�}��� � �$�"5�"5�6�6��$� �)�)�*�#�D�I�I�.�.��$� �/�/�0�#�D�I�I�.�.��c�\�t||d�}t|�}|r|d|d�d|d��z }|S)Nz at r�:r)�_format_callbackr)r�args� func_repr�sources r�_format_callback_sourcersB�� ��t�T�2�I� !�$� '�F� ��t�F�1�I�;�a��q� �{�3�3� ��rc��� g}|r|jd�|D��|r&|jd�|j�D��djdj|��S)Nc3�FK�|]}tj|����y�wr��reprlib�repr)�.0�args r� <genexpr>z*_format_args_and_kwargs.<locals>.<genexpr>&s����7�$�3�W�\�\�#�&�$�s�!c3�VK�|]!\}}|�dtj|������#y�w)�=Nr)r"�k�vs rr$z*_format_args_and_kwargs.<locals>.<genexpr>(s)����I�.�$�!�Q��s�!�G�L�L��O�,�-�.�s�')z({})z, )�extend�items�format�join)r�kwargsr*s r�_format_args_and_kwargsr.sV��� �E�� ���7�$�7�7� � ���I�&�,�,�.�I�I��=�=����5�)�*�*rc��t|tj�r;t||�|z}t |j |j|j|�St|d�r|jr |j}n0t|d�r|jr |j}nt|�}|t||�z }|r||z }|S)N�__qualname__�__name__)r rrr.rrr�keywords�hasattrr0r1r!)rrr-�suffixrs rrr,s����$� �)�)�*�(��v�6��?���� � �4�9�9�d�m�m�V�L�L��t�^�$��):�):��%�%� � ��z� "�t�}�}��M�M� ���J� � �(��v�6�6�I� ��V�� ��rc�� |�tj�j}|�tj}t jjtj|�|d��}|j�|S)NF)�limit�lookup_lines) �sys� _getframe�f_backr�DEBUG_STACK_DEPTH� traceback�StackSummary�extract� walk_stack�reverse)�fr6�stacks r� extract_stackrC>so��� �y��M�M�O�"�"���}��+�+���"�"�*�*�9�+?�+?��+B�16�8=� +� ?�E� �M�M�O��Lr)�)NN)rrr r8r<rDrrrr.rrC�rr�<module>rFs0����� ��� ��+��$r__pycache__/futures.cpython-312.opt-1.pyc000064400000041064151706172560014132 0ustar00� T��h8��j�dZdZddlZddlZddlZddlZddlmZddl m Z ddl mZddl mZdd l m Z e jZe jZe j Ze j"Zej$dz ZGd �d�ZeZd�Zd �Zd�Zd�Zd�Zd�Zdd�d�Z ddlZej(xZZy#e$rYywxYw)z.A Future class similar to the one in PEP 3148.)�Future�wrap_future�isfuture�N)�GenericAlias�)�base_futures)�events)� exceptions)�format_helpersc���eZdZdZeZdZdZdZdZ dZ dZdZdZ dd�d�Zd�Zd�Zee�Zed��Zej,d ��Zd �Zd�Zdd�Zd �Zd�Zd�Zd�Zd�Zdd�d�Zd�Z d�Z!d�Z"d�Z#e#Z$y)ra,This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NF��loopc���|�tj�|_n||_g|_|jj �r.tjtjd��|_ yy)z�Initialize the future. The optional event_loop argument allows explicitly setting the event loop object used by the future. If it's not provided, the future uses the default event loop. Nr) r �get_event_loop�_loop� _callbacks� get_debugr� extract_stack�sys� _getframe�_source_traceback��selfrs �(/usr/lib64/python3.12/asyncio/futures.py�__init__zFuture.__init__Hs[���<��.�.�0�D�J��D�J�����:�:���!�%3�%A�%A�� � �a� �&"�D�"�"�c�,�tj|�S�N)r�_future_repr�rs r�__repr__zFuture.__repr__Xs���(�(��.�.rc���|jsy|j}|jj�d�||d�}|jr|j|d<|j j |�y)Nz exception was never retrieved)�message� exception�future�source_traceback)�_Future__log_traceback� _exception� __class__�__name__rr�call_exception_handler)r�exc�contexts r�__del__zFuture.__del__[sl���#�#� ��o�o���>�>�*�*�+�+I�J��� ���!�!�*.�*@�*@�G�&�'�� � �)�)�'�2rc��|jSr)r'r s r�_log_tracebackzFuture._log_tracebackms���#�#�#rc�,�|rtd��d|_y)Nz'_log_traceback can only be set to FalseF)� ValueErrorr')r�vals rr0zFuture._log_tracebackqs����F�G�G�$��rc�8�|j}|�td��|S)z-Return the event loop the Future is bound to.z!Future object is not initialized.)r�RuntimeErrorrs r�get_loopzFuture.get_loopws!���z�z���<��B�C�C��rc��|j�|j}d|_|S|j�tj�}ntj|j�}|j|_d|_|S)z�Create the CancelledError to raise if the Future is cancelled. This should only be called once when handling a cancellation since it erases the saved context exception value. N)�_cancelled_exc�_cancel_messager �CancelledError�__context__)rr,s r�_make_cancelled_errorzFuture._make_cancelled_error~sr�����*��%�%�C�"&�D���J����'��+�+�-�C��+�+�D�,@�,@�A�C��-�-���"���� rc�~�d|_|jtk7ryt|_||_|j�y)z�Cancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)r'�_state�_PENDING� _CANCELLEDr9�_Future__schedule_callbacks)r�msgs r�cancelz Future.cancel�s9�� %����;�;�(�"�� ���"����!�!�#�rc��|jdd}|syg|jdd|D]#\}}|jj|||���%y)z�Internal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. N�r-)rr� call_soon)r� callbacks�callback�ctxs r�__schedule_callbackszFuture.__schedule_callbacks�sM���O�O�A�&� ���������&�M�H�c��J�J� � ��4�� �=�'rc�(�|jtk(S)z(Return True if the future was cancelled.)r>r@r s r� cancelledzFuture.cancelled�s���{�{�j�(�(rc�(�|jtk7S)z�Return True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. )r>r?r s r�donezFuture.done�s���{�{�h�&�&rc� �|jtk(r|j��|jtk7rt j d��d|_|j�%|jj|j��|jS)aReturn the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. zResult is not ready.F)r>r@r<� _FINISHEDr �InvalidStateErrorr'r(�with_traceback� _exception_tb�_resultr s r�resultz Future.result�st���;�;�*�$��,�,�.�.��;�;�)�#��.�.�/E�F�F�$����?�?�&��/�/�0�0��1C�1C�D�D��|�|�rc��|jtk(r|j��|jtk7rt j d��d|_|jS)a&Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.F)r>r@r<rPr rQr'r(r s rr$zFuture.exception�sO���;�;�*�$��,�,�.�.��;�;�)�#��.�.�/F�G�G�$������rrEc���|jtk7r|jj|||��y|�t j �}|jj||f�y)z�Add a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. rEN)r>r?rrF�contextvars�copy_contextr�append)r�fnr-s r�add_done_callbackzFuture.add_done_callback�sR���;�;�(�"��J�J� � ��T�7� �;���%�2�2�4���O�O�"�"�B��=�1rc��|jD��cgc]\}}||k7r||f��}}}t|j�t|�z }|r||jdd|Scc}}w)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. N)r�len)rr[�frI�filtered_callbacks� removed_counts r�remove_done_callbackzFuture.remove_done_callback�sn��/3�o�o�*�.=�(�1�c�!"�b�� !�#�h�.=� �*��D�O�O�,�s�3E�/F�F� ��!3�D�O�O�A����� *s�Ac��|jtk7r$tj|j�d|����||_t |_|j �y)z�Mark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. �: N)r>r?r rQrTrPrA)rrUs r� set_resultzFuture.set_result�sJ���;�;�(�"��.�.�$�+�+��b���/I�J�J��������!�!�#rc�j�|jtk7r$tj|j�d|����t |t �r|�}t |t�rtd�}||_||_ |}||_ |j|_t|_|j�d|_y)z�Mark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. rdzPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r>r?r rQ� isinstance�type� StopIterationr5� __cause__r;r(� __traceback__rSrPrAr')rr$�new_excs r� set_exceptionzFuture.set_exceptions����;�;�(�"��.�.�$�+�+��b���/I�J�J��i��&�!��I��i��/�"�$,�-�G�!*�G��"+�G���I�#���&�4�4�������!�!�#�#��rc#�K�|j�sd|_|��|j�std��|j�S�w)NTzawait wasn't used with future)rN�_asyncio_future_blockingr5rUr s r� __await__zFuture.__await__s=�����y�y�{�,0�D�)��J��y�y�{��>�?�?��{�{�}��s�AA r)%r*� __module__�__qualname__�__doc__r?r>rTr(rrr9r8ror'rr!r.�classmethodr�__class_getitem__�propertyr0�setterr6r<rCrArLrNrUr$r\rbrermrp�__iter__�rrrrs����&�F��G��J��E����O��N� %���O�#�"� /�3� $�L�1�� �$��$����%��%� ��( �>�)�'�� �04�2� � $�$�.��Hrrc�^� |j}|�S#t$rY|jSwxYwr)r6�AttributeErrorr)�futr6s r� _get_loopr}-s:����<�<���z���� ���9�9�� �s�� ,�,c�H�|j�ry|j|�y)z?Helper setting the result only if the future was not cancelled.N)rLre)r|rUs r�_set_result_unless_cancelledr9s�� �}�}����N�N�6�rc�l�t|�}|tjjurt j|j �S|tjjurt j|j �S|tjjurt j|j �S|Sr)rh� concurrent�futuresr:r �args�TimeoutErrorrQ)r,� exc_classs r�_convert_future_excr�@s����S� �I��J�&�&�5�5�5��(�(�#�(�(�3�3� �j�(�(�5�5� 5��&�&����1�1� �j�(�(�:�:� :��+�+�S�X�X�6�6�� rc� �|j�r|j�|j�sy|j�}|�|jt|��y|j �}|j|�y)z8Copy state from a future to a concurrent.futures.Future.N)rLrC�set_running_or_notify_cancelr$rmr�rUre)r��sourcer$rUs r�_set_concurrent_future_stater�Lst������� ����2�:�2�2�4��� � �"�I��� � � � �!4�Y�!?�@������� ���f�%rc��|j�ry|j�r|j�y|j�}|�|jt |��y|j�}|j |�y)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N)rLrCr$rmr�rUre)r��destr$rUs r�_copy_future_stater�[se���~�~��� ������� ��$�$�&� �� ����2�9�=�>��]�]�_�F��O�O�F�#rc�������t��s/t�tjj�std��t��s/t�tjj�std��t��rt ��nd�t��rt ��nd�d�����fd�}����fd�}�j|��j|�y)aChain two futures so that when one completes, so does the other. The result (or exception) of source will be copied to destination. If destination is cancelled, source gets cancelled too. Compatible with both asyncio.Future and concurrent.futures.Future. z(A future is required for source argumentz-A future is required for destination argumentNc�L�t|�r t||�yt||�yr)rr�r�)r%�others r� _set_statez!_chain_future.<locals>._set_states���F���u�f�-�(���7rc���|j�r3����ur�j�y�j�j�yyr)rLrC�call_soon_threadsafe)�destination� dest_loopr��source_loops ���r�_call_check_cancelz)_chain_future.<locals>._call_check_cancel�s<���� � �"��"�k�Y�&>�� � ���0�0����?� #rc����j�r���j�ry����ur ��|�y�j�ry�j��|�yr)rL� is_closedr�)r�r�r�r�r�s ����r�_call_set_statez&_chain_future.<locals>._call_set_state�s[����!�!�#��%�)�*=�*=�*?���� �[� 8��{�F�+��"�"�$���*�*�:�{�F�Kr)rrgr�r�r� TypeErrorr}r\)r�r�r�r�r�r�r�s`` @@@r� _chain_futurer�os�����F��J�v�/9�/A�/A�/H�/H�%J��B�C�C��K� ��K�4>�4F�4F�4M�4M�*O��G�H�H�'/��'7�)�F�#�T�K�*2�;�*?� �+�&�T�I�8�@� L��!�!�"4�5� ���_�-rr c��t|�r|S|�tj�}|j�}t ||�|S)z&Wrap concurrent.futures.Future object.)rr r� create_futurer�)r%r� new_futures rrr�sB������ ��|��$�$�&���#�#�%�J��&�*�%��r) rs�__all__�concurrent.futuresr�rX�loggingr�typesr�rr r rrr?r@rP�DEBUG�STACK_DEBUGr� _PyFuturer}rr�r�r�r�r�_asyncio�_CFuture�ImportErrorryrr�<module>r�s���4������ ������� � ��� � �� � $� $� ��"�"� ��m�m�a���H�H�X � � �� �&�$�().�X!%� �(�� !���'�F�X�� � �� �s�B*�*B2�1B2__pycache__/log.cpython-312.opt-1.pyc000064400000000433151706172560013211 0ustar00� T��h|��4�dZddlZeje�Zy)zLogging configuration.�N)�__doc__�logging� getLogger�__package__�logger���$/usr/lib64/python3.12/asyncio/log.py�<module>rs���� �� � �;� '�r __pycache__/log.cpython-312.opt-2.pyc000064400000000370151706172560013212 0ustar00� T��h|��2� ddlZeje�Zy)�N)�logging� getLogger�__package__�logger���$/usr/lib64/python3.12/asyncio/log.py�<module>r s���� �� � �;� '�r__pycache__/proactor_events.cpython-312.opt-1.pyc000064400000126012151706172560015647 0ustar00� T��h܂���dZdZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl mZddl mZddl m Z dd l mZdd l mZddl mZddl mZdd lmZd�ZGd�dej*ej,�ZGd�deej0�ZGd�deej4�ZGd�de�ZGd�deej:�ZGd�deeej>�Z Gd�deeej>�Z!Gd�de jD�Z#y)z�Event loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. )�BaseProactorEventLoop�N�)�base_events)� constants)�futures)� exceptions)� protocols)�sslproto)� transports)�trsock)�loggerc���tj|�|jd< |j�|jd<d|jvr |j�|jd<yy#tj $r5|jj�rtjd|d��Y�uwxYw#tj $rd|jd<YywxYw)N�socket�socknamezgetsockname() failed on %rT��exc_info�peername)r�TransportSocket�_extra�getsocknamer�error�_loop� get_debugr �warning�getpeername)� transport�socks �0/usr/lib64/python3.12/asyncio/proactor_events.py�_set_socket_extrars���!'�!7�!7��!=�I���X��C�'+�'7�'7�'9� ����$���)�)�)� 0�+/�+;�+;�+=�I���Z�(�*���<�<�C��?�?�$�$�&��N�N�,�d�T� C��C���|�|� 0�+/�I���Z�(� 0�s$�A/�B:�/AB7�6B7�:"C�Cc���eZdZdZ d�fd� Zd�Zd�Zd�Zd�Zd�Z d�Z ejfd �Z dd �Zd�Zd�Zd �Z�xZS)�_ProactorBasePipeTransportz*Base class for pipe and socket transports.c���t�|�||�|j|�||_|j |�||_d|_d|_d|_d|_ d|_ d|_d|_d|_ |j �|j j�|jj!|j"j$|�|�,|jj!t&j(|d�yy)NrF)�super�__init__� _set_extra�_sock�set_protocol�_server�_buffer� _read_fut� _write_fut�_pending_write� _conn_lost�_closing�_called_connection_lost�_eof_written�_attachr� call_soon� _protocol�connection_mader�_set_result_unless_cancelled��self�loopr�protocol�waiter�extra�server� __class__s �rr$z#_ProactorBasePipeTransport.__init__2s���� �����%�������� ����(�#��������������������� �',��$�!����<�<�#��L�L� � �"�� � ���T�^�^�;�;�T�B����J�J� � ��!E�!E�!'�� /��c��|jjg}|j�|jd�n|jr|jd�|j�,|jd|jj����|j�|jd|j���|j�|jd|j���|jr'|jdt|j����|jr|jd�djd j|��S) N�closed�closingzfd=zread=zwrite=zwrite_bufsize=zEOF writtenz<{}>� ) r=�__name__r&�appendr.�filenor*r+r)�lenr0�format�join)r7�infos r�__repr__z#_ProactorBasePipeTransport.__repr__Is������'�'�(���:�:���K�K��!� �]�]��K�K� �"��:�:�!��K�K�#�d�j�j�/�/�1�2�3�4��>�>�%��K�K�%����1�2�3��?�?�&��K�K�&���� 3�4�5��<�<��K�K�.��T�\�\�):�(;�<�=�����K�K� �&��}�}�S�X�X�d�^�,�,r>c�"�||jd<y)N�pipe)r�r7rs rr%z%_ProactorBasePipeTransport._set_extra[s��"����F�r>c��||_y�N�r3)r7r9s rr'z'_ProactorBasePipeTransport.set_protocol^s ��!��r>c��|jSrOrP�r7s r�get_protocolz'_ProactorBasePipeTransport.get_protocolas���~�~�r>c��|jSrO)r.rRs r� is_closingz%_ProactorBasePipeTransport.is_closingds���}�}�r>c�.�|jryd|_|xjdz c_|js2|j�&|jj|jd�|j�"|jj�d|_yy)NTr) r.r-r)r+rr2�_call_connection_lostr*�cancelrRs r�closez _ProactorBasePipeTransport.closegsq���=�=���� ����1����|�|���� 7��J�J� � ��!;�!;�T�B��>�>�%��N�N�!�!�#�!�D�N�&r>c�v�|j�-|d|��t|��|jj�yy)Nzunclosed transport )�source)r&�ResourceWarningrY)r7�_warns r�__del__z"_ProactorBasePipeTransport.__del__rs5���:�:�!��'��x�0�/�$�O��J�J����"r>c�0� t|t�r4|jj�rDt j d||d��n*|jj ||||jd��|j|�y#|j|�wxYw)Nz%r: %sTr)�message� exceptionrr9) � isinstance�OSErrorrrr �debug�call_exception_handlerr3�_force_close)r7�excr`s r�_fatal_errorz'_ProactorBasePipeTransport._fatal_errorwsy�� #��#�w�'��:�:�'�'�)��L�L��4��4�H�� � �1�1�&�!$�!%� $��� 3�� ���c�"��D���c�"�s�A.B�Bc�H�|j�S|jj�s9|�|jjd�n|jj|�|jr |j ryd|_|xjdz c_|jr!|jj�d|_|jr!|jj�d|_ d|_ d|_|jj|j|�y)NTrr)� _empty_waiter�done� set_result� set_exceptionr.r/r-r+rXr*r,r)rr2rW)r7rgs rrfz'_ProactorBasePipeTransport._force_close�s������)�$�2D�2D�2I�2I�2K��{��"�"�-�-�d�3��"�"�0�0��5��=�=�T�9�9���� ����1����?�?��O�O�"�"�$�"�D�O��>�>��N�N�!�!�#�!�D�N�������� � ���T�7�7��=r>c��|jry |jj|�t|jd�rF|jj�dk7r)|jj tj�|jj�d|_|j}|�|j�d|_ d|_y#t|jd�rF|jj�dk7r)|jj tj�|jj�d|_|j}|�|j�d|_ d|_wxYw)N�shutdown���T)r/r3�connection_lost�hasattrr&rEror� SHUT_RDWRrYr(�_detach)r7rgr<s rrWz0_ProactorBasePipeTransport._call_connection_lost�s���'�'�� 0��N�N�*�*�3�/��t�z�z�:�.�4�:�:�3D�3D�3F�"�3L�� � �#�#�F�$4�$4�5��J�J�����D�J��\�\�F��!���� �#���+/�D�(���t�z�z�:�.�4�:�:�3D�3D�3F�"�3L�� � �#�#�F�$4�$4�5��J�J�����D�J��\�\�F��!���� �#���+/�D�(�s�C�B+E?c�f�|j}|j�|t|j�z }|SrO)r,r)rF)r7�sizes r�get_write_buffer_sizez0_ProactorBasePipeTransport.get_write_buffer_size�s/���"�"���<�<�#��C����%�%�D��r>�NNN)zFatal error on pipe transport)rC� __module__�__qualname__�__doc__r$rJr%r'rSrUrY�warnings�warnr^rhrfrWrw� __classcell__�r=s@rr!r!.sQ���4�48�$(�/�.-�$#�"��� "�%�M�M�� #�>�(0�(r>r!c�N��eZdZdZ d �fd� Zd�Zd�Zd�Zd�Zd�Z d d�Z �xZS)�_ProactorReadPipeTransportzTransport for read pipes.c����d|_d|_t�|� ||||||�t |�|_|jj|j�d|_y)NrpTF) �_pending_data_length�_pausedr#r$� bytearray�_datarr2� _loop_reading) r7r8rr9r:r;r<�buffer_sizer=s �rr$z#_ProactorReadPipeTransport.__init__�sT���$&��!���� ����t�X�v�u�f�E��{�+�� �� � ���T�/�/�0���r>c�:�|jxr |jSrO)r�r.rRs r� is_readingz%_ProactorReadPipeTransport.is_reading�s���<�<��5�� � �$5�5r>c��|js|jryd|_|jj�rt j d|�yy)NTz%r pauses reading)r.r�rrr rdrRs r� pause_readingz(_ProactorReadPipeTransport.pause_reading�s?���=�=�D�L�L������:�:���!��L�L�,�d�3�"r>c��|js|jsyd|_|j�&|jj |j d�|j}d|_|dkDr4|jj |j|jd||�|jj�rtjd|�yy)NFrpz%r resumes reading)r.r�r*rr2r�r��_data_receivedr�rr rd)r7�lengths r�resume_readingz)_ProactorReadPipeTransport.resume_reading�s����=�=���������>�>�!��J�J� � ��!3�!3�T�:��*�*��$&��!��B�;� �J�J� � ��!4�!4�d�j�j��&�6I�6�R��:�:���!��L�L�-�t�4�"r>c�.�|jj�rtjd|� |jj�}|s|j�yy#ttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.)rrr rdr3�eof_received� SystemExit�KeyboardInterrupt� BaseExceptionrhrY)r7� keep_openrgs r� _eof_receivedz(_ProactorReadPipeTransport._eof_received�s����:�:���!��L�L�*�D�1� ����3�3�5�I���J�J�L����-�.� ��� �����H� J��� �s�A � B�8B�Bc��|jr||_y|dk(r|j�yt|jt j�r" tj|j|�y|jj|�y#ttf$r�t$r}|j|d�Yd}~yd}~wwxYw)Nrz3Fatal error: protocol.buffer_updated() call failed.) r�r�r�rbr3r �BufferedProtocol�_feed_data_to_buffered_protor�r�r�rh� data_received)r7�datar�rgs rr�z)_ProactorReadPipeTransport._data_received�s����<�<�)/�D�%���Q�;���� ���d�n�n�i�&@�&@�A� ��6�6�t�~�~�t�L� �N�N�(�(��.��� 1�2� �� � ��!�!�#�#1�2��� �s� B � C�%B<�<Cc�J�d}d} |�xd|_|j�rQ|j�}|dk(r |dkDr|j||�yyt t|j�d|�}n|j�|jr |dkDr|j||�yy|js?|jjj|j|j�|_|js&|jj|j� |dkDr|j||�yy#t $rZ}|js|j#|d�n1|jj%�rt'j(dd��Yd}~�wd}~wt*$r}|j-|�Yd}~��d}~wt.$r}|j#|d�Yd}~��d}~wt0j2$r|js�Y��wxYw#|dkDr|j||�wwxYw)Nrprz"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)r*rk�resultr��bytes� memoryviewr�rXr.r�r� _proactor� recv_intor&�add_done_callbackr��ConnectionAbortedErrorrhrr rd�ConnectionResetErrorrfrcr�CancelledError)r7�futr�r�rgs rr�z(_ProactorReadPipeTransport._loop_readings�������. 2���"&����8�8�:� �Z�Z�\�F���{��F��{��#�#�D�&�1��A!��D�J�J�!7���!@�A�D��J�J�L��}�}��2��{��#�#�D�&�1��)�<�<�!%���!5�!5�!?�!?�� � �D�J�J�!W����<�<����0�0��1C�1C�D���{��#�#�D�&�1���#&� ,��=�=��!�!�#�'K�L����%�%�'����I�&*�,���#� #����c�"�"��� I����c�#G�H�H���(�(� ��=�=��!� ����{��#�#�D�&�1��sm�.D<�>D<�&AD<�12H�< H�AF�H�H�&F<�7H�<H�G�H�#H�H�H�H�H")NNNirO)rCryrzr{r$r�r�r�r�r�r�r~rs@rr�r��s/���#�48�6;��6�4�&5�$� /�212r>r�c�R��eZdZdZdZ�fd�Zd�Zdd�Zd�Zd�Z d�Z d �Zd �Z�xZ S)�_ProactorBaseWritePipeTransportzTransport for write pipes.Tc�2��t�|�|i|��d|_yrO)r#r$rj�r7�args�kwr=s �rr$z(_ProactorBaseWritePipeTransport.__init__Ns��� ���$�%�"�%�!��r>c��t|tttf�s!t dt|�j����|jrtd��|j�td��|sy|jrH|jtjk\rtjd�|xjdz c_ y|j�|j!t|���y|j"s!t|�|_|j%�y|j"j'|�|j%�y)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)r�)rbr�r�r�� TypeError�typerCr0�RuntimeErrorrjr-r�!LOG_THRESHOLD_FOR_CONNLOST_WRITESr rr+� _loop_writingr)�_maybe_pause_protocol�extend)r7r�s r�writez%_ProactorBaseWritePipeTransport.writeRs���$�� �:� >�?����D�z�*�*�+�-�.� .�����;�<�<����)��I�J�J����?�?����)�"M�"M�M����@�A��O�O�q� �O���?�?�"� ���E�$�K��0����$�T�?�D�L��&�&�(� �L�L����%��&�&�(r>c�� |�|j� |jryd|_d|_|r|j�|�|j}d|_|sx|jr&|j j |jd�|jr)|jjtj�|j�n�|j jj|j|�|_|jj!�sFt#|�|_|jj%|j&�|j)�n%|jj%|j&�|j*�)|j�|j*j-d�yyy#t.$r}|j1|�Yd}~yd}~wt2$r}|j5|d�Yd}~yd}~wwxYw)Nrz#Fatal write error on pipe transport)r+r.r,r�r)rr2rWr0r&ror�SHUT_WR�_maybe_resume_protocolr��sendrkrFr�r�r�rjrlr�rfrcrh)r7�fr�rgs rr�z-_ProactorBaseWritePipeTransport._loop_writingxs���& J��}����!8�T�]�]��"�D�O�"#�D������ ��|��|�|��#�����=�=��J�J�(�(��)C�)C�T�J��$�$��J�J�'�'����7��+�+�-�"&�*�*�"6�"6�";�";�D�J�J��"M������+�+�-�*-�d�)�D�'��O�O�5�5�d�6H�6H�I��.�.�0��O�O�5�5�d�6H�6H�I��!�!�-�$�/�/�2I��"�"�-�-�d�3�3J�-��#� #����c�"�"��� J����c�#H�I�I�� J�s)�F<�FF<�< H�G�H�'G>�>Hc��y�NT�rRs r� can_write_eofz-_ProactorBaseWritePipeTransport.can_write_eof����r>c�$�|j�yrO)rYrRs r� write_eofz)_ProactorBaseWritePipeTransport.write_eof�s��� � �r>c�&�|jd�yrO�rfrRs r�abortz%_ProactorBaseWritePipeTransport.abort�������$�r>c���|j�td��|jj�|_|j�|jjd�|jS)NzEmpty waiter is already set)rjr�r� create_futurer+rlrRs r�_make_empty_waiterz2_ProactorBaseWritePipeTransport._make_empty_waiter�sY�����)��<�=�=�!�Z�Z�5�5�7����?�?�"����)�)�$�/��!�!�!r>c��d|_yrO)rjrRs r�_reset_empty_waiterz3_ProactorBaseWritePipeTransport._reset_empty_waiter�s ��!��r>�NN)rCryrzr{�_start_tls_compatibler$r�r�r�r�r�r�r�r~rs@rr�r�Hs7���$� ��"�$)�L'J�R�� �"�"r>r�c�$��eZdZ�fd�Zd�Z�xZS)�_ProactorWritePipeTransportc����t�|�|i|��|jjj |j d�|_|jj|j�y)N�) r#r$rr��recvr&r*r��_pipe_closedr�s �rr$z$_ProactorWritePipeTransport.__init__�sO��� ���$�%�"�%����-�-�2�2�4�:�:�r�B������(�(��):�):�;r>c��|j�ry|jryd|_|j�|j t��y|j �yrO)� cancelledr.r*r+rf�BrokenPipeErrorrY)r7r�s rr�z(_ProactorWritePipeTransport._pipe_closed�sC���=�=�?���=�=������?�?�&����o�/�0��J�J�Lr>)rCryrzr$r�r~rs@rr�r��s ���<� r>r�c�R��eZdZdZ d �fd� Zd�Zd�Zd�Zd d�Zd d�Z d d�Z �xZS)�_ProactorDatagramTransportic����||_d|_d|_t�|�|||||��tj�|_|jj|j�y)Nr)r:r;)�_addressrj�_buffer_sizer#r$�collections�dequer)rr2r�)r7r8rr9�addressr:r;r=s �rr$z#_ProactorDatagramTransport.__init__�s^����� �!������ ����t�X�f�E��J�#�(�(�*���� � ���T�/�/�0r>c��t||�yrO�rrMs rr%z%_ProactorDatagramTransport._set_extra�����$��%r>c��|jSrO)r�rRs rrwz0_ProactorDatagramTransport.get_write_buffer_size�s��� � � r>c�&�|jd�yrOr�rRs rr�z _ProactorDatagramTransport.abort�r�r>c�r�t|tttf�st dt|���|sy|j�(|d|jfvrtd|j����|jrT|jrH|jtjk\rtjd�|xjdz c_y|jjt|�|f�|xjt!|�z c_|j"�|j%�|j'�y)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rbr�r�r�r�r�r�� ValueErrorr-rr�r rr)rDr�rFr+r�r�)r7r��addrs r�sendtoz!_ProactorDatagramTransport.sendto�s����$�� �:� >�?��J� ��J�(� (����=�=�$��d�D�M�M�5J�)J��3�D�M�M�?�C�E� E��?�?�t�}�}����)�"M�"M�M����B�C��O�O�q� �O�� �����U�4�[�$�/�0����S��Y�&���?�?�"���� � �"�"�$r>c�z� |jryd|_|r|j�|jr|jr?|jr3|j r&|jj|jd�y|jj�\}}|xjt|�zc_ |j�6|jjj|j|�|_n7|jjj|j||��|_|jj!|j"�|j%�y#t&$r%}|j(j+|�Yd}~yd}~wt,$r}|j/|d�Yd}~yd}~wwxYw)N)r�z'Fatal write error on datagram transport)r-r+r�r)r�r.rr2rW�popleftr�rFr�r�r&r�r�r�r�rcr3�error_received� Exceptionrh)r7r�r�r�rgs rr�z(_ProactorDatagramTransport._loop_writingsT�� *�����#�D�O��� � ���<�<�D�O�O�� � ��=�=��J�J�(�(��)C�)C�T�J�����-�-�/�J�D�$�����T��*���}�}�(�"&�*�*�"6�"6�";�";�D�J�J�<@�#B���#'�*�*�"6�"6�"=�"=�d�j�j�>B�CG�#>�#I��� �O�O�-�-�d�.@�.@�A��'�'�)�� � /��N�N�)�)�#�.�.��� N����c�#L�M�M�� N�s0�E)�A/E)�?B4E)�) F:�2F�F:�F5�5F:c�2�d} |jr! |r|jj|�yyd|_|�_|j �}|j r#d} |r|jj|�yy|j�||j}}n|\}}|jr! |r|jj|�yy|j�@|jjj|j|j�|_n?|jjj|j|j�|_|j�&|jj|j� |r|jj|�yy#t$r%}|jj!|�Yd}~�Id}~wt"j$$r|j s�Y�nwxYw#|r|jj|�wwxYwrO)r-r3�datagram_receivedr*r�r.r�rr�r�r&�max_size�recvfromr�r�rcr�rr�)r7r�r�r��resrgs rr�z(_ProactorDatagramTransport._loop_reading$s�����' =�����H����0�0��t�<��?"�D�N����j�j�l���=�=��D��0����0�0��t�<��-�=�=�,�!$�d�m�m�$�D�!$�J�D�$����� ����0�0��t�<���}�}�(�!%���!5�!5�!:�!:�4�:�:�;?�=�=�"J���"&���!5�!5�!>�!>�t�z�z�?C�}�}�"N����~�~�)����0�0��1C�1C�D�����0�0��t�<���� /��N�N�)�)�#�.�.���(�(� ��=�=��!� ������0�0��t�<��sM�F#�'F#�9,F#�BF#�2G5�# G2�,G�G5�#G2�/G5�1G2�2G5�5!HrxrO)rCryrzr�r$r%rwr�r�r�r�r~rs@rr�r��s2����H�59�$(�1�&�!� �%�: *�D)=r>r�c��eZdZdZd�Zd�Zy)�_ProactorDuplexPipeTransportzTransport for duplex pipes.c��y)NFr�rRs rr�z*_ProactorDuplexPipeTransport.can_write_eofUs��r>c��t�rO)�NotImplementedErrorrRs rr�z&_ProactorDuplexPipeTransport.write_eofXs��!�!r>N)rCryrzr{r�r�r�r>rr�r�Ps��&��"r>r�c�f��eZdZdZej jZ d�fd� Zd�Z d�Z d�Z�xZS)�_ProactorSocketTransportz Transport for connected sockets.c�X��t�|�||||||�tj|�yrO)r#r$r�_set_nodelayr6s �rr$z!_ProactorSocketTransport.__init__cs(��� ����t�X�v�u�f�E�� � ��&r>c��t||�yrOr�rMs rr%z#_ProactorSocketTransport._set_extrahr�r>c��yr�r�rRs rr�z&_ProactorSocketTransport.can_write_eofkr�r>c��|js|jryd|_|j�*|jj t j�yyr�)r.r0r+r&rorr�rRs rr�z"_ProactorSocketTransport.write_eofnsA���=�=�D�-�-�� ����?�?�"��J�J������/�#r>rx) rCryrzr{r� _SendfileMode� TRY_NATIVE�_sendfile_compatibler$r%r�r�r~rs@rr�r�\s4���+�$�2�2�=�=��48�$(�'� &��0r>r�c����eZdZ�fd�Z dd�Z dddddddd�d�Z dd�Z d d�Z d d �Z d d �Z �fd�Z d�Zd �Zd�Z d!d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�Z d"d�Zd�Zd�Zd�Z�xZS)#rc���t�|��tjd|jj �||_||_d|_i|_ |j|�|j�tj�tj�ur.tj |j"j%��yy)NzUsing proactor: %s)r#r$r rdr=rCr�� _selector�_self_reading_future�_accept_futures�set_loop�_make_self_pipe� threading�current_thread�main_thread�signal� set_wakeup_fd�_csockrE)r7�proactorr=s �rr$zBaseProactorEventLoop.__init__xs���� �������)�8�+=�+=�+F�+F�G�!���!���$(��!�!������$�������#�#�%��)>�)>�)@�@�� � ����!3�!3�!5�6�Ar>Nc�"�t||||||�SrO)r�)r7rr9r:r;r<s r�_make_socket_transportz,BaseProactorEventLoop._make_socket_transport�s��'��d�H�f�(-�v�7� 7r>F)�server_side�server_hostnamer;r<�ssl_handshake_timeout�ssl_shutdown_timeoutc �t�tj||||||| | ��}t|||||��|jS)N)rr�r;r<)r �SSLProtocolr��_app_transport)r7�rawsockr9� sslcontextr:rrr;r<rr�ssl_protocols r�_make_ssl_transportz)BaseProactorEventLoop._make_ssl_transport�sI�� �+�+��h� �F��_�&;�%9� ;�� !��w��',�V� =��*�*�*r>c�"�t||||||�SrO)r�)r7rr9r�r:r;s r�_make_datagram_transportz.BaseProactorEventLoop._make_datagram_transport�s��)�$��h��*0�%�9� 9r>c� �t|||||�SrO)r��r7rr9r:r;s r�_make_duplex_pipe_transportz1BaseProactorEventLoop._make_duplex_pipe_transport�s��+�D�,0�(�F�E�K� Kr>c� �t|||||�SrO)r�rs r�_make_read_pipe_transportz/BaseProactorEventLoop._make_read_pipe_transport�s��)�$��h���N�Nr>c� �t|||||�SrO)r�rs r�_make_write_pipe_transportz0BaseProactorEventLoop._make_write_pipe_transport�s��+�4�+/��6�5�J� Jr>c���|j�rtd��|j�rytj�tj �urt jd�|j�|j�|jj�d|_ d|_t�|�-�y)Nz!Cannot close a running event looprp)� is_runningr�� is_closedrrr r r�_stop_accept_futures�_close_self_piper�rYrr#)r7r=s �rrYzBaseProactorEventLoop.close�s�����?�?���B�C�C��>�>����#�#�%��)>�)>�)@�@�� � ��$� �!�!�#����������������� �� �r>c��VK�|jj||��d{���S7��wrO)r�r�)r7r�ns r� sock_recvzBaseProactorEventLoop.sock_recv�s#�����^�^�(�(��q�1�1�1�1��� )�'�)c��VK�|jj||��d{���S7��wrO)r�r�)r7r�bufs r�sock_recv_intoz$BaseProactorEventLoop.sock_recv_into�s#�����^�^�-�-�d�C�8�8�8�8�r-c��VK�|jj||��d{���S7��wrO)r�r�)r7r�bufsizes r� sock_recvfromz#BaseProactorEventLoop.sock_recvfrom�s#�����^�^�,�,�T�7�;�;�;�;�r-c��rK�|st|�}|jj|||��d{���S7��wrO)rFr�� recvfrom_into)r7rr/�nbytess r�sock_recvfrom_intoz(BaseProactorEventLoop.sock_recvfrom_into�s1�������X�F��^�^�1�1�$��V�D�D�D�D�s�.7�5�7c��VK�|jj||��d{���S7��wrO)r�r�)r7rr�s r�sock_sendallz"BaseProactorEventLoop.sock_sendall�s#�����^�^�(�(��t�4�4�4�4�r-c��ZK�|jj||d|��d{���S7��w)Nr)r�r�)r7rr�r�s r�sock_sendtoz!BaseProactorEventLoop.sock_sendto�s'�����^�^�*�*�4��q�'�B�B�B�B�s�"+�)�+c��K�|jr|j�dk7rtd��|jj ||��d{���S7��w)Nrzthe socket must be non-blocking)�_debug� gettimeoutr�r��connect)r7rr�s r�sock_connectz"BaseProactorEventLoop.sock_connect�sD�����;�;�4�?�?�,��1��>�?�?��^�^�+�+�D�'�:�:�:�:�s�A A�A� Ac��TK�|jj|��d{���S7��wrO)r��acceptrMs r�sock_acceptz!BaseProactorEventLoop.sock_accept�s!�����^�^�*�*�4�0�0�0�0�s�(�&�(c��K� |j�} t j|�j}|r|n|}|syt|d�}|rt||z|�n|} t||�}d} t| |z |�}|dkr| | dkDr|j|�SS|jj||||��d{���||z }| |z } �^#ttjf$r}t j d��d}~wwxYw#t$rt j d��wxYw7�g#| dkDr|j|�wwxYw�w)Nznot a regular filerl��)rE�AttributeError�io�UnsupportedOperationr�SendfileNotAvailableError�os�fstat�st_sizerc�min�seekr��sendfile)r7r�file�offset�countrE�err�fsize� blocksize�end_pos� total_sents r�_sock_sendfile_nativez+BaseProactorEventLoop._sock_sendfile_native�s_���� M��[�[�]�F� M��H�H�V�$�,�,�E�#�E�� ���� �;�/� �05�#�f�u�n�e�,�5���V�U�#��� � "����&� 0�)�<� ���>�%� �A�~�� � �&�!�� �n�n�-�-�d�D�&�)�L�L�L��)�#���i�'� � ���� 7� 7�8� M��6�6�7K�L�L�� M��� M��6�6�7K�L�L� M��M���A�~�� � �&�!��sh�E�C �D�6E�+D$�E�!D$�:D"�;D$� C=�#C8�8C=�=E�D�E�"D$�$D=�=Ec��jK�|j�}|j�|j��d{��� |j|j|||d���d{���|j�|r|j �SS7�P7�)#|j�|r|j �wwxYw�w)NF)�fallback)r�r�r�� sock_sendfiler&r�r�)r7�transprOrPrQr�s r�_sendfile_nativez&BaseProactorEventLoop._sendfile_native�s������*�*�,�������'�'�)�)�)� (��+�+�F�L�L�$���5:�,�<�<� �&�&�(���%�%�'�� *��<�� �&�&�(���%�%�'��s8�4B3�B�B3�#B�B � B�#%B3� B�%B0�0B3c��|j�!|jj�d|_|jj�d|_|jj�d|_|xj dzc_y)Nr)rrX�_ssockrYr� _internal_fdsrRs rr)z&BaseProactorEventLoop._close_self_pipesg���$�$�0��%�%�,�,�.�(,�D�%����������������������a��r>c���tj�\|_|_|jj d�|jj d�|xj dz c_y)NFr)r� socketpairr^r�setblockingr_rRs rrz%BaseProactorEventLoop._make_self_pipesN��#)�#4�#4�#6� ���T�[�������&�������&����a��r>c�t� |�|j�|j|ury|jj|jd�}||_|j|j�y#tj$rYyttf$r�t$r}|jd||d��Yd}~yd}~wwxYw)Niz.Error on reading from the event loop self pipe)r`rar8) r�rr�r�r^r��_loop_self_readingrr�r�r�r�re)r7r�rgs rrdz(BaseProactorEventLoop._loop_self_readings��� 9��}���� ��(�(��1�����#�#�D�K�K��6�A�)*�D�%� ���� 7� 7�8���(�(� ���-�.� ��� ��'�'�K� ��)� � �� �s"� A,�&A,�,B7�B7�B2�2B7c��|j}|�y |jd�y#t$r(|jrt j dd��YyYywxYw)N�z3Fail to write a null byte into the self-pipe socketTr)rr�rcr=r rd)r7�csocks r�_write_to_selfz$BaseProactorEventLoop._write_to_self4sU�������=�� ,��J�J�u���� ,��{�{����0�&*�,�� ,�s�#�,A�Ac �P���������d��������fd� ��j��y)Nc ��� |�s|j�\}}�jrtjd�||���}���j ||�dd|i�� ���n�j||d|i����j �ry�jj� �}|�j� j�<|j��y#t$r�}� j�dk7r9�jd|tj� �d��� j!�n.�jrtjd � d� �Yd}~yYd}~yYd}~yd}~wt"j$$r� j!�YywxYw)Nz#%r got a new connection from %r: %rTr)rr;r<rrrrpzAccept failed on a socket)r`rarzAccept failed on socket %rr)r�r=r rdrrr'r�rBrrEr�rcrerrrYrr�) r��connr�r9rgr8�protocol_factoryr7r<rrrrs ��������rr8z2BaseProactorEventLoop._start_serving.<locals>.loopKsw���# *��=�!"����J�D�$��{�{����%J�%+�T�4�9�/�1�H�!�-��0�0� �(�J�D�#-�t�"4�V�2G�1E� 1�G��3�3� �(�#-�t�"4�V�4�E��>�>�#���N�N�)�)�$�/��78��$�$�T�[�[�]�3��#�#�D�)��� 6��;�;�=�B�&��/�/�#>�%(�"(�"8�"8��">�1�� �J�J�L��[�[��L�L�!=�!%��6�6�!�!���,�,� �� � �� �s%�BC� C� F�A0E�&F�FrO)r2) r7rlrrr<�backlogrrr8s ````` ``@r�_start_servingz$BaseProactorEventLoop._start_servingFs��� $ *�$ *�L ���t�r>c��yrOr�)r7� event_lists r�_process_eventsz%BaseProactorEventLoop._process_eventsss��r>c��|jj�D]}|j��|jj�yrO)r�valuesrX�clear)r7�futures rr(z*BaseProactorEventLoop._stop_accept_futuresws6���*�*�1�1�3�F��M�M�O�4����"�"�$r>c���|jj|j�d�}|r|j�|jj|�|j �yrO)r�poprErXr�� _stop_servingrY)r7rrus rrxz#BaseProactorEventLoop._stop_serving|sG���%�%�)�)�$�+�+�-��>����M�M�O����$�$�T�*�� � �r>rxrOr�)r)NN�dNN)rCryrzr$rrrr r"r$rYr,r0r3r7r9r;r@rCrWr\r)rrdrhrnrqr(rxr~rs@rrrvs����7�=A�26�7�9=� +� �$��t�"&�!%� +� CG�9� BF�*.�K� @D�(,�O�AE�)-�J��(2�9�<�E�5�C�;� 1�"�: (� � �9�8,�&>A�-1�,0�+�Z �%� r>r)$r{�__all__rFrIrr|r rr��rrrrr r rr�logr r�_FlowControlMixin� BaseTransportr!� ReadTransportr��WriteTransportr�r��DatagramTransportr�� Transportr�r�� BaseEventLooprr�r>r�<module>r�s���#�� � � �� ������������0�$D��!=�!=�!+�!9�!9�D�NP2�!;�!+�!9�!9�P2�fk"�&@�&0�&?�&?�k"�\�"A��,A=�!;�!+�!=�!=�A=�H "�#=�#B�#-�#7�#7� "�0�9�>�)�3�3�0�4K�K�5�5�Kr>__pycache__/queues.cpython-312.opt-1.pyc000064400000027247151706172560013753 0ustar00� T��h&���dZddlZddlZddlmZddlmZddlmZGd�de�Z Gd �d e�Z Gd�dej�ZGd �de�Z Gd�de�Zy))�Queue� PriorityQueue� LifoQueue� QueueFull� QueueEmpty�N)�GenericAlias�)�locks)�mixinsc��eZdZdZy)rz;Raised when Queue.get_nowait() is called on an empty Queue.N��__name__� __module__�__qualname__�__doc__���'/usr/lib64/python3.12/asyncio/queues.pyrrs��E�rrc��eZdZdZy)rzDRaised when the Queue.put_nowait() method is called on a full Queue.Nr rrrrrs��N�rrc��eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z d�Z ee�Z d �Zd �Zed��Zd�Zd �Zd�Zd�Zd�Zd�Zd�Zd�Zy)raA queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "await put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. c��||_tj�|_tj�|_d|_t j�|_|jj�|j|�y)Nr)�_maxsize�collections�deque�_getters�_putters�_unfinished_tasksr �Event� _finished�set�_init��self�maxsizes r�__init__zQueue.__init__!s\���� �$�)�)�+�� �#�)�)�+�� �!"���������������� � �7�rc�6�tj�|_y�N)rr�_queuer"s rr!zQueue._init/s��!�'�'�)��rc�6�|jj�Sr')r(�popleft�r#s r�_getz Queue._get2s���{�{�"�"�$�$rc�:�|jj|�yr'�r(�append�r#�items r�_putz Queue._put5��������4� rc�t�|r6|j�}|j�s|jd�y|r�5yyr')r*�done� set_result)r#�waiters�waiters r�_wakeup_nextzQueue._wakeup_next:s0����_�_�&�F��;�;�=��!�!�$�'�� rc�p�dt|�j�dt|�d�d|j��d�S)N�<z at z#x� �>)�typer�id�_formatr+s r�__repr__zQueue.__repr__Bs5���4��:�&�&�'�t�B�t�H�R�=��$�,�,�.�9I��K�Krc�V�dt|�j�d|j��d�S)Nr;r<r=)r>rr@r+s r�__str__z Queue.__str__Es)���4��:�&�&�'�q�����(8��:�:rc�P�d|j��}t|dd�r|dt|j���z }|jr|dt|j��d�z }|jr|dt|j��d�z }|jr|d|j��z }|S)Nzmaxsize=r(z _queue=z _getters[�]z _putters[z tasks=)r�getattr�listr(r�lenrr)r#�results rr@z Queue._formatJs����D�M�M�,�-���4��4�(����d�k�k�!2� 5�6�6�F��=�=�� �3�t�}�}�#5�"6�a�8�8�F��=�=�� �3�t�}�}�#5�"6�a�8�8�F��!�!���� 6� 6�7�8�8�F�� rc�,�t|j�S)zNumber of items in the queue.)rHr(r+s r�qsizezQueue.qsizeVs���4�;�;��rc��|jS)z%Number of items allowed in the queue.)rr+s rr$z Queue.maxsizeZs���}�}�rc��|jS)z3Return True if the queue is empty, False otherwise.�r(r+s r�emptyzQueue.empty_s���;�;��rc�\�|jdkry|j�|jk\S)z�Return True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. rF)rrKr+s r�fullz Queue.fullcs(���=�=�A����:�:�<�4�=�=�0�0rc���K�|j�rU|j�j�}|jj |� |�d{���|j�r�U|j|�S7�&#|j� |jj |�n#t$rYnwxYw|j�s+|j�s|j|j��xYw�w)z�Put an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. N)rQ� _get_loop� create_futurerr/�cancel�remove� ValueError� cancelledr9� put_nowait)r#r1�putters r�putz Queue.putns������i�i�k��^�^�%�3�3�5�F��M�M� � ��(� ���� �i�i�k�&���t�$�$��� �� � ����M�M�(�(��0��!������y�y�{�6�+;�+;�+=��%�%�d�m�m�4��sZ�A C8� A;�A9�A;�C8�(C8�9A;�;C5�B*�)C5�* B6�3C5�5B6�6?C5�5C8c���|j�rt�|j|�|xjdz c_|jj�|j |j�y)zyPut an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. r N)rQrr2rr�clearr9rr0s rrYzQueue.put_nowait�sP�� �9�9�;��O�� � �$�����!�#�����������$�-�-�(rc���K�|j�rU|j�j�}|jj |� |�d{���|j�r�U|j�S7�%#|j� |jj |�n#t$rYnwxYw|j�s+|j�s|j|j��xYw�w)zoRemove and return an item from the queue. If queue is empty, wait until an item is available. N)rOrSrTrr/rUrVrWrXr9� get_nowait)r#�getters r�getz Queue.get�s����� �j�j�l��^�^�%�3�3�5�F��M�M� � ��(� ���� �j�j�l�&��� � ��� �� � ����M�M�(�(��0��!������z�z�|�F�,<�,<�,>��%�%�d�m�m�4��sZ�A C7� A:�A8�A:�C7�(C7�8A:�:C4� B)�(C4�) B5�2C4�4B5�5?C4�4C7c��|j�rt�|j�}|j|j�|S)z�Remove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. )rOrr,r9rr0s rr_zQueue.get_nowait�s5�� �:�:�<����y�y�{�����$�-�-�(��rc��|jdkrtd��|xjdzc_|jdk(r|jj�yy)a$Indicate that a formerly enqueued task is complete. Used by queue consumers. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue). Raises ValueError if called more times than there were items placed in the queue. rz!task_done() called too many timesr N)rrWrr r+s r� task_donezQueue.task_done�sR���!�!�Q�&��@�A�A����!�#���!�!�Q�&��N�N��� �'rc��tK�|jdkDr#|jj��d{���yy7��w)aBlock until all items in the queue have been gotten and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer calls task_done() to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks. rN)rr�waitr+s r�joinz Queue.join�s4�����!�!�A�%��.�.�%�%�'�'�'�&�'�s�-8�6�8N)r)rrrrr%r!r,r2r9rArC�classmethodr�__class_getitem__r@rK�propertyr$rOrQr[rYrar_rdrgrrrrrs~�� � �*�%�!� �L�;�$�L�1�� � ������ 1�%�6 )�!�4 �!�( (rrc�R�eZdZdZd�Zejfd�Zejfd�Z y)rz�A subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). c��g|_yr'rNr"s rr!zPriorityQueue._init�� ����rc�*�||j|�yr'rN)r#r1�heappushs rr2zPriorityQueue._put�s������d�#rc�&�||j�Sr'rN)r#�heappops rr,zPriorityQueue._get�s���t�{�{�#�#rN) rrrrr!�heapqror2rqr,rrrrr�s(��� �#(�.�.�$�!�=�=�$rrc�"�eZdZdZd�Zd�Zd�Zy)rzEA subclass of Queue that retrieves most recently added entries first.c��g|_yr'rNr"s rr!zLifoQueue._init�rmrc�:�|jj|�yr'r.r0s rr2zLifoQueue._put�r3rc�6�|jj�Sr')r(�popr+s rr,zLifoQueue._get�s���{�{��� � rN)rrrrr!r2r,rrrrr�s��O��!�!rr)�__all__rrr�typesr�r r� Exceptionrr�_LoopBoundMixinrrrrrr�<module>r}s^�� L������� �� � � � � B(�F�"�"�B(�J $�E� $� !�� !r__pycache__/queues.cpython-312.opt-2.pyc000064400000022200151706172560013734 0ustar00� T��h&���dZddlZddlZddlmZddlmZddlmZGd�de�Z Gd �d e�Z Gd�dej�ZGd �de�Z Gd�de�Zy))�Queue� PriorityQueue� LifoQueue� QueueFull� QueueEmpty�N)�GenericAlias�)�locks)�mixinsc��eZdZ y)rN��__name__� __module__�__qualname__���'/usr/lib64/python3.12/asyncio/queues.pyrrs��E�rrc��eZdZ y)rNr rrrrrs��N�rrc��eZdZ dd�Zd�Zd�Zd�Zd�Zd�Zd�Z e e�Zd�Z d �Zed ��Zd�Zd�Zd �Zd�Zd�Zd�Zd�Zd�Zy)rc��||_tj�|_tj�|_d|_t j�|_|jj�|j|�y�Nr)�_maxsize�collections�deque�_getters�_putters�_unfinished_tasksr �Event� _finished�set�_init��self�maxsizes r�__init__zQueue.__init__!s\���� �$�)�)�+�� �#�)�)�+�� �!"���������������� � �7�rc�6�tj�|_y�N)rr�_queuer"s rr!zQueue._init/s��!�'�'�)��rc�6�|jj�Sr')r(�popleft�r#s r�_getz Queue._get2s���{�{�"�"�$�$rc�:�|jj|�yr'�r(�append�r#�items r�_putz Queue._put5��������4� rc�t�|r6|j�}|j�s|jd�y|r�5yyr')r*�done� set_result)r#�waiters�waiters r�_wakeup_nextzQueue._wakeup_next:s0����_�_�&�F��;�;�=��!�!�$�'�� rc�p�dt|�j�dt|�d�d|j��d�S)N�<z at z#x� �>)�typer�id�_formatr+s r�__repr__zQueue.__repr__Bs5���4��:�&�&�'�t�B�t�H�R�=��$�,�,�.�9I��K�Krc�V�dt|�j�d|j��d�S)Nr;r<r=)r>rr@r+s r�__str__z Queue.__str__Es)���4��:�&�&�'�q�����(8��:�:rc�P�d|j��}t|dd�r|dt|j���z }|jr|dt|j��d�z }|jr|dt|j��d�z }|jr|d|j��z }|S)Nzmaxsize=r(z _queue=z _getters[�]z _putters[z tasks=)r�getattr�listr(r�lenrr)r#�results rr@z Queue._formatJs����D�M�M�,�-���4��4�(����d�k�k�!2� 5�6�6�F��=�=�� �3�t�}�}�#5�"6�a�8�8�F��=�=�� �3�t�}�}�#5�"6�a�8�8�F��!�!���� 6� 6�7�8�8�F�� rc�.� t|j�Sr')rHr(r+s r�qsizezQueue.qsizeVs��+��4�;�;��rc�� |jSr')rr+s rr$z Queue.maxsizeZs��3��}�}�rc�� |jSr'�r(r+s r�emptyzQueue.empty_s��A��;�;��rc�^� |jdkry|j�|jk\S)NrF)rrKr+s r�fullz Queue.fullcs-�� � �=�=�A����:�:�<�4�=�=�0�0rc��K� |j�rU|j�j�}|jj |� |�d{���|j�r�U|j|�S7�&#|j� |jj |�n#t$rYnwxYw|j�s+|j�s|j|j��xYw�wr')rQ� _get_loop� create_futurerr/�cancel�remove� ValueError� cancelledr9� put_nowait)r#r1�putters r�putz Queue.putns����� � �i�i�k��^�^�%�3�3�5�F��M�M� � ��(� ���� �i�i�k�&���t�$�$��� �� � ����M�M�(�(��0��!������y�y�{�6�+;�+;�+=��%�%�d�m�m�4��sZ�AC9�A<�A:�A<�C9�)C9�:A<�<C6�B+�*C6�+ B7�4C6�6B7�7?C6�6C9c��� |j�rt�|j|�|xjdz c_|jj�|j |j�y)Nr )rQrr2rr�clearr9rr0s rrYzQueue.put_nowait�sU�� ��9�9�;��O�� � �$�����!�#�����������$�-�-�(rc���K� |j�rU|j�j�}|jj |� |�d{���|j�r�U|j�S7�%#|j� |jj |�n#t$rYnwxYw|j�s+|j�s|j|j��xYw�wr')rOrSrTrr/rUrVrWrXr9� get_nowait)r#�getters r�getz Queue.get�s����� ��j�j�l��^�^�%�3�3�5�F��M�M� � ��(� ���� �j�j�l�&��� � ��� �� � ����M�M�(�(��0��!������z�z�|�F�,<�,<�,>��%�%�d�m�m�4��sZ�AC8�A;�A9�A;�C8�)C8�9A;�;C5�B*�)C5�* B6�3C5�5B6�6?C5�5C8c�� |j�rt�|j�}|j|j�|Sr')rOrr,r9rr0s rr_zQueue.get_nowait�s:�� ��:�:�<����y�y�{�����$�-�-�(��rc�� |jdkrtd��|xjdzc_|jdk(r|jj�yy)Nrz!task_done() called too many timesr )rrWrr r+s r� task_donezQueue.task_done�sW�� ��!�!�Q�&��@�A�A����!�#���!�!�Q�&��N�N��� �'rc��vK� |jdkDr#|jj��d{���yy7��wr)rr�waitr+s r�joinz Queue.join�s9���� ��!�!�A�%��.�.�%�%�'�'�'�&�'�s�.9�7�9N)r)rrrr%r!r,r2r9rArC�classmethodr�__class_getitem__r@rK�propertyr$rOrQr[rYrar_rdrgrrrrrs~�� � �*�%�!� �L�;�$�L�1�� � ������ 1�%�6 )�!�4 �!�( (rrc�P�eZdZ d�Zej fd�Zejfd�Zy)rc��g|_yr'rNr"s rr!zPriorityQueue._init�� ����rc�*�||j|�yr'rN)r#r1�heappushs rr2zPriorityQueue._put�s������d�#rc�&�||j�Sr'rN)r#�heappops rr,zPriorityQueue._get�s���t�{�{�#�#rN) rrrr!�heapqror2rqr,rrrrr�s(��� �#(�.�.�$�!�=�=�$rrc� �eZdZ d�Zd�Zd�Zy)rc��g|_yr'rNr"s rr!zLifoQueue._init�rmrc�:�|jj|�yr'r.r0s rr2zLifoQueue._put�r3rc�6�|jj�Sr')r(�popr+s rr,zLifoQueue._get�s���{�{��� � rN)rrrr!r2r,rrrrr�s��O��!�!rr)�__all__rrr�typesr�r r� Exceptionrr�_LoopBoundMixinrrrrrr�<module>r}s^�� L������� �� � � � � B(�F�"�"�B(�J $�E� $� !�� !r__pycache__/runners.cpython-312.opt-1.pyc000064400000023410151706172560014124 0ustar00� T��h>���dZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlmZGd �d ej�Z Gd�d�Zddd �d�Zd�Zy))�Runner�run�N�)� coroutines)�events)� exceptions)�tasks)� constantsc��eZdZdZdZdZy)�_State�created�initialized�closedN)�__name__� __module__�__qualname__�CREATED�INITIALIZED�CLOSED���(/usr/lib64/python3.12/asyncio/runners.pyrrs���G��K� �Frrc�N�eZdZdZddd�d�Zd�Zd�Zd�Zd�Zdd �d �Z d�Z d�Zy) ra5A context manager that controls event loop life cycle. The context manager always creates a new event loop, allows to run async functions inside it, and properly finalizes the loop at the context manager exit. If debug is True, the event loop will be run in debug mode. If loop_factory is passed, it is used for new event loop creation. asyncio.run(main(), debug=True) is a shortcut for with asyncio.Runner(debug=True) as runner: runner.run(main()) The run() method can be called multiple times within the runner's context. This can be useful for interactive console (e.g. IPython), unittest runners, console tools, -- everywhere when async code is called from existing sync framework and where the preferred single asyncio.run() call doesn't work. N��debug�loop_factoryc��tj|_||_||_d|_d|_d|_d|_y)NrF) rr�_state�_debug� _loop_factory�_loop�_context�_interrupt_count�_set_event_loop)�selfrrs r�__init__zRunner.__init__0s:���n�n������)����� ��� � !���$��rc�&�|j�|S�N)� _lazy_init�r%s r� __enter__zRunner.__enter__9s�������rc�$�|j�yr()�close)r%�exc_type�exc_val�exc_tbs r�__exit__zRunner.__exit__=s��� � �rc�F�|jtjury |j}t |�|j|j ��|j|jtj��|jrtjd�|j�d|_tj|_y#|jrtjd�j�d|_tj|_wxYw)zShutdown and close event loop.N)rrrr!�_cancel_all_tasks�run_until_complete�shutdown_asyncgens�shutdown_default_executorr �THREAD_JOIN_TIMEOUTr$r�set_event_loopr-r)r%�loops rr-zRunner.close@s����;�;�f�0�0�0�� (��:�:�D��d�#��#�#�D�$;�$;�$=�>��#�#��.�.�y�/L�/L�M� O��#�#��%�%�d�+��J�J�L��D�J� �-�-�D�K�� �#�#��%�%�d�+��J�J�L��D�J� �-�-�D�K�s �A$C�AD c�:�|j�|jS)zReturn embedded event loop.)r)r!r*s r�get_loopzRunner.get_loopQs�������z�z�r��contextc���tj|�stdj|���t j ��t d��|j�|�|j}|jj||��}tj�tj�urztjtj �tj"urGt%j&|j(|��} tjtj |�nd}d|_ |jj-|�|�Ytjtj �|ur3tjtj tj"�SSS#t$rd}Y��wxYw#t.j0$r4|j*dkDr#t3|dd�}|�|�dk(r t5���wxYw#|�Ytjtj �|ur3tjtj tj"�wwwxYw)z/Run a coroutine inside the embedded event loop.z"a coroutine was expected, got {!r}Nz7Runner.run() cannot be called from a running event loopr<)� main_taskr�uncancel)r�iscoroutine� ValueError�formatr�_get_running_loop�RuntimeErrorr)r"r!�create_task� threading�current_thread�main_thread�signal� getsignal�SIGINT�default_int_handler� functools�partial� _on_sigintr#r4r�CancelledError�getattr�KeyboardInterrupt)r%�coror=�task�sigint_handlerr@s rrz Runner.runVs����%�%�d�+��A�H�H��N�O�O��#�#�%�1��I�K� K� �����?��m�m�G��z�z�%�%�d�G�%�<���$�$�&�)�*?�*?�*A�A�� � ����/�6�3M�3M�M�&�.�.�t���$�O�N� &�� � �f�m�m�^�<�"�N� !��� I��:�:�0�0��6��*��$�$�V�]�]�3�~�E�� � �f�m�m�V�-G�-G�H�F�+��%� &�"&�� &���(�(� ��$�$�q�(�"�4��T�:���'�H�J�!�O�+�-�-�� ���*��$�$�V�]�]�3�~�E�� � �f�m�m�V�-G�-G�H�F�+�s,�$F,�6F=�,F:�9F:�=AH�H�AI$c�$�|jtjurtd��|jtjury|j �Lt j�|_|js<t j|j�d|_ n|j�|_|j�%|jj|j�tj�|_tj|_y)NzRunner is closedT)rrrrErr r�new_event_loopr!r$r8r� set_debug�contextvars�copy_contextr"r*s rr)zRunner._lazy_init�s����;�;�&�-�-�'��1�2�2��;�;�&�,�,�,�����%��.�.�0�D�J��'�'��%�%�d�j�j�1�'+��$��+�+�-�D�J��;�;�"��J�J� � ����-�#�0�0�2�� ��(�(��rc���|xjdz c_|jdk(r=|j�s-|j�|jj d��yt��)Nrc��yr(rrrr�<lambda>z#Runner._on_sigint.<locals>.<lambda>�s��Dr)r#�done�cancelr!�call_soon_threadsaferS)r%�signum�framer?s rrPzRunner._on_sigint�sT������"��� � �A�%�i�n�n�.>������J�J�+�+�L�9���!�!r)rrr�__doc__r&r+r1r-r;rr)rPrrrrrs=���6!%�4�%���(�"� $(�+I�Z)�&"rrrc��tj��td��t||��5}|j |�cddd�S#1swYyxYw)a�Execute the coroutine and return the result. This function runs the passed coroutine, taking care of managing the asyncio event loop, finalizing asynchronous generators and closing the default executor. This function cannot be called when another asyncio event loop is running in the same thread. If debug is True, the event loop will be run in debug mode. If loop_factory is passed, it is used for new event loop creation. This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once. The executor is given a timeout duration of 5 minutes to shutdown. If the executor hasn't finished within that duration, a warning is emitted and the executor is closed. Example: async def main(): await asyncio.sleep(1) print('hello') asyncio.run(main()) Nz8asyncio.run() cannot be called from a running event loopr)rrDrErr)�mainrr�runners rrr�sK��:���!�-��F�H� H� �e�,� 7�6��z�z�$�� 8� 7� 7�s�A�Ac�B�tj|�}|sy|D]}|j��|jtj|ddi��|D]G}|j�r�|j ���%|jd|j �|d���Iy)N�return_exceptionsTz1unhandled exception during asyncio.run() shutdown)�message� exceptionrU)r � all_tasksr`r4�gather� cancelledrk�call_exception_handler)r9� to_cancelrUs rr3r3�s�������%�I�������� �� ���E�L�L�)�L�t�L�M����>�>����>�>��'��'�'�N�!�^�^�-��)� � r)�__all__rZ�enumrNrGrJ�rrrr r �Enumrrrr3rrr�<module>rusW�� ������ �������T�Y�Y��I"�I"�X�$�# �Lr__pycache__/runners.cpython-312.opt-2.pyc000064400000017652151706172560014140 0ustar00� T��h>���dZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlmZGd �d ej�Z Gd�d�Zddd �d�Zd�Zy))�Runner�run�N�)� coroutines)�events)� exceptions)�tasks)� constantsc��eZdZdZdZdZy)�_State�created�initialized�closedN)�__name__� __module__�__qualname__�CREATED�INITIALIZED�CLOSED���(/usr/lib64/python3.12/asyncio/runners.pyrrs���G��K� �Frrc�L�eZdZ ddd�d�Zd�Zd�Zd�Zd�Zdd�d �Zd �Z d�Z y)rN��debug�loop_factoryc��tj|_||_||_d|_d|_d|_d|_y)NrF) rr�_state�_debug� _loop_factory�_loop�_context�_interrupt_count�_set_event_loop)�selfrrs r�__init__zRunner.__init__0s:���n�n������)����� ��� � !���$��rc�&�|j�|S�N)� _lazy_init�r%s r� __enter__zRunner.__enter__9s�������rc�$�|j�yr()�close)r%�exc_type�exc_val�exc_tbs r�__exit__zRunner.__exit__=s��� � �rc�H� |jtjury |j}t |�|j|j ��|j|jtj��|jrtjd�|j�d|_tj|_y#|jrtjd�j�d|_tj|_wxYwr()rrrr!�_cancel_all_tasks�run_until_complete�shutdown_asyncgens�shutdown_default_executorr �THREAD_JOIN_TIMEOUTr$r�set_event_loopr-r)r%�loops rr-zRunner.close@s���,��;�;�f�0�0�0�� (��:�:�D��d�#��#�#�D�$;�$;�$=�>��#�#��.�.�y�/L�/L�M� O��#�#��%�%�d�+��J�J�L��D�J� �-�-�D�K�� �#�#��%�%�d�+��J�J�L��D�J� �-�-�D�K�s �A$C�AD!c�<� |j�|jSr()r)r!r*s r�get_loopzRunner.get_loopQs��)������z�z�r��contextc��� tj|�stdj|���t j ��t d��|j�|�|j}|jj||��}tj�tj�urztjtj �tj"urGt%j&|j(|��} tjtj |�nd}d|_ |jj-|�|�Ytjtj �|ur3tjtj tj"�SSS#t$rd}Y��wxYw#t.j0$r4|j*dkDr#t3|dd�}|�|�dk(r t5���wxYw#|�Ytjtj �|ur3tjtj tj"�wwwxYw)Nz"a coroutine was expected, got {!r}z7Runner.run() cannot be called from a running event loopr<)� main_taskr�uncancel)r�iscoroutine� ValueError�formatr�_get_running_loop�RuntimeErrorr)r"r!�create_task� threading�current_thread�main_thread�signal� getsignal�SIGINT�default_int_handler� functools�partial� _on_sigintr#r4r�CancelledError�getattr�KeyboardInterrupt)r%�coror=�task�sigint_handlerr@s rrz Runner.runVs���=��%�%�d�+��A�H�H��N�O�O��#�#�%�1��I�K� K� �����?��m�m�G��z�z�%�%�d�G�%�<���$�$�&�)�*?�*?�*A�A�� � ����/�6�3M�3M�M�&�.�.�t���$�O�N� &�� � �f�m�m�^�<�"�N� !��� I��:�:�0�0��6��*��$�$�V�]�]�3�~�E�� � �f�m�m�V�-G�-G�H�F�+��%� &�"&�� &���(�(� ��$�$�q�(�"�4��T�:���'�H�J�!�O�+�-�-�� ���*��$�$�V�]�]�3�~�E�� � �f�m�m�V�-G�-G�H�F�+�s,�$F-�7F>�-F;�:F;�>AH�H�AI%c�$�|jtjurtd��|jtjury|j �Lt j�|_|js<t j|j�d|_ n|j�|_|j�%|jj|j�tj�|_tj|_y)NzRunner is closedT)rrrrErr r�new_event_loopr!r$r8r� set_debug�contextvars�copy_contextr"r*s rr)zRunner._lazy_init�s����;�;�&�-�-�'��1�2�2��;�;�&�,�,�,�����%��.�.�0�D�J��'�'��%�%�d�j�j�1�'+��$��+�+�-�D�J��;�;�"��J�J� � ����-�#�0�0�2�� ��(�(��rc���|xjdz c_|jdk(r=|j�s-|j�|jj d��yt��)Nrc��yr(rrrr�<lambda>z#Runner._on_sigint.<locals>.<lambda>�s��Dr)r#�done�cancelr!�call_soon_threadsaferS)r%�signum�framer?s rrPzRunner._on_sigint�sT������"��� � �A�%�i�n�n�.>������J�J�+�+�L�9���!�!r)rrrr&r+r1r-r;rr)rPrrrrrs=���6!%�4�%���(�"� $(�+I�Z)�&"rrrc�� tj��td��t||��5}|j |�cddd�S#1swYyxYw)Nz8asyncio.run() cannot be called from a running event loopr)rrDrErr)�mainrr�runners rrr�sP���8���!�-��F�H� H� �e�,� 7�6��z�z�$�� 8� 7� 7�s�A � Ac�B�tj|�}|sy|D]}|j��|jtj|ddi��|D]G}|j�r�|j ���%|jd|j �|d���Iy)N�return_exceptionsTz1unhandled exception during asyncio.run() shutdown)�message� exceptionrU)r � all_tasksr`r4�gather� cancelledrj�call_exception_handler)r9� to_cancelrUs rr3r3�s�������%�I�������� �� ���E�L�L�)�L�t�L�M����>�>����>�>��'��'�'�N�!�^�^�-��)� � r)�__all__rZ�enumrNrGrJ�rrrr r �Enumrrrr3rrr�<module>rtsW�� ������ �������T�Y�Y��I"�I"�X�$�# �Lr__init__.py000064400000002304151706172560006666 0ustar00"""The asyncio package, tracking PEP 3156.""" # flake8: noqa import sys # This relies on each of the submodules having an __all__ variable. from .base_events import * from .coroutines import * from .events import * from .exceptions import * from .futures import * from .locks import * from .protocols import * from .runners import * from .queues import * from .streams import * from .subprocess import * from .tasks import * from .taskgroups import * from .timeouts import * from .threads import * from .transports import * __all__ = (base_events.__all__ + coroutines.__all__ + events.__all__ + exceptions.__all__ + futures.__all__ + locks.__all__ + protocols.__all__ + runners.__all__ + queues.__all__ + streams.__all__ + subprocess.__all__ + tasks.__all__ + taskgroups.__all__ + threads.__all__ + timeouts.__all__ + transports.__all__) if sys.platform == 'win32': # pragma: no cover from .windows_events import * __all__ += windows_events.__all__ else: from .unix_events import * # pragma: no cover __all__ += unix_events.__all__ __main__.py000064400000006643151706172560006661 0ustar00import ast import asyncio import code import concurrent.futures import contextvars import inspect import sys import threading import types import warnings from . import futures class AsyncIOInteractiveConsole(code.InteractiveConsole): def __init__(self, locals, loop): super().__init__(locals) self.compile.compiler.flags |= ast.PyCF_ALLOW_TOP_LEVEL_AWAIT self.loop = loop self.context = contextvars.copy_context() def runcode(self, code): future = concurrent.futures.Future() def callback(): global repl_future global repl_future_interrupted repl_future = None repl_future_interrupted = False func = types.FunctionType(code, self.locals) try: coro = func() except SystemExit: raise except KeyboardInterrupt as ex: repl_future_interrupted = True future.set_exception(ex) return except BaseException as ex: future.set_exception(ex) return if not inspect.iscoroutine(coro): future.set_result(coro) return try: repl_future = self.loop.create_task(coro, context=self.context) futures._chain_future(repl_future, future) except BaseException as exc: future.set_exception(exc) loop.call_soon_threadsafe(callback, context=self.context) try: return future.result() except SystemExit: raise except BaseException: if repl_future_interrupted: self.write("\nKeyboardInterrupt\n") else: self.showtraceback() class REPLThread(threading.Thread): def run(self): try: banner = ( f'asyncio REPL {sys.version} on {sys.platform}\n' f'Use "await" directly instead of "asyncio.run()".\n' f'Type "help", "copyright", "credits" or "license" ' f'for more information.\n' f'{getattr(sys, "ps1", ">>> ")}import asyncio' ) console.interact( banner=banner, exitmsg='exiting asyncio REPL...') finally: warnings.filterwarnings( 'ignore', message=r'^coroutine .* was never awaited$', category=RuntimeWarning) loop.call_soon_threadsafe(loop.stop) if __name__ == '__main__': sys.audit("cpython.run_stdin") loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) repl_locals = {'asyncio': asyncio} for key in {'__name__', '__package__', '__loader__', '__spec__', '__builtins__', '__file__'}: repl_locals[key] = locals()[key] console = AsyncIOInteractiveConsole(repl_locals, loop) repl_future = None repl_future_interrupted = False try: import readline # NoQA except ImportError: pass repl_thread = REPLThread() repl_thread.daemon = True repl_thread.start() while True: try: loop.run_forever() except KeyboardInterrupt: if repl_future and not repl_future.done(): repl_future.cancel() repl_future_interrupted = True continue else: break base_events.py000064400000231347151706172560007440 0ustar00"""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. """ import collections import collections.abc import concurrent.futures import errno import heapq import itertools import os import socket import stat import subprocess import threading import time import traceback import sys import warnings import weakref try: import ssl except ImportError: # pragma: no cover ssl = None from . import constants from . import coroutines from . import events from . import exceptions from . import futures from . import protocols from . import sslproto from . import staggered from . import tasks from . import timeouts from . import transports from . import trsock from .log import logger __all__ = 'BaseEventLoop','Server', # Minimum number of _scheduled timer handles before cleanup of # cancelled handles is performed. _MIN_SCHEDULED_TIMER_HANDLES = 100 # Minimum fraction of _scheduled timer handles that are cancelled # before cleanup of cancelled handles is performed. _MIN_CANCELLED_TIMER_HANDLES_FRACTION = 0.5 _HAS_IPv6 = hasattr(socket, 'AF_INET6') # Maximum timeout passed to select to avoid OS limitations MAXIMUM_SELECT_TIMEOUT = 24 * 3600 def _format_handle(handle): cb = handle._callback if isinstance(getattr(cb, '__self__', None), tasks.Task): # format the task return repr(cb.__self__) else: return str(handle) def _format_pipe(fd): if fd == subprocess.PIPE: return '<pipe>' elif fd == subprocess.STDOUT: return '<stdout>' else: return repr(fd) def _set_reuseport(sock): if not hasattr(socket, 'SO_REUSEPORT'): raise ValueError('reuse_port not supported by socket module') else: try: sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) except OSError: raise ValueError('reuse_port not supported by socket module, ' 'SO_REUSEPORT defined but not implemented.') def _ipaddr_info(host, port, family, type, proto, flowinfo=0, scopeid=0): # Try to skip getaddrinfo if "host" is already an IP. Users might have # handled name resolution in their own code and pass in resolved IPs. if not hasattr(socket, 'inet_pton'): return if proto not in {0, socket.IPPROTO_TCP, socket.IPPROTO_UDP} or \ host is None: return None if type == socket.SOCK_STREAM: proto = socket.IPPROTO_TCP elif type == socket.SOCK_DGRAM: proto = socket.IPPROTO_UDP else: return None if port is None: port = 0 elif isinstance(port, bytes) and port == b'': port = 0 elif isinstance(port, str) and port == '': port = 0 else: # If port's a service name like "http", don't skip getaddrinfo. try: port = int(port) except (TypeError, ValueError): return None if family == socket.AF_UNSPEC: afs = [socket.AF_INET] if _HAS_IPv6: afs.append(socket.AF_INET6) else: afs = [family] if isinstance(host, bytes): host = host.decode('idna') if '%' in host: # Linux's inet_pton doesn't accept an IPv6 zone index after host, # like '::1%lo0'. return None for af in afs: try: socket.inet_pton(af, host) # The host has already been resolved. if _HAS_IPv6 and af == socket.AF_INET6: return af, type, proto, '', (host, port, flowinfo, scopeid) else: return af, type, proto, '', (host, port) except OSError: pass # "host" is not an IP address. return None def _interleave_addrinfos(addrinfos, first_address_family_count=1): """Interleave list of addrinfo tuples by family.""" # Group addresses by family addrinfos_by_family = collections.OrderedDict() for addr in addrinfos: family = addr[0] if family not in addrinfos_by_family: addrinfos_by_family[family] = [] addrinfos_by_family[family].append(addr) addrinfos_lists = list(addrinfos_by_family.values()) reordered = [] if first_address_family_count > 1: reordered.extend(addrinfos_lists[0][:first_address_family_count - 1]) del addrinfos_lists[0][:first_address_family_count - 1] reordered.extend( a for a in itertools.chain.from_iterable( itertools.zip_longest(*addrinfos_lists) ) if a is not None) return reordered def _run_until_complete_cb(fut): if not fut.cancelled(): exc = fut.exception() if isinstance(exc, (SystemExit, KeyboardInterrupt)): # Issue #22429: run_forever() already finished, no need to # stop it. return futures._get_loop(fut).stop() if hasattr(socket, 'TCP_NODELAY'): def _set_nodelay(sock): if (sock.family in {socket.AF_INET, socket.AF_INET6} and sock.type == socket.SOCK_STREAM and sock.proto == socket.IPPROTO_TCP): sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) else: def _set_nodelay(sock): pass def _check_ssl_socket(sock): if ssl is not None and isinstance(sock, ssl.SSLSocket): raise TypeError("Socket cannot be of type SSLSocket") class _SendfileFallbackProtocol(protocols.Protocol): def __init__(self, transp): if not isinstance(transp, transports._FlowControlMixin): raise TypeError("transport should be _FlowControlMixin instance") self._transport = transp self._proto = transp.get_protocol() self._should_resume_reading = transp.is_reading() self._should_resume_writing = transp._protocol_paused transp.pause_reading() transp.set_protocol(self) if self._should_resume_writing: self._write_ready_fut = self._transport._loop.create_future() else: self._write_ready_fut = None async def drain(self): if self._transport.is_closing(): raise ConnectionError("Connection closed by peer") fut = self._write_ready_fut if fut is None: return await fut def connection_made(self, transport): raise RuntimeError("Invalid state: " "connection should have been established already.") def connection_lost(self, exc): if self._write_ready_fut is not None: # Never happens if peer disconnects after sending the whole content # Thus disconnection is always an exception from user perspective if exc is None: self._write_ready_fut.set_exception( ConnectionError("Connection is closed by peer")) else: self._write_ready_fut.set_exception(exc) self._proto.connection_lost(exc) def pause_writing(self): if self._write_ready_fut is not None: return self._write_ready_fut = self._transport._loop.create_future() def resume_writing(self): if self._write_ready_fut is None: return self._write_ready_fut.set_result(False) self._write_ready_fut = None def data_received(self, data): raise RuntimeError("Invalid state: reading should be paused") def eof_received(self): raise RuntimeError("Invalid state: reading should be paused") async def restore(self): self._transport.set_protocol(self._proto) if self._should_resume_reading: self._transport.resume_reading() if self._write_ready_fut is not None: # Cancel the future. # Basically it has no effect because protocol is switched back, # no code should wait for it anymore. self._write_ready_fut.cancel() if self._should_resume_writing: self._proto.resume_writing() class Server(events.AbstractServer): def __init__(self, loop, sockets, protocol_factory, ssl_context, backlog, ssl_handshake_timeout, ssl_shutdown_timeout=None): self._loop = loop self._sockets = sockets self._active_count = 0 self._waiters = [] self._protocol_factory = protocol_factory self._backlog = backlog self._ssl_context = ssl_context self._ssl_handshake_timeout = ssl_handshake_timeout self._ssl_shutdown_timeout = ssl_shutdown_timeout self._serving = False self._serving_forever_fut = None def __repr__(self): return f'<{self.__class__.__name__} sockets={self.sockets!r}>' def _attach(self): assert self._sockets is not None self._active_count += 1 def _detach(self): assert self._active_count > 0 self._active_count -= 1 if self._active_count == 0 and self._sockets is None: self._wakeup() def _wakeup(self): waiters = self._waiters self._waiters = None for waiter in waiters: if not waiter.done(): waiter.set_result(None) def _start_serving(self): if self._serving: return self._serving = True for sock in self._sockets: sock.listen(self._backlog) self._loop._start_serving( self._protocol_factory, sock, self._ssl_context, self, self._backlog, self._ssl_handshake_timeout, self._ssl_shutdown_timeout) def get_loop(self): return self._loop def is_serving(self): return self._serving @property def sockets(self): if self._sockets is None: return () return tuple(trsock.TransportSocket(s) for s in self._sockets) def close(self): sockets = self._sockets if sockets is None: return self._sockets = None for sock in sockets: self._loop._stop_serving(sock) self._serving = False if (self._serving_forever_fut is not None and not self._serving_forever_fut.done()): self._serving_forever_fut.cancel() self._serving_forever_fut = None if self._active_count == 0: self._wakeup() async def start_serving(self): self._start_serving() # Skip one loop iteration so that all 'loop.add_reader' # go through. await tasks.sleep(0) async def serve_forever(self): if self._serving_forever_fut is not None: raise RuntimeError( f'server {self!r} is already being awaited on serve_forever()') if self._sockets is None: raise RuntimeError(f'server {self!r} is closed') self._start_serving() self._serving_forever_fut = self._loop.create_future() try: await self._serving_forever_fut except exceptions.CancelledError: try: self.close() await self.wait_closed() finally: raise finally: self._serving_forever_fut = None async def wait_closed(self): """Wait until server is closed and all connections are dropped. - If the server is not closed, wait. - If it is closed, but there are still active connections, wait. Anyone waiting here will be unblocked once both conditions (server is closed and all connections have been dropped) have become true, in either order. Historical note: In 3.11 and before, this was broken, returning immediately if the server was already closed, even if there were still active connections. An attempted fix in 3.12.0 was still broken, returning immediately if the server was still open and there were no active connections. Hopefully in 3.12.1 we have it right. """ # Waiters are unblocked by self._wakeup(), which is called # from two places: self.close() and self._detach(), but only # when both conditions have become true. To signal that this # has happened, self._wakeup() sets self._waiters to None. if self._waiters is None: return waiter = self._loop.create_future() self._waiters.append(waiter) await waiter class BaseEventLoop(events.AbstractEventLoop): def __init__(self): self._timer_cancelled_count = 0 self._closed = False self._stopping = False self._ready = collections.deque() self._scheduled = [] self._default_executor = None self._internal_fds = 0 # Identifier of the thread running the event loop, or None if the # event loop is not running self._thread_id = None self._clock_resolution = time.get_clock_info('monotonic').resolution self._exception_handler = None self.set_debug(coroutines._is_debug_mode()) # In debug mode, if the execution of a callback or a step of a task # exceed this duration in seconds, the slow callback/task is logged. self.slow_callback_duration = 0.1 self._current_handle = None self._task_factory = None self._coroutine_origin_tracking_enabled = False self._coroutine_origin_tracking_saved_depth = None # A weak set of all asynchronous generators that are # being iterated by the loop. self._asyncgens = weakref.WeakSet() # Set to True when `loop.shutdown_asyncgens` is called. self._asyncgens_shutdown_called = False # Set to True when `loop.shutdown_default_executor` is called. self._executor_shutdown_called = False def __repr__(self): return ( f'<{self.__class__.__name__} running={self.is_running()} ' f'closed={self.is_closed()} debug={self.get_debug()}>' ) def create_future(self): """Create a Future object attached to the loop.""" return futures.Future(loop=self) def create_task(self, coro, *, name=None, context=None): """Schedule a coroutine object. Return a task object. """ self._check_closed() if self._task_factory is None: task = tasks.Task(coro, loop=self, name=name, context=context) if task._source_traceback: del task._source_traceback[-1] else: if context is None: # Use legacy API if context is not needed task = self._task_factory(self, coro) else: task = self._task_factory(self, coro, context=context) tasks._set_task_name(task, name) try: return task finally: # gh-128552: prevent a refcycle of # task.exception().__traceback__->BaseEventLoop.create_task->task del task def set_task_factory(self, factory): """Set 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. """ if factory is not None and not callable(factory): raise TypeError('task factory must be a callable or None') self._task_factory = factory def get_task_factory(self): """Return a task factory, or None if the default one is in use.""" return self._task_factory def _make_socket_transport(self, sock, protocol, waiter=None, *, extra=None, server=None): """Create socket transport.""" raise NotImplementedError def _make_ssl_transport( self, rawsock, protocol, sslcontext, waiter=None, *, server_side=False, server_hostname=None, extra=None, server=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, call_connection_made=True): """Create SSL transport.""" raise NotImplementedError def _make_datagram_transport(self, sock, protocol, address=None, waiter=None, extra=None): """Create datagram transport.""" raise NotImplementedError def _make_read_pipe_transport(self, pipe, protocol, waiter=None, extra=None): """Create read pipe transport.""" raise NotImplementedError def _make_write_pipe_transport(self, pipe, protocol, waiter=None, extra=None): """Create write pipe transport.""" raise NotImplementedError async def _make_subprocess_transport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, extra=None, **kwargs): """Create subprocess transport.""" raise NotImplementedError def _write_to_self(self): """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. """ raise NotImplementedError def _process_events(self, event_list): """Process selector events.""" raise NotImplementedError def _check_closed(self): if self._closed: raise RuntimeError('Event loop is closed') def _check_default_executor(self): if self._executor_shutdown_called: raise RuntimeError('Executor shutdown has been called') def _asyncgen_finalizer_hook(self, agen): self._asyncgens.discard(agen) if not self.is_closed(): self.call_soon_threadsafe(self.create_task, agen.aclose()) def _asyncgen_firstiter_hook(self, agen): if self._asyncgens_shutdown_called: warnings.warn( f"asynchronous generator {agen!r} was scheduled after " f"loop.shutdown_asyncgens() call", ResourceWarning, source=self) self._asyncgens.add(agen) async def shutdown_asyncgens(self): """Shutdown all active asynchronous generators.""" self._asyncgens_shutdown_called = True if not len(self._asyncgens): # If Python version is <3.6 or we don't have any asynchronous # generators alive. return closing_agens = list(self._asyncgens) self._asyncgens.clear() results = await tasks.gather( *[ag.aclose() for ag in closing_agens], return_exceptions=True) for result, agen in zip(results, closing_agens): if isinstance(result, Exception): self.call_exception_handler({ 'message': f'an error occurred during closing of ' f'asynchronous generator {agen!r}', 'exception': result, 'asyncgen': agen }) async def shutdown_default_executor(self, timeout=None): """Schedule the shutdown of the default executor. The timeout parameter specifies the amount of time the executor will be given to finish joining. The default value is None, which means that the executor will be given an unlimited amount of time. """ self._executor_shutdown_called = True if self._default_executor is None: return future = self.create_future() thread = threading.Thread(target=self._do_shutdown, args=(future,)) thread.start() try: async with timeouts.timeout(timeout): await future except TimeoutError: warnings.warn("The executor did not finishing joining " f"its threads within {timeout} seconds.", RuntimeWarning, stacklevel=2) self._default_executor.shutdown(wait=False) else: thread.join() def _do_shutdown(self, future): try: self._default_executor.shutdown(wait=True) if not self.is_closed(): self.call_soon_threadsafe(futures._set_result_unless_cancelled, future, None) except Exception as ex: if not self.is_closed() and not future.cancelled(): self.call_soon_threadsafe(future.set_exception, ex) def _check_running(self): if self.is_running(): raise RuntimeError('This event loop is already running') if events._get_running_loop() is not None: raise RuntimeError( 'Cannot run the event loop while another loop is running') def run_forever(self): """Run until stop() is called.""" self._check_closed() self._check_running() self._set_coroutine_origin_tracking(self._debug) old_agen_hooks = sys.get_asyncgen_hooks() try: self._thread_id = threading.get_ident() sys.set_asyncgen_hooks(firstiter=self._asyncgen_firstiter_hook, finalizer=self._asyncgen_finalizer_hook) events._set_running_loop(self) while True: self._run_once() if self._stopping: break finally: self._stopping = False self._thread_id = None events._set_running_loop(None) self._set_coroutine_origin_tracking(False) sys.set_asyncgen_hooks(*old_agen_hooks) def run_until_complete(self, future): """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. """ self._check_closed() self._check_running() new_task = not futures.isfuture(future) future = tasks.ensure_future(future, loop=self) if new_task: # An exception is raised if the future didn't complete, so there # is no need to log the "destroy pending task" message future._log_destroy_pending = False future.add_done_callback(_run_until_complete_cb) try: self.run_forever() except: if new_task and future.done() and not future.cancelled(): # The coroutine raised a BaseException. Consume the exception # to not log a warning, the caller doesn't have access to the # local task. future.exception() raise finally: future.remove_done_callback(_run_until_complete_cb) if not future.done(): raise RuntimeError('Event loop stopped before Future completed.') return future.result() def stop(self): """Stop running the event loop. Every callback already scheduled will still run. This simply informs run_forever to stop looping after a complete iteration. """ self._stopping = True def close(self): """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. """ if self.is_running(): raise RuntimeError("Cannot close a running event loop") if self._closed: return if self._debug: logger.debug("Close %r", self) self._closed = True self._ready.clear() self._scheduled.clear() self._executor_shutdown_called = True executor = self._default_executor if executor is not None: self._default_executor = None executor.shutdown(wait=False) def is_closed(self): """Returns True if the event loop was closed.""" return self._closed def __del__(self, _warn=warnings.warn): if not self.is_closed(): _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self) if not self.is_running(): self.close() def is_running(self): """Returns True if the event loop is running.""" return (self._thread_id is not None) def time(self): """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. """ return time.monotonic() def call_later(self, delay, callback, *args, context=None): """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. """ if delay is None: raise TypeError('delay must not be None') timer = self.call_at(self.time() + delay, callback, *args, context=context) if timer._source_traceback: del timer._source_traceback[-1] return timer def call_at(self, when, callback, *args, context=None): """Like call_later(), but uses an absolute time. Absolute time corresponds to the event loop's time() method. """ if when is None: raise TypeError("when cannot be None") self._check_closed() if self._debug: self._check_thread() self._check_callback(callback, 'call_at') timer = events.TimerHandle(when, callback, args, self, context) if timer._source_traceback: del timer._source_traceback[-1] heapq.heappush(self._scheduled, timer) timer._scheduled = True return timer def call_soon(self, callback, *args, context=None): """Arrange 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. """ self._check_closed() if self._debug: self._check_thread() self._check_callback(callback, 'call_soon') handle = self._call_soon(callback, args, context) if handle._source_traceback: del handle._source_traceback[-1] return handle def _check_callback(self, callback, method): if (coroutines.iscoroutine(callback) or coroutines.iscoroutinefunction(callback)): raise TypeError( f"coroutines cannot be used with {method}()") if not callable(callback): raise TypeError( f'a callable object was expected by {method}(), ' f'got {callback!r}') def _call_soon(self, callback, args, context): handle = events.Handle(callback, args, self, context) if handle._source_traceback: del handle._source_traceback[-1] self._ready.append(handle) return handle def _check_thread(self): """Check 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. """ if self._thread_id is None: return thread_id = threading.get_ident() if thread_id != self._thread_id: raise RuntimeError( "Non-thread-safe operation invoked on an event loop other " "than the current one") def call_soon_threadsafe(self, callback, *args, context=None): """Like call_soon(), but thread-safe.""" self._check_closed() if self._debug: self._check_callback(callback, 'call_soon_threadsafe') handle = self._call_soon(callback, args, context) if handle._source_traceback: del handle._source_traceback[-1] self._write_to_self() return handle def run_in_executor(self, executor, func, *args): self._check_closed() if self._debug: self._check_callback(func, 'run_in_executor') if executor is None: executor = self._default_executor # Only check when the default executor is being used self._check_default_executor() if executor is None: executor = concurrent.futures.ThreadPoolExecutor( thread_name_prefix='asyncio' ) self._default_executor = executor return futures.wrap_future( executor.submit(func, *args), loop=self) def set_default_executor(self, executor): if not isinstance(executor, concurrent.futures.ThreadPoolExecutor): raise TypeError('executor must be ThreadPoolExecutor instance') self._default_executor = executor def _getaddrinfo_debug(self, host, port, family, type, proto, flags): msg = [f"{host}:{port!r}"] if family: msg.append(f'family={family!r}') if type: msg.append(f'type={type!r}') if proto: msg.append(f'proto={proto!r}') if flags: msg.append(f'flags={flags!r}') msg = ', '.join(msg) logger.debug('Get address info %s', msg) t0 = self.time() addrinfo = socket.getaddrinfo(host, port, family, type, proto, flags) dt = self.time() - t0 msg = f'Getting address info {msg} took {dt * 1e3:.3f}ms: {addrinfo!r}' if dt >= self.slow_callback_duration: logger.info(msg) else: logger.debug(msg) return addrinfo async def getaddrinfo(self, host, port, *, family=0, type=0, proto=0, flags=0): if self._debug: getaddr_func = self._getaddrinfo_debug else: getaddr_func = socket.getaddrinfo return await self.run_in_executor( None, getaddr_func, host, port, family, type, proto, flags) async def getnameinfo(self, sockaddr, flags=0): return await self.run_in_executor( None, socket.getnameinfo, sockaddr, flags) async def sock_sendfile(self, sock, file, offset=0, count=None, *, fallback=True): if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") _check_ssl_socket(sock) self._check_sendfile_params(sock, file, offset, count) try: return await self._sock_sendfile_native(sock, file, offset, count) except exceptions.SendfileNotAvailableError as exc: if not fallback: raise return await self._sock_sendfile_fallback(sock, file, offset, count) async def _sock_sendfile_native(self, sock, file, offset, count): # NB: sendfile syscall is not supported for SSL sockets and # non-mmap files even if sendfile is supported by OS raise exceptions.SendfileNotAvailableError( f"syscall sendfile is not available for socket {sock!r} " f"and file {file!r} combination") async def _sock_sendfile_fallback(self, sock, file, offset, count): if offset: file.seek(offset) blocksize = ( min(count, constants.SENDFILE_FALLBACK_READBUFFER_SIZE) if count else constants.SENDFILE_FALLBACK_READBUFFER_SIZE ) buf = bytearray(blocksize) total_sent = 0 try: while True: if count: blocksize = min(count - total_sent, blocksize) if blocksize <= 0: break view = memoryview(buf)[:blocksize] read = await self.run_in_executor(None, file.readinto, view) if not read: break # EOF await self.sock_sendall(sock, view[:read]) total_sent += read return total_sent finally: if total_sent > 0 and hasattr(file, 'seek'): file.seek(offset + total_sent) def _check_sendfile_params(self, sock, file, offset, count): if 'b' not in getattr(file, 'mode', 'b'): raise ValueError("file should be opened in binary mode") if not sock.type == socket.SOCK_STREAM: raise ValueError("only SOCK_STREAM type sockets are supported") if count is not None: if not isinstance(count, int): raise TypeError( "count must be a positive integer (got {!r})".format(count)) if count <= 0: raise ValueError( "count must be a positive integer (got {!r})".format(count)) if not isinstance(offset, int): raise TypeError( "offset must be a non-negative integer (got {!r})".format( offset)) if offset < 0: raise ValueError( "offset must be a non-negative integer (got {!r})".format( offset)) async def _connect_sock(self, exceptions, addr_info, local_addr_infos=None): """Create, bind and connect one socket.""" my_exceptions = [] exceptions.append(my_exceptions) family, type_, proto, _, address = addr_info sock = None try: sock = socket.socket(family=family, type=type_, proto=proto) sock.setblocking(False) if local_addr_infos is not None: for lfamily, _, _, _, laddr in local_addr_infos: # skip local addresses of different family if lfamily != family: continue try: sock.bind(laddr) break except OSError as exc: msg = ( f'error while attempting to bind on ' f'address {laddr!r}: {str(exc).lower()}' ) exc = OSError(exc.errno, msg) my_exceptions.append(exc) else: # all bind attempts failed if my_exceptions: raise my_exceptions.pop() else: raise OSError(f"no matching local address with {family=} found") await self.sock_connect(sock, address) return sock except OSError as exc: my_exceptions.append(exc) if sock is not None: sock.close() raise except: if sock is not None: sock.close() raise finally: exceptions = my_exceptions = None async def create_connection( self, protocol_factory, host=None, port=None, *, ssl=None, family=0, proto=0, flags=0, sock=None, local_addr=None, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, happy_eyeballs_delay=None, interleave=None, all_errors=False): """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. """ if server_hostname is not None and not ssl: raise ValueError('server_hostname is only meaningful with ssl') if server_hostname is None and ssl: # Use host as default for server_hostname. It is an error # if host is empty or not set, e.g. when an # already-connected socket was passed or when only a port # is given. To avoid this error, you can pass # server_hostname='' -- this will bypass the hostname # check. (This also means that if host is a numeric # IP/IPv6 address, we will attempt to verify that exact # address; this will probably fail, but it is possible to # create a certificate for a specific IP address, so we # don't judge it here.) if not host: raise ValueError('You must set server_hostname ' 'when using ssl without a host') server_hostname = host if ssl_handshake_timeout is not None and not ssl: raise ValueError( 'ssl_handshake_timeout is only meaningful with ssl') if ssl_shutdown_timeout is not None and not ssl: raise ValueError( 'ssl_shutdown_timeout is only meaningful with ssl') if sock is not None: _check_ssl_socket(sock) if happy_eyeballs_delay is not None and interleave is None: # If using happy eyeballs, default to interleave addresses by family interleave = 1 if host is not None or port is not None: if sock is not None: raise ValueError( 'host/port and sock can not be specified at the same time') infos = await self._ensure_resolved( (host, port), family=family, type=socket.SOCK_STREAM, proto=proto, flags=flags, loop=self) if not infos: raise OSError('getaddrinfo() returned empty list') if local_addr is not None: laddr_infos = await self._ensure_resolved( local_addr, family=family, type=socket.SOCK_STREAM, proto=proto, flags=flags, loop=self) if not laddr_infos: raise OSError('getaddrinfo() returned empty list') else: laddr_infos = None if interleave: infos = _interleave_addrinfos(infos, interleave) exceptions = [] if happy_eyeballs_delay is None: # not using happy eyeballs for addrinfo in infos: try: sock = await self._connect_sock( exceptions, addrinfo, laddr_infos) break except OSError: continue else: # using happy eyeballs sock = (await staggered.staggered_race( ( # can't use functools.partial as it keeps a reference # to exceptions lambda addrinfo=addrinfo: self._connect_sock( exceptions, addrinfo, laddr_infos ) for addrinfo in infos ), happy_eyeballs_delay, loop=self, ))[0] # can't use sock, _, _ as it keeks a reference to exceptions if sock is None: exceptions = [exc for sub in exceptions for exc in sub] try: if all_errors: raise ExceptionGroup("create_connection failed", exceptions) if len(exceptions) == 1: raise exceptions[0] else: # If they all have the same str(), raise one. model = str(exceptions[0]) if all(str(exc) == model for exc in exceptions): raise exceptions[0] # Raise a combined exception so the user can see all # the various error messages. raise OSError('Multiple exceptions: {}'.format( ', '.join(str(exc) for exc in exceptions))) finally: exceptions = None else: if sock is None: raise ValueError( 'host and port was not specified and no sock specified') if sock.type != socket.SOCK_STREAM: # We allow AF_INET, AF_INET6, AF_UNIX as long as they # are SOCK_STREAM. # We support passing AF_UNIX sockets even though we have # a dedicated API for that: create_unix_connection. # Disallowing AF_UNIX in this method, breaks backwards # compatibility. raise ValueError( f'A Stream Socket was expected, got {sock!r}') transport, protocol = await self._create_connection_transport( sock, protocol_factory, ssl, server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) if self._debug: # Get the socket from the transport because SSL transport closes # the old socket and creates a new SSL socket sock = transport.get_extra_info('socket') logger.debug("%r connected to %s:%r: (%r, %r)", sock, host, port, transport, protocol) return transport, protocol async def _create_connection_transport( self, sock, protocol_factory, ssl, server_hostname, server_side=False, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): sock.setblocking(False) protocol = protocol_factory() waiter = self.create_future() if ssl: sslcontext = None if isinstance(ssl, bool) else ssl transport = self._make_ssl_transport( sock, protocol, sslcontext, waiter, server_side=server_side, server_hostname=server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) else: transport = self._make_socket_transport(sock, protocol, waiter) try: await waiter except: transport.close() raise return transport, protocol async def sendfile(self, transport, file, offset=0, count=None, *, fallback=True): """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. """ if transport.is_closing(): raise RuntimeError("Transport is closing") mode = getattr(transport, '_sendfile_compatible', constants._SendfileMode.UNSUPPORTED) if mode is constants._SendfileMode.UNSUPPORTED: raise RuntimeError( f"sendfile is not supported for transport {transport!r}") if mode is constants._SendfileMode.TRY_NATIVE: try: return await self._sendfile_native(transport, file, offset, count) except exceptions.SendfileNotAvailableError as exc: if not fallback: raise if not fallback: raise RuntimeError( f"fallback is disabled and native sendfile is not " f"supported for transport {transport!r}") return await self._sendfile_fallback(transport, file, offset, count) async def _sendfile_native(self, transp, file, offset, count): raise exceptions.SendfileNotAvailableError( "sendfile syscall is not supported") async def _sendfile_fallback(self, transp, file, offset, count): if offset: file.seek(offset) blocksize = min(count, 16384) if count else 16384 buf = bytearray(blocksize) total_sent = 0 proto = _SendfileFallbackProtocol(transp) try: while True: if count: blocksize = min(count - total_sent, blocksize) if blocksize <= 0: return total_sent view = memoryview(buf)[:blocksize] read = await self.run_in_executor(None, file.readinto, view) if not read: return total_sent # EOF transp.write(view[:read]) await proto.drain() total_sent += read finally: if total_sent > 0 and hasattr(file, 'seek'): file.seek(offset + total_sent) await proto.restore() async def start_tls(self, transport, protocol, sslcontext, *, server_side=False, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): """Upgrade transport to TLS. Return a new transport that *protocol* should start using immediately. """ if ssl is None: raise RuntimeError('Python ssl module is not available') if not isinstance(sslcontext, ssl.SSLContext): raise TypeError( f'sslcontext is expected to be an instance of ssl.SSLContext, ' f'got {sslcontext!r}') if not getattr(transport, '_start_tls_compatible', False): raise TypeError( f'transport {transport!r} is not supported by start_tls()') waiter = self.create_future() ssl_protocol = sslproto.SSLProtocol( self, protocol, sslcontext, waiter, server_side, server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout, call_connection_made=False) # Pause early so that "ssl_protocol.data_received()" doesn't # have a chance to get called before "ssl_protocol.connection_made()". transport.pause_reading() transport.set_protocol(ssl_protocol) conmade_cb = self.call_soon(ssl_protocol.connection_made, transport) resume_cb = self.call_soon(transport.resume_reading) try: await waiter except BaseException: transport.close() conmade_cb.cancel() resume_cb.cancel() raise return ssl_protocol._app_transport async def create_datagram_endpoint(self, protocol_factory, local_addr=None, remote_addr=None, *, family=0, proto=0, flags=0, reuse_port=None, allow_broadcast=None, sock=None): """Create datagram connection.""" if sock is not None: if sock.type == socket.SOCK_STREAM: raise ValueError( f'A datagram socket was expected, got {sock!r}') if (local_addr or remote_addr or family or proto or flags or reuse_port or allow_broadcast): # show the problematic kwargs in exception msg opts = dict(local_addr=local_addr, remote_addr=remote_addr, family=family, proto=proto, flags=flags, reuse_port=reuse_port, allow_broadcast=allow_broadcast) problems = ', '.join(f'{k}={v}' for k, v in opts.items() if v) raise ValueError( f'socket modifier keyword arguments can not be used ' f'when sock is specified. ({problems})') sock.setblocking(False) r_addr = None else: if not (local_addr or remote_addr): if family == 0: raise ValueError('unexpected address family') addr_pairs_info = (((family, proto), (None, None)),) elif hasattr(socket, 'AF_UNIX') and family == socket.AF_UNIX: for addr in (local_addr, remote_addr): if addr is not None and not isinstance(addr, str): raise TypeError('string is expected') if local_addr and local_addr[0] not in (0, '\x00'): try: if stat.S_ISSOCK(os.stat(local_addr).st_mode): os.remove(local_addr) except FileNotFoundError: pass except OSError as err: # Directory may have permissions only to create socket. logger.error('Unable to check or remove stale UNIX ' 'socket %r: %r', local_addr, err) addr_pairs_info = (((family, proto), (local_addr, remote_addr)), ) else: # join address by (family, protocol) addr_infos = {} # Using order preserving dict for idx, addr in ((0, local_addr), (1, remote_addr)): if addr is not None: if not (isinstance(addr, tuple) and len(addr) == 2): raise TypeError('2-tuple is expected') infos = await self._ensure_resolved( addr, family=family, type=socket.SOCK_DGRAM, proto=proto, flags=flags, loop=self) if not infos: raise OSError('getaddrinfo() returned empty list') for fam, _, pro, _, address in infos: key = (fam, pro) if key not in addr_infos: addr_infos[key] = [None, None] addr_infos[key][idx] = address # each addr has to have info for each (family, proto) pair addr_pairs_info = [ (key, addr_pair) for key, addr_pair in addr_infos.items() if not ((local_addr and addr_pair[0] is None) or (remote_addr and addr_pair[1] is None))] if not addr_pairs_info: raise ValueError('can not get address information') exceptions = [] for ((family, proto), (local_address, remote_address)) in addr_pairs_info: sock = None r_addr = None try: sock = socket.socket( family=family, type=socket.SOCK_DGRAM, proto=proto) if reuse_port: _set_reuseport(sock) if allow_broadcast: sock.setsockopt( socket.SOL_SOCKET, socket.SO_BROADCAST, 1) sock.setblocking(False) if local_addr: sock.bind(local_address) if remote_addr: if not allow_broadcast: await self.sock_connect(sock, remote_address) r_addr = remote_address except OSError as exc: if sock is not None: sock.close() exceptions.append(exc) except: if sock is not None: sock.close() raise else: break else: raise exceptions[0] protocol = protocol_factory() waiter = self.create_future() transport = self._make_datagram_transport( sock, protocol, r_addr, waiter) if self._debug: if local_addr: logger.info("Datagram endpoint local_addr=%r remote_addr=%r " "created: (%r, %r)", local_addr, remote_addr, transport, protocol) else: logger.debug("Datagram endpoint remote_addr=%r created: " "(%r, %r)", remote_addr, transport, protocol) try: await waiter except: transport.close() raise return transport, protocol async def _ensure_resolved(self, address, *, family=0, type=socket.SOCK_STREAM, proto=0, flags=0, loop): host, port = address[:2] info = _ipaddr_info(host, port, family, type, proto, *address[2:]) if info is not None: # "host" is already a resolved IP. return [info] else: return await loop.getaddrinfo(host, port, family=family, type=type, proto=proto, flags=flags) async def _create_server_getaddrinfo(self, host, port, family, flags): infos = await self._ensure_resolved((host, port), family=family, type=socket.SOCK_STREAM, flags=flags, loop=self) if not infos: raise OSError(f'getaddrinfo({host!r}) returned empty list') return infos async def create_server( self, protocol_factory, host=None, port=None, *, family=socket.AF_UNSPEC, flags=socket.AI_PASSIVE, sock=None, backlog=100, ssl=None, reuse_address=None, reuse_port=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, start_serving=True): """Create 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. """ if isinstance(ssl, bool): raise TypeError('ssl argument must be an SSLContext or None') if ssl_handshake_timeout is not None and ssl is None: raise ValueError( 'ssl_handshake_timeout is only meaningful with ssl') if ssl_shutdown_timeout is not None and ssl is None: raise ValueError( 'ssl_shutdown_timeout is only meaningful with ssl') if sock is not None: _check_ssl_socket(sock) if host is not None or port is not None: if sock is not None: raise ValueError( 'host/port and sock can not be specified at the same time') if reuse_address is None: reuse_address = os.name == "posix" and sys.platform != "cygwin" sockets = [] if host == '': hosts = [None] elif (isinstance(host, str) or not isinstance(host, collections.abc.Iterable)): hosts = [host] else: hosts = host fs = [self._create_server_getaddrinfo(host, port, family=family, flags=flags) for host in hosts] infos = await tasks.gather(*fs) infos = set(itertools.chain.from_iterable(infos)) completed = False try: for res in infos: af, socktype, proto, canonname, sa = res try: sock = socket.socket(af, socktype, proto) except socket.error: # Assume it's a bad family/type/protocol combination. if self._debug: logger.warning('create_server() failed to create ' 'socket.socket(%r, %r, %r)', af, socktype, proto, exc_info=True) continue sockets.append(sock) if reuse_address: sock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, True) # Since Linux 6.12.9, SO_REUSEPORT is not allowed # on other address families than AF_INET/AF_INET6. if reuse_port and af in (socket.AF_INET, socket.AF_INET6): _set_reuseport(sock) # Disable IPv4/IPv6 dual stack support (enabled by # default on Linux) which makes a single socket # listen on both address families. if (_HAS_IPv6 and af == socket.AF_INET6 and hasattr(socket, 'IPPROTO_IPV6')): sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, True) try: sock.bind(sa) except OSError as err: msg = ('error while attempting ' 'to bind on address %r: %s' % (sa, str(err).lower())) if err.errno == errno.EADDRNOTAVAIL: # Assume the family is not enabled (bpo-30945) sockets.pop() sock.close() if self._debug: logger.warning(msg) continue raise OSError(err.errno, msg) from None if not sockets: raise OSError('could not bind on any address out of %r' % ([info[4] for info in infos],)) completed = True finally: if not completed: for sock in sockets: sock.close() else: if sock is None: raise ValueError('Neither host/port nor sock were specified') if sock.type != socket.SOCK_STREAM: raise ValueError(f'A Stream Socket was expected, got {sock!r}') sockets = [sock] for sock in sockets: sock.setblocking(False) server = Server(self, sockets, protocol_factory, ssl, backlog, ssl_handshake_timeout, ssl_shutdown_timeout) if start_serving: server._start_serving() # Skip one loop iteration so that all 'loop.add_reader' # go through. await tasks.sleep(0) if self._debug: logger.info("%r is serving", server) return server async def connect_accepted_socket( self, protocol_factory, sock, *, ssl=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): if sock.type != socket.SOCK_STREAM: raise ValueError(f'A Stream Socket was expected, got {sock!r}') if ssl_handshake_timeout is not None and not ssl: raise ValueError( 'ssl_handshake_timeout is only meaningful with ssl') if ssl_shutdown_timeout is not None and not ssl: raise ValueError( 'ssl_shutdown_timeout is only meaningful with ssl') if sock is not None: _check_ssl_socket(sock) transport, protocol = await self._create_connection_transport( sock, protocol_factory, ssl, '', server_side=True, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) if self._debug: # Get the socket from the transport because SSL transport closes # the old socket and creates a new SSL socket sock = transport.get_extra_info('socket') logger.debug("%r handled: (%r, %r)", sock, transport, protocol) return transport, protocol async def connect_read_pipe(self, protocol_factory, pipe): protocol = protocol_factory() waiter = self.create_future() transport = self._make_read_pipe_transport(pipe, protocol, waiter) try: await waiter except: transport.close() raise if self._debug: logger.debug('Read pipe %r connected: (%r, %r)', pipe.fileno(), transport, protocol) return transport, protocol async def connect_write_pipe(self, protocol_factory, pipe): protocol = protocol_factory() waiter = self.create_future() transport = self._make_write_pipe_transport(pipe, protocol, waiter) try: await waiter except: transport.close() raise if self._debug: logger.debug('Write pipe %r connected: (%r, %r)', pipe.fileno(), transport, protocol) return transport, protocol def _log_subprocess(self, msg, stdin, stdout, stderr): info = [msg] if stdin is not None: info.append(f'stdin={_format_pipe(stdin)}') if stdout is not None and stderr == subprocess.STDOUT: info.append(f'stdout=stderr={_format_pipe(stdout)}') else: if stdout is not None: info.append(f'stdout={_format_pipe(stdout)}') if stderr is not None: info.append(f'stderr={_format_pipe(stderr)}') logger.debug(' '.join(info)) async def subprocess_shell(self, protocol_factory, cmd, *, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=False, shell=True, bufsize=0, encoding=None, errors=None, text=None, **kwargs): if not isinstance(cmd, (bytes, str)): raise ValueError("cmd must be a string") if universal_newlines: raise ValueError("universal_newlines must be False") if not shell: raise ValueError("shell must be True") if bufsize != 0: raise ValueError("bufsize must be 0") if text: raise ValueError("text must be False") if encoding is not None: raise ValueError("encoding must be None") if errors is not None: raise ValueError("errors must be None") protocol = protocol_factory() debug_log = None if self._debug: # don't log parameters: they may contain sensitive information # (password) and may be too long debug_log = 'run shell command %r' % cmd self._log_subprocess(debug_log, stdin, stdout, stderr) transport = await self._make_subprocess_transport( protocol, cmd, True, stdin, stdout, stderr, bufsize, **kwargs) if self._debug and debug_log is not None: logger.info('%s: %r', debug_log, transport) return transport, protocol async def subprocess_exec(self, protocol_factory, program, *args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=False, shell=False, bufsize=0, encoding=None, errors=None, text=None, **kwargs): if universal_newlines: raise ValueError("universal_newlines must be False") if shell: raise ValueError("shell must be False") if bufsize != 0: raise ValueError("bufsize must be 0") if text: raise ValueError("text must be False") if encoding is not None: raise ValueError("encoding must be None") if errors is not None: raise ValueError("errors must be None") popen_args = (program,) + args protocol = protocol_factory() debug_log = None if self._debug: # don't log parameters: they may contain sensitive information # (password) and may be too long debug_log = f'execute program {program!r}' self._log_subprocess(debug_log, stdin, stdout, stderr) transport = await self._make_subprocess_transport( protocol, popen_args, False, stdin, stdout, stderr, bufsize, **kwargs) if self._debug and debug_log is not None: logger.info('%s: %r', debug_log, transport) return transport, protocol def get_exception_handler(self): """Return an exception handler, or None if the default one is in use. """ return self._exception_handler def set_exception_handler(self, handler): """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). """ if handler is not None and not callable(handler): raise TypeError(f'A callable object or None is expected, ' f'got {handler!r}') self._exception_handler = handler def default_exception_handler(self, context): """Default 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()`. """ message = context.get('message') if not message: message = 'Unhandled exception in event loop' exception = context.get('exception') if exception is not None: exc_info = (type(exception), exception, exception.__traceback__) else: exc_info = False if ('source_traceback' not in context and self._current_handle is not None and self._current_handle._source_traceback): context['handle_traceback'] = \ self._current_handle._source_traceback log_lines = [message] for key in sorted(context): if key in {'message', 'exception'}: continue value = context[key] if key == 'source_traceback': tb = ''.join(traceback.format_list(value)) value = 'Object created at (most recent call last):\n' value += tb.rstrip() elif key == 'handle_traceback': tb = ''.join(traceback.format_list(value)) value = 'Handle created at (most recent call last):\n' value += tb.rstrip() else: value = repr(value) log_lines.append(f'{key}: {value}') logger.error('\n'.join(log_lines), exc_info=exc_info) def call_exception_handler(self, context): """Call 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. """ if self._exception_handler is None: try: self.default_exception_handler(context) except (SystemExit, KeyboardInterrupt): raise except BaseException: # Second protection layer for unexpected errors # in the default implementation, as well as for subclassed # event loops with overloaded "default_exception_handler". logger.error('Exception in default exception handler', exc_info=True) else: try: ctx = None thing = context.get("task") if thing is None: # Even though Futures don't have a context, # Task is a subclass of Future, # and sometimes the 'future' key holds a Task. thing = context.get("future") if thing is None: # Handles also have a context. thing = context.get("handle") if thing is not None and hasattr(thing, "get_context"): ctx = thing.get_context() if ctx is not None and hasattr(ctx, "run"): ctx.run(self._exception_handler, self, context) else: self._exception_handler(self, context) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: # Exception in the user set custom exception handler. try: # Let's try default handler. self.default_exception_handler({ 'message': 'Unhandled error in exception handler', 'exception': exc, 'context': context, }) except (SystemExit, KeyboardInterrupt): raise except BaseException: # Guard 'default_exception_handler' in case it is # overloaded. logger.error('Exception in default exception handler ' 'while handling an unexpected error ' 'in custom exception handler', exc_info=True) def _add_callback(self, handle): """Add a Handle to _ready.""" if not handle._cancelled: self._ready.append(handle) def _add_callback_signalsafe(self, handle): """Like _add_callback() but called from a signal handler.""" self._add_callback(handle) self._write_to_self() def _timer_handle_cancelled(self, handle): """Notification that a TimerHandle has been cancelled.""" if handle._scheduled: self._timer_cancelled_count += 1 def _run_once(self): """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. """ sched_count = len(self._scheduled) if (sched_count > _MIN_SCHEDULED_TIMER_HANDLES and self._timer_cancelled_count / sched_count > _MIN_CANCELLED_TIMER_HANDLES_FRACTION): # Remove delayed calls that were cancelled if their number # is too high new_scheduled = [] for handle in self._scheduled: if handle._cancelled: handle._scheduled = False else: new_scheduled.append(handle) heapq.heapify(new_scheduled) self._scheduled = new_scheduled self._timer_cancelled_count = 0 else: # Remove delayed calls that were cancelled from head of queue. while self._scheduled and self._scheduled[0]._cancelled: self._timer_cancelled_count -= 1 handle = heapq.heappop(self._scheduled) handle._scheduled = False timeout = None if self._ready or self._stopping: timeout = 0 elif self._scheduled: # Compute the desired timeout. when = self._scheduled[0]._when timeout = min(max(0, when - self.time()), MAXIMUM_SELECT_TIMEOUT) event_list = self._selector.select(timeout) self._process_events(event_list) # Needed to break cycles when an exception occurs. event_list = None # Handle 'later' callbacks that are ready. end_time = self.time() + self._clock_resolution while self._scheduled: handle = self._scheduled[0] if handle._when >= end_time: break handle = heapq.heappop(self._scheduled) handle._scheduled = False self._ready.append(handle) # This is the only place where callbacks are actually *called*. # All other places just add them to ready. # Note: We run all currently scheduled callbacks, but not any # callbacks scheduled by callbacks run this time around -- # they will be run the next time (after another I/O poll). # Use an idiom that is thread-safe without using locks. ntodo = len(self._ready) for i in range(ntodo): handle = self._ready.popleft() if handle._cancelled: continue if self._debug: try: self._current_handle = handle t0 = self.time() handle._run() dt = self.time() - t0 if dt >= self.slow_callback_duration: logger.warning('Executing %s took %.3f seconds', _format_handle(handle), dt) finally: self._current_handle = None else: handle._run() handle = None # Needed to break cycles when an exception occurs. def _set_coroutine_origin_tracking(self, enabled): if bool(enabled) == bool(self._coroutine_origin_tracking_enabled): return if enabled: self._coroutine_origin_tracking_saved_depth = ( sys.get_coroutine_origin_tracking_depth()) sys.set_coroutine_origin_tracking_depth( constants.DEBUG_STACK_DEPTH) else: sys.set_coroutine_origin_tracking_depth( self._coroutine_origin_tracking_saved_depth) self._coroutine_origin_tracking_enabled = enabled def get_debug(self): return self._debug def set_debug(self, enabled): self._debug = enabled if self.is_running(): self.call_soon_threadsafe(self._set_coroutine_origin_tracking, enabled) base_futures.py000064400000003666151706172560007632 0ustar00__all__ = () import reprlib from . import format_helpers # States for Future. _PENDING = 'PENDING' _CANCELLED = 'CANCELLED' _FINISHED = 'FINISHED' def isfuture(obj): """Check for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. """ return (hasattr(obj.__class__, '_asyncio_future_blocking') and obj._asyncio_future_blocking is not None) def _format_callbacks(cb): """helper function for Future.__repr__""" size = len(cb) if not size: cb = '' def format_cb(callback): return format_helpers._format_callback_source(callback, ()) if size == 1: cb = format_cb(cb[0][0]) elif size == 2: cb = '{}, {}'.format(format_cb(cb[0][0]), format_cb(cb[1][0])) elif size > 2: cb = '{}, <{} more>, {}'.format(format_cb(cb[0][0]), size - 2, format_cb(cb[-1][0])) return f'cb=[{cb}]' def _future_repr_info(future): # (Future) -> str """helper function for Future.__repr__""" info = [future._state.lower()] if future._state == _FINISHED: if future._exception is not None: info.append(f'exception={future._exception!r}') else: # use reprlib to limit the length of the output, especially # for very long strings result = reprlib.repr(future._result) info.append(f'result={result}') if future._callbacks: info.append(_format_callbacks(future._callbacks)) if future._source_traceback: frame = future._source_traceback[-1] info.append(f'created at {frame[0]}:{frame[1]}') return info @reprlib.recursive_repr() def _future_repr(future): info = ' '.join(_future_repr_info(future)) return f'<{future.__class__.__name__} {info}>' base_subprocess.py000064400000021245151706172560010316 0ustar00import collections import subprocess import warnings from . import protocols from . import transports from .log import logger class BaseSubprocessTransport(transports.SubprocessTransport): def __init__(self, loop, protocol, args, shell, stdin, stdout, stderr, bufsize, waiter=None, extra=None, **kwargs): super().__init__(extra) self._closed = False self._protocol = protocol self._loop = loop self._proc = None self._pid = None self._returncode = None self._exit_waiters = [] self._pending_calls = collections.deque() self._pipes = {} self._finished = False if stdin == subprocess.PIPE: self._pipes[0] = None if stdout == subprocess.PIPE: self._pipes[1] = None if stderr == subprocess.PIPE: self._pipes[2] = None # Create the child process: set the _proc attribute try: self._start(args=args, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr, bufsize=bufsize, **kwargs) except: self.close() raise self._pid = self._proc.pid self._extra['subprocess'] = self._proc if self._loop.get_debug(): if isinstance(args, (bytes, str)): program = args else: program = args[0] logger.debug('process %r created: pid %s', program, self._pid) self._loop.create_task(self._connect_pipes(waiter)) def __repr__(self): info = [self.__class__.__name__] if self._closed: info.append('closed') if self._pid is not None: info.append(f'pid={self._pid}') if self._returncode is not None: info.append(f'returncode={self._returncode}') elif self._pid is not None: info.append('running') else: info.append('not started') stdin = self._pipes.get(0) if stdin is not None: info.append(f'stdin={stdin.pipe}') stdout = self._pipes.get(1) stderr = self._pipes.get(2) if stdout is not None and stderr is stdout: info.append(f'stdout=stderr={stdout.pipe}') else: if stdout is not None: info.append(f'stdout={stdout.pipe}') if stderr is not None: info.append(f'stderr={stderr.pipe}') return '<{}>'.format(' '.join(info)) def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs): raise NotImplementedError def set_protocol(self, protocol): self._protocol = protocol def get_protocol(self): return self._protocol def is_closing(self): return self._closed def close(self): if self._closed: return self._closed = True for proto in self._pipes.values(): if proto is None: continue proto.pipe.close() if (self._proc is not None and # has the child process finished? self._returncode is None and # the child process has finished, but the # transport hasn't been notified yet? self._proc.poll() is None): if self._loop.get_debug(): logger.warning('Close running child process: kill %r', self) try: self._proc.kill() except ProcessLookupError: pass # Don't clear the _proc reference yet: _post_init() may still run def __del__(self, _warn=warnings.warn): if not self._closed: _warn(f"unclosed transport {self!r}", ResourceWarning, source=self) self.close() def get_pid(self): return self._pid def get_returncode(self): return self._returncode def get_pipe_transport(self, fd): if fd in self._pipes: return self._pipes[fd].pipe else: return None def _check_proc(self): if self._proc is None: raise ProcessLookupError() def send_signal(self, signal): self._check_proc() self._proc.send_signal(signal) def terminate(self): self._check_proc() self._proc.terminate() def kill(self): self._check_proc() self._proc.kill() async def _connect_pipes(self, waiter): try: proc = self._proc loop = self._loop if proc.stdin is not None: _, pipe = await loop.connect_write_pipe( lambda: WriteSubprocessPipeProto(self, 0), proc.stdin) self._pipes[0] = pipe if proc.stdout is not None: _, pipe = await loop.connect_read_pipe( lambda: ReadSubprocessPipeProto(self, 1), proc.stdout) self._pipes[1] = pipe if proc.stderr is not None: _, pipe = await loop.connect_read_pipe( lambda: ReadSubprocessPipeProto(self, 2), proc.stderr) self._pipes[2] = pipe assert self._pending_calls is not None loop.call_soon(self._protocol.connection_made, self) for callback, data in self._pending_calls: loop.call_soon(callback, *data) self._pending_calls = None except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: if waiter is not None and not waiter.cancelled(): waiter.set_exception(exc) else: if waiter is not None and not waiter.cancelled(): waiter.set_result(None) def _call(self, cb, *data): if self._pending_calls is not None: self._pending_calls.append((cb, data)) else: self._loop.call_soon(cb, *data) def _pipe_connection_lost(self, fd, exc): self._call(self._protocol.pipe_connection_lost, fd, exc) self._try_finish() def _pipe_data_received(self, fd, data): self._call(self._protocol.pipe_data_received, fd, data) def _process_exited(self, returncode): assert returncode is not None, returncode assert self._returncode is None, self._returncode if self._loop.get_debug(): logger.info('%r exited with return code %r', self, returncode) self._returncode = returncode if self._proc.returncode is None: # asyncio uses a child watcher: copy the status into the Popen # object. On Python 3.6, it is required to avoid a ResourceWarning. self._proc.returncode = returncode self._call(self._protocol.process_exited) self._try_finish() async def _wait(self): """Wait until the process exit and return the process return code. This method is a coroutine.""" if self._returncode is not None: return self._returncode waiter = self._loop.create_future() self._exit_waiters.append(waiter) return await waiter def _try_finish(self): assert not self._finished if self._returncode is None: return if all(p is not None and p.disconnected for p in self._pipes.values()): self._finished = True self._call(self._call_connection_lost, None) def _call_connection_lost(self, exc): try: self._protocol.connection_lost(exc) finally: # wake up futures waiting for wait() for waiter in self._exit_waiters: if not waiter.cancelled(): waiter.set_result(self._returncode) self._exit_waiters = None self._loop = None self._proc = None self._protocol = None class WriteSubprocessPipeProto(protocols.BaseProtocol): def __init__(self, proc, fd): self.proc = proc self.fd = fd self.pipe = None self.disconnected = False def connection_made(self, transport): self.pipe = transport def __repr__(self): return f'<{self.__class__.__name__} fd={self.fd} pipe={self.pipe!r}>' def connection_lost(self, exc): self.disconnected = True self.proc._pipe_connection_lost(self.fd, exc) self.proc = None def pause_writing(self): self.proc._protocol.pause_writing() def resume_writing(self): self.proc._protocol.resume_writing() class ReadSubprocessPipeProto(WriteSubprocessPipeProto, protocols.Protocol): def data_received(self, data): self.proc._pipe_data_received(self.fd, data) base_tasks.py000064400000005160151706172560007251 0ustar00import linecache import reprlib import traceback from . import base_futures from . import coroutines def _task_repr_info(task): info = base_futures._future_repr_info(task) if task.cancelling() and not task.done(): # replace status info[0] = 'cancelling' info.insert(1, 'name=%r' % task.get_name()) if task._fut_waiter is not None: info.insert(2, f'wait_for={task._fut_waiter!r}') if task._coro: coro = coroutines._format_coroutine(task._coro) info.insert(2, f'coro=<{coro}>') return info @reprlib.recursive_repr() def _task_repr(task): info = ' '.join(_task_repr_info(task)) return f'<{task.__class__.__name__} {info}>' def _task_get_stack(task, limit): frames = [] if hasattr(task._coro, 'cr_frame'): # case 1: 'async def' coroutines f = task._coro.cr_frame elif hasattr(task._coro, 'gi_frame'): # case 2: legacy coroutines f = task._coro.gi_frame elif hasattr(task._coro, 'ag_frame'): # case 3: async generators f = task._coro.ag_frame else: # case 4: unknown objects f = None if f is not None: while f is not None: if limit is not None: if limit <= 0: break limit -= 1 frames.append(f) f = f.f_back frames.reverse() elif task._exception is not None: tb = task._exception.__traceback__ while tb is not None: if limit is not None: if limit <= 0: break limit -= 1 frames.append(tb.tb_frame) tb = tb.tb_next return frames def _task_print_stack(task, limit, file): extracted_list = [] checked = set() for f in task.get_stack(limit=limit): lineno = f.f_lineno co = f.f_code filename = co.co_filename name = co.co_name if filename not in checked: checked.add(filename) linecache.checkcache(filename) line = linecache.getline(filename, lineno, f.f_globals) extracted_list.append((filename, lineno, name, line)) exc = task._exception if not extracted_list: print(f'No stack for {task!r}', file=file) elif exc is not None: print(f'Traceback for {task!r} (most recent call last):', file=file) else: print(f'Stack for {task!r} (most recent call last):', file=file) traceback.print_list(extracted_list, file=file) if exc is not None: for line in traceback.format_exception_only(exc.__class__, exc): print(line, file=file, end='') constants.py000064400000002605151706172560007147 0ustar00# Contains code from https://github.com/MagicStack/uvloop/tree/v0.16.0 # SPDX-License-Identifier: PSF-2.0 AND (MIT OR Apache-2.0) # SPDX-FileCopyrightText: Copyright (c) 2015-2021 MagicStack Inc. http://magic.io import enum # After the connection is lost, log warnings after this many write()s. LOG_THRESHOLD_FOR_CONNLOST_WRITES = 5 # Seconds to wait before retrying accept(). ACCEPT_RETRY_DELAY = 1 # Number of stack entries to capture in debug mode. # The larger the number, the slower the operation in debug mode # (see extract_stack() in format_helpers.py). DEBUG_STACK_DEPTH = 10 # Number of seconds to wait for SSL handshake to complete # The default timeout matches that of Nginx. SSL_HANDSHAKE_TIMEOUT = 60.0 # Number of seconds to wait for SSL shutdown to complete # The default timeout mimics lingering_time SSL_SHUTDOWN_TIMEOUT = 30.0 # Used in sendfile fallback code. We use fallback for platforms # that don't support sendfile, or for TLS connections. SENDFILE_FALLBACK_READBUFFER_SIZE = 1024 * 256 FLOW_CONTROL_HIGH_WATER_SSL_READ = 256 # KiB FLOW_CONTROL_HIGH_WATER_SSL_WRITE = 512 # KiB # Default timeout for joining the threads in the threadpool THREAD_JOIN_TIMEOUT = 300 # The enum should be here to break circular dependencies between # base_events and sslproto class _SendfileMode(enum.Enum): UNSUPPORTED = enum.auto() TRY_NATIVE = enum.auto() FALLBACK = enum.auto() coroutines.py000064400000006416151706172570007332 0ustar00__all__ = 'iscoroutinefunction', 'iscoroutine' import collections.abc import inspect import os import sys import types def _is_debug_mode(): # See: https://docs.python.org/3/library/asyncio-dev.html#asyncio-debug-mode. return sys.flags.dev_mode or (not sys.flags.ignore_environment and bool(os.environ.get('PYTHONASYNCIODEBUG'))) # A marker for iscoroutinefunction. _is_coroutine = object() def iscoroutinefunction(func): """Return True if func is a decorated coroutine function.""" return (inspect.iscoroutinefunction(func) or getattr(func, '_is_coroutine', None) is _is_coroutine) # Prioritize native coroutine check to speed-up # asyncio.iscoroutine. _COROUTINE_TYPES = (types.CoroutineType, collections.abc.Coroutine) _iscoroutine_typecache = set() def iscoroutine(obj): """Return True if obj is a coroutine object.""" if type(obj) in _iscoroutine_typecache: return True if isinstance(obj, _COROUTINE_TYPES): # Just in case we don't want to cache more than 100 # positive types. That shouldn't ever happen, unless # someone stressing the system on purpose. if len(_iscoroutine_typecache) < 100: _iscoroutine_typecache.add(type(obj)) return True else: return False def _format_coroutine(coro): assert iscoroutine(coro) def get_name(coro): # Coroutines compiled with Cython sometimes don't have # proper __qualname__ or __name__. While that is a bug # in Cython, asyncio shouldn't crash with an AttributeError # in its __repr__ functions. if hasattr(coro, '__qualname__') and coro.__qualname__: coro_name = coro.__qualname__ elif hasattr(coro, '__name__') and coro.__name__: coro_name = coro.__name__ else: # Stop masking Cython bugs, expose them in a friendly way. coro_name = f'<{type(coro).__name__} without __name__>' return f'{coro_name}()' def is_running(coro): try: return coro.cr_running except AttributeError: try: return coro.gi_running except AttributeError: return False coro_code = None if hasattr(coro, 'cr_code') and coro.cr_code: coro_code = coro.cr_code elif hasattr(coro, 'gi_code') and coro.gi_code: coro_code = coro.gi_code coro_name = get_name(coro) if not coro_code: # Built-in types might not have __qualname__ or __name__. if is_running(coro): return f'{coro_name} running' else: return coro_name coro_frame = None if hasattr(coro, 'gi_frame') and coro.gi_frame: coro_frame = coro.gi_frame elif hasattr(coro, 'cr_frame') and coro.cr_frame: coro_frame = coro.cr_frame # If Cython's coroutine has a fake code object without proper # co_filename -- expose that. filename = coro_code.co_filename or '<empty co_filename>' lineno = 0 if coro_frame is not None: lineno = coro_frame.f_lineno coro_repr = f'{coro_name} running at {filename}:{lineno}' else: lineno = coro_code.co_firstlineno coro_repr = f'{coro_name} done, defined at {filename}:{lineno}' return coro_repr events.py000064400000071233151706172570006443 0ustar00"""Event loop and event loop policy.""" # Contains code from https://github.com/MagicStack/uvloop/tree/v0.16.0 # SPDX-License-Identifier: PSF-2.0 AND (MIT OR Apache-2.0) # SPDX-FileCopyrightText: Copyright (c) 2015-2021 MagicStack Inc. http://magic.io __all__ = ( 'AbstractEventLoopPolicy', 'AbstractEventLoop', 'AbstractServer', 'Handle', 'TimerHandle', 'get_event_loop_policy', 'set_event_loop_policy', 'get_event_loop', 'set_event_loop', 'new_event_loop', 'get_child_watcher', 'set_child_watcher', '_set_running_loop', 'get_running_loop', '_get_running_loop', ) import contextvars import os import signal import socket import subprocess import sys import threading from . import format_helpers class Handle: """Object returned by callback registration methods.""" __slots__ = ('_callback', '_args', '_cancelled', '_loop', '_source_traceback', '_repr', '__weakref__', '_context') def __init__(self, callback, args, loop, context=None): if context is None: context = contextvars.copy_context() self._context = context self._loop = loop self._callback = callback self._args = args self._cancelled = False self._repr = None if self._loop.get_debug(): self._source_traceback = format_helpers.extract_stack( sys._getframe(1)) else: self._source_traceback = None def _repr_info(self): info = [self.__class__.__name__] if self._cancelled: info.append('cancelled') if self._callback is not None: info.append(format_helpers._format_callback_source( self._callback, self._args)) if self._source_traceback: frame = self._source_traceback[-1] info.append(f'created at {frame[0]}:{frame[1]}') return info def __repr__(self): if self._repr is not None: return self._repr info = self._repr_info() return '<{}>'.format(' '.join(info)) def get_context(self): return self._context def cancel(self): if not self._cancelled: self._cancelled = True if self._loop.get_debug(): # Keep a representation in debug mode to keep callback and # parameters. For example, to log the warning # "Executing <Handle...> took 2.5 second" self._repr = repr(self) self._callback = None self._args = None def cancelled(self): return self._cancelled def _run(self): try: self._context.run(self._callback, *self._args) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: cb = format_helpers._format_callback_source( self._callback, self._args) msg = f'Exception in callback {cb}' context = { 'message': msg, 'exception': exc, 'handle': self, } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) self = None # Needed to break cycles when an exception occurs. class TimerHandle(Handle): """Object returned by timed callback registration methods.""" __slots__ = ['_scheduled', '_when'] def __init__(self, when, callback, args, loop, context=None): super().__init__(callback, args, loop, context) if self._source_traceback: del self._source_traceback[-1] self._when = when self._scheduled = False def _repr_info(self): info = super()._repr_info() pos = 2 if self._cancelled else 1 info.insert(pos, f'when={self._when}') return info def __hash__(self): return hash(self._when) def __lt__(self, other): if isinstance(other, TimerHandle): return self._when < other._when return NotImplemented def __le__(self, other): if isinstance(other, TimerHandle): return self._when < other._when or self.__eq__(other) return NotImplemented def __gt__(self, other): if isinstance(other, TimerHandle): return self._when > other._when return NotImplemented def __ge__(self, other): if isinstance(other, TimerHandle): return self._when > other._when or self.__eq__(other) return NotImplemented def __eq__(self, other): if isinstance(other, TimerHandle): return (self._when == other._when and self._callback == other._callback and self._args == other._args and self._cancelled == other._cancelled) return NotImplemented def cancel(self): if not self._cancelled: self._loop._timer_handle_cancelled(self) super().cancel() def when(self): """Return a scheduled callback time. The time is an absolute timestamp, using the same time reference as loop.time(). """ return self._when class AbstractServer: """Abstract server returned by create_server().""" def close(self): """Stop serving. This leaves existing connections open.""" raise NotImplementedError def get_loop(self): """Get the event loop the Server object is attached to.""" raise NotImplementedError def is_serving(self): """Return True if the server is accepting connections.""" raise NotImplementedError async def start_serving(self): """Start accepting connections. This method is idempotent, so it can be called when the server is already being serving. """ raise NotImplementedError async def serve_forever(self): """Start accepting connections until the coroutine is cancelled. The server is closed when the coroutine is cancelled. """ raise NotImplementedError async def wait_closed(self): """Coroutine to wait until service is closed.""" raise NotImplementedError async def __aenter__(self): return self async def __aexit__(self, *exc): self.close() await self.wait_closed() class AbstractEventLoop: """Abstract event loop.""" # Running and stopping the event loop. def run_forever(self): """Run the event loop until stop() is called.""" raise NotImplementedError def run_until_complete(self, future): """Run the event loop until a Future is done. Return the Future's result, or raise its exception. """ raise NotImplementedError def stop(self): """Stop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. """ raise NotImplementedError def is_running(self): """Return whether the event loop is currently running.""" raise NotImplementedError def is_closed(self): """Returns True if the event loop was closed.""" raise NotImplementedError def close(self): """Close the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. """ raise NotImplementedError async def shutdown_asyncgens(self): """Shutdown all active asynchronous generators.""" raise NotImplementedError async def shutdown_default_executor(self): """Schedule the shutdown of the default executor.""" raise NotImplementedError # Methods scheduling callbacks. All these return Handles. def _timer_handle_cancelled(self, handle): """Notification that a TimerHandle has been cancelled.""" raise NotImplementedError def call_soon(self, callback, *args, context=None): return self.call_later(0, callback, *args, context=context) def call_later(self, delay, callback, *args, context=None): raise NotImplementedError def call_at(self, when, callback, *args, context=None): raise NotImplementedError def time(self): raise NotImplementedError def create_future(self): raise NotImplementedError # Method scheduling a coroutine object: create a task. def create_task(self, coro, *, name=None, context=None): raise NotImplementedError # Methods for interacting with threads. def call_soon_threadsafe(self, callback, *args, context=None): raise NotImplementedError def run_in_executor(self, executor, func, *args): raise NotImplementedError def set_default_executor(self, executor): raise NotImplementedError # Network I/O methods returning Futures. async def getaddrinfo(self, host, port, *, family=0, type=0, proto=0, flags=0): raise NotImplementedError async def getnameinfo(self, sockaddr, flags=0): raise NotImplementedError async def create_connection( self, protocol_factory, host=None, port=None, *, ssl=None, family=0, proto=0, flags=0, sock=None, local_addr=None, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, happy_eyeballs_delay=None, interleave=None): raise NotImplementedError async def create_server( self, protocol_factory, host=None, port=None, *, family=socket.AF_UNSPEC, flags=socket.AI_PASSIVE, sock=None, backlog=100, ssl=None, reuse_address=None, reuse_port=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, start_serving=True): """A coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. ssl_handshake_timeout is the time in seconds that an SSL server will wait for completion of the SSL handshake before aborting the connection. Default is 60s. ssl_shutdown_timeout is the time in seconds that an SSL server will wait for completion of the SSL shutdown procedure before aborting the connection. Default is 30s. start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. """ raise NotImplementedError async def sendfile(self, transport, file, offset=0, count=None, *, fallback=True): """Send a file through a transport. Return an amount of sent bytes. """ raise NotImplementedError async def start_tls(self, transport, protocol, sslcontext, *, server_side=False, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): """Upgrade a transport to TLS. Return a new transport that *protocol* should start using immediately. """ raise NotImplementedError async def create_unix_connection( self, protocol_factory, path=None, *, ssl=None, sock=None, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): raise NotImplementedError async def create_unix_server( self, protocol_factory, path=None, *, sock=None, backlog=100, ssl=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, start_serving=True): """A coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file system path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. ssl_handshake_timeout is the time in seconds that an SSL server will wait for the SSL handshake to complete (defaults to 60s). ssl_shutdown_timeout is the time in seconds that an SSL server will wait for the SSL shutdown to finish (defaults to 30s). start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. """ raise NotImplementedError async def connect_accepted_socket( self, protocol_factory, sock, *, ssl=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): """Handle an accepted connection. This is used by servers that accept connections outside of asyncio, but use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. """ raise NotImplementedError async def create_datagram_endpoint(self, protocol_factory, local_addr=None, remote_addr=None, *, family=0, proto=0, flags=0, reuse_address=None, reuse_port=None, allow_broadcast=None, sock=None): """A coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. """ raise NotImplementedError # Pipes and subprocesses. async def connect_read_pipe(self, protocol_factory, pipe): """Register read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.""" # The reason to accept file-like object instead of just file descriptor # is: we need to own pipe and close it at transport finishing # Can got complicated errors if pass f.fileno(), # close fd in pipe transport then close f and vice versa. raise NotImplementedError async def connect_write_pipe(self, protocol_factory, pipe): """Register write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.""" # The reason to accept file-like object instead of just file descriptor # is: we need to own pipe and close it at transport finishing # Can got complicated errors if pass f.fileno(), # close fd in pipe transport then close f and vice versa. raise NotImplementedError async def subprocess_shell(self, protocol_factory, cmd, *, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs): raise NotImplementedError async def subprocess_exec(self, protocol_factory, *args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs): raise NotImplementedError # Ready-based callback registration methods. # The add_*() methods return None. # The remove_*() methods return True if something was removed, # False if there was nothing to delete. def add_reader(self, fd, callback, *args): raise NotImplementedError def remove_reader(self, fd): raise NotImplementedError def add_writer(self, fd, callback, *args): raise NotImplementedError def remove_writer(self, fd): raise NotImplementedError # Completion based I/O methods returning Futures. async def sock_recv(self, sock, nbytes): raise NotImplementedError async def sock_recv_into(self, sock, buf): raise NotImplementedError async def sock_recvfrom(self, sock, bufsize): raise NotImplementedError async def sock_recvfrom_into(self, sock, buf, nbytes=0): raise NotImplementedError async def sock_sendall(self, sock, data): raise NotImplementedError async def sock_sendto(self, sock, data, address): raise NotImplementedError async def sock_connect(self, sock, address): raise NotImplementedError async def sock_accept(self, sock): raise NotImplementedError async def sock_sendfile(self, sock, file, offset=0, count=None, *, fallback=None): raise NotImplementedError # Signal handling. def add_signal_handler(self, sig, callback, *args): raise NotImplementedError def remove_signal_handler(self, sig): raise NotImplementedError # Task factory. def set_task_factory(self, factory): raise NotImplementedError def get_task_factory(self): raise NotImplementedError # Error handlers. def get_exception_handler(self): raise NotImplementedError def set_exception_handler(self, handler): raise NotImplementedError def default_exception_handler(self, context): raise NotImplementedError def call_exception_handler(self, context): raise NotImplementedError # Debug flag management. def get_debug(self): raise NotImplementedError def set_debug(self, enabled): raise NotImplementedError class AbstractEventLoopPolicy: """Abstract policy for accessing the event loop.""" def get_event_loop(self): """Get the event loop for the current context. Returns an event loop object implementing the AbstractEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.""" raise NotImplementedError def set_event_loop(self, loop): """Set the event loop for the current context to loop.""" raise NotImplementedError def new_event_loop(self): """Create and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.""" raise NotImplementedError # Child processes handling (Unix only). def get_child_watcher(self): "Get the watcher for child processes." raise NotImplementedError def set_child_watcher(self, watcher): """Set the watcher for child processes.""" raise NotImplementedError class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy): """Default policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). """ _loop_factory = None class _Local(threading.local): _loop = None _set_called = False def __init__(self): self._local = self._Local() def get_event_loop(self): """Get the event loop for the current context. Returns an instance of EventLoop or raises an exception. """ if (self._local._loop is None and not self._local._set_called and threading.current_thread() is threading.main_thread()): stacklevel = 2 try: f = sys._getframe(1) except AttributeError: pass else: # Move up the call stack so that the warning is attached # to the line outside asyncio itself. while f: module = f.f_globals.get('__name__') if not (module == 'asyncio' or module.startswith('asyncio.')): break f = f.f_back stacklevel += 1 import warnings warnings.warn('There is no current event loop', DeprecationWarning, stacklevel=stacklevel) self.set_event_loop(self.new_event_loop()) if self._local._loop is None: raise RuntimeError('There is no current event loop in thread %r.' % threading.current_thread().name) return self._local._loop def set_event_loop(self, loop): """Set the event loop.""" self._local._set_called = True if loop is not None and not isinstance(loop, AbstractEventLoop): raise TypeError(f"loop must be an instance of AbstractEventLoop or None, not '{type(loop).__name__}'") self._local._loop = loop def new_event_loop(self): """Create a new event loop. You must call set_event_loop() to make this the current event loop. """ return self._loop_factory() # Event loop policy. The policy itself is always global, even if the # policy's rules say that there is an event loop per thread (or other # notion of context). The default policy is installed by the first # call to get_event_loop_policy(). _event_loop_policy = None # Lock for protecting the on-the-fly creation of the event loop policy. _lock = threading.Lock() # A TLS for the running event loop, used by _get_running_loop. class _RunningLoop(threading.local): loop_pid = (None, None) _running_loop = _RunningLoop() def get_running_loop(): """Return the running event loop. Raise a RuntimeError if there is none. This function is thread-specific. """ # NOTE: this function is implemented in C (see _asynciomodule.c) loop = _get_running_loop() if loop is None: raise RuntimeError('no running event loop') return loop def _get_running_loop(): """Return the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. """ # NOTE: this function is implemented in C (see _asynciomodule.c) running_loop, pid = _running_loop.loop_pid if running_loop is not None and pid == os.getpid(): return running_loop def _set_running_loop(loop): """Set the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. """ # NOTE: this function is implemented in C (see _asynciomodule.c) _running_loop.loop_pid = (loop, os.getpid()) def _init_event_loop_policy(): global _event_loop_policy with _lock: if _event_loop_policy is None: # pragma: no branch from . import DefaultEventLoopPolicy _event_loop_policy = DefaultEventLoopPolicy() def get_event_loop_policy(): """Get the current event loop policy.""" if _event_loop_policy is None: _init_event_loop_policy() return _event_loop_policy def set_event_loop_policy(policy): """Set the current event loop policy. If policy is None, the default policy is restored.""" global _event_loop_policy if policy is not None and not isinstance(policy, AbstractEventLoopPolicy): raise TypeError(f"policy must be an instance of AbstractEventLoopPolicy or None, not '{type(policy).__name__}'") _event_loop_policy = policy def get_event_loop(): """Return an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. """ # NOTE: this function is implemented in C (see _asynciomodule.c) current_loop = _get_running_loop() if current_loop is not None: return current_loop return get_event_loop_policy().get_event_loop() def set_event_loop(loop): """Equivalent to calling get_event_loop_policy().set_event_loop(loop).""" get_event_loop_policy().set_event_loop(loop) def new_event_loop(): """Equivalent to calling get_event_loop_policy().new_event_loop().""" return get_event_loop_policy().new_event_loop() def get_child_watcher(): """Equivalent to calling get_event_loop_policy().get_child_watcher().""" return get_event_loop_policy().get_child_watcher() def set_child_watcher(watcher): """Equivalent to calling get_event_loop_policy().set_child_watcher(watcher).""" return get_event_loop_policy().set_child_watcher(watcher) # Alias pure-Python implementations for testing purposes. _py__get_running_loop = _get_running_loop _py__set_running_loop = _set_running_loop _py_get_running_loop = get_running_loop _py_get_event_loop = get_event_loop try: # get_event_loop() is one of the most frequently called # functions in asyncio. Pure Python implementation is # about 4 times slower than C-accelerated. from _asyncio import (_get_running_loop, _set_running_loop, get_running_loop, get_event_loop) except ImportError: pass else: # Alias C implementations for testing purposes. _c__get_running_loop = _get_running_loop _c__set_running_loop = _set_running_loop _c_get_running_loop = get_running_loop _c_get_event_loop = get_event_loop if hasattr(os, 'fork'): def on_fork(): # Reset the loop and wakeupfd in the forked child process. if _event_loop_policy is not None: _event_loop_policy._local = BaseDefaultEventLoopPolicy._Local() _set_running_loop(None) signal.set_wakeup_fd(-1) os.register_at_fork(after_in_child=on_fork) exceptions.py000064400000003330151706172570007311 0ustar00"""asyncio exceptions.""" __all__ = ('BrokenBarrierError', 'CancelledError', 'InvalidStateError', 'TimeoutError', 'IncompleteReadError', 'LimitOverrunError', 'SendfileNotAvailableError') class CancelledError(BaseException): """The Future or Task was cancelled.""" TimeoutError = TimeoutError # make local alias for the standard exception class InvalidStateError(Exception): """The operation is not allowed in this state.""" class SendfileNotAvailableError(RuntimeError): """Sendfile syscall is not available. Raised if OS does not support sendfile syscall for given socket or file type. """ class IncompleteReadError(EOFError): """ Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) """ def __init__(self, partial, expected): r_expected = 'undefined' if expected is None else repr(expected) super().__init__(f'{len(partial)} bytes read on a total of ' f'{r_expected} expected bytes') self.partial = partial self.expected = expected def __reduce__(self): return type(self), (self.partial, self.expected) class LimitOverrunError(Exception): """Reached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. """ def __init__(self, message, consumed): super().__init__(message) self.consumed = consumed def __reduce__(self): return type(self), (self.args[0], self.consumed) class BrokenBarrierError(RuntimeError): """Barrier is broken by barrier.abort() call.""" format_helpers.py000064400000004544151706172570010152 0ustar00import functools import inspect import reprlib import sys import traceback from . import constants def _get_function_source(func): func = inspect.unwrap(func) if inspect.isfunction(func): code = func.__code__ return (code.co_filename, code.co_firstlineno) if isinstance(func, functools.partial): return _get_function_source(func.func) if isinstance(func, functools.partialmethod): return _get_function_source(func.func) return None def _format_callback_source(func, args): func_repr = _format_callback(func, args, None) source = _get_function_source(func) if source: func_repr += f' at {source[0]}:{source[1]}' return func_repr def _format_args_and_kwargs(args, kwargs): """Format function arguments and keyword arguments. Special case for a single parameter: ('hello',) is formatted as ('hello'). """ # use reprlib to limit the length of the output items = [] if args: items.extend(reprlib.repr(arg) for arg in args) if kwargs: items.extend(f'{k}={reprlib.repr(v)}' for k, v in kwargs.items()) return '({})'.format(', '.join(items)) def _format_callback(func, args, kwargs, suffix=''): if isinstance(func, functools.partial): suffix = _format_args_and_kwargs(args, kwargs) + suffix return _format_callback(func.func, func.args, func.keywords, suffix) if hasattr(func, '__qualname__') and func.__qualname__: func_repr = func.__qualname__ elif hasattr(func, '__name__') and func.__name__: func_repr = func.__name__ else: func_repr = repr(func) func_repr += _format_args_and_kwargs(args, kwargs) if suffix: func_repr += suffix return func_repr def extract_stack(f=None, limit=None): """Replacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. """ if f is None: f = sys._getframe().f_back if limit is None: # Limit the amount of work to a reasonable amount, as extract_stack() # can be called for each coroutine and future in debug mode. limit = constants.DEBUG_STACK_DEPTH stack = traceback.StackSummary.extract(traceback.walk_stack(f), limit=limit, lookup_lines=False) stack.reverse() return stack futures.py000064400000034004151706172570006627 0ustar00"""A Future class similar to the one in PEP 3148.""" __all__ = ( 'Future', 'wrap_future', 'isfuture', ) import concurrent.futures import contextvars import logging import sys from types import GenericAlias from . import base_futures from . import events from . import exceptions from . import format_helpers isfuture = base_futures.isfuture _PENDING = base_futures._PENDING _CANCELLED = base_futures._CANCELLED _FINISHED = base_futures._FINISHED STACK_DEBUG = logging.DEBUG - 1 # heavy-duty debugging class Future: """This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) """ # Class variables serving as defaults for instance variables. _state = _PENDING _result = None _exception = None _loop = None _source_traceback = None _cancel_message = None # A saved CancelledError for later chaining as an exception context. _cancelled_exc = None # This field is used for a dual purpose: # - Its presence is a marker to declare that a class implements # the Future protocol (i.e. is intended to be duck-type compatible). # The value must also be not-None, to enable a subclass to declare # that it is not compatible by setting this to None. # - It is set by __iter__() below so that Task._step() can tell # the difference between # `await Future()` or`yield from Future()` (correct) vs. # `yield Future()` (incorrect). _asyncio_future_blocking = False __log_traceback = False def __init__(self, *, loop=None): """Initialize the future. The optional event_loop argument allows explicitly setting the event loop object used by the future. If it's not provided, the future uses the default event loop. """ if loop is None: self._loop = events.get_event_loop() else: self._loop = loop self._callbacks = [] if self._loop.get_debug(): self._source_traceback = format_helpers.extract_stack( sys._getframe(1)) def __repr__(self): return base_futures._future_repr(self) def __del__(self): if not self.__log_traceback: # set_exception() was not called, or result() or exception() # has consumed the exception return exc = self._exception context = { 'message': f'{self.__class__.__name__} exception was never retrieved', 'exception': exc, 'future': self, } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) __class_getitem__ = classmethod(GenericAlias) @property def _log_traceback(self): return self.__log_traceback @_log_traceback.setter def _log_traceback(self, val): if val: raise ValueError('_log_traceback can only be set to False') self.__log_traceback = False def get_loop(self): """Return the event loop the Future is bound to.""" loop = self._loop if loop is None: raise RuntimeError("Future object is not initialized.") return loop def _make_cancelled_error(self): """Create the CancelledError to raise if the Future is cancelled. This should only be called once when handling a cancellation since it erases the saved context exception value. """ if self._cancelled_exc is not None: exc = self._cancelled_exc self._cancelled_exc = None return exc if self._cancel_message is None: exc = exceptions.CancelledError() else: exc = exceptions.CancelledError(self._cancel_message) exc.__context__ = self._cancelled_exc # Remove the reference since we don't need this anymore. self._cancelled_exc = None return exc def cancel(self, msg=None): """Cancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. """ self.__log_traceback = False if self._state != _PENDING: return False self._state = _CANCELLED self._cancel_message = msg self.__schedule_callbacks() return True def __schedule_callbacks(self): """Internal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. """ callbacks = self._callbacks[:] if not callbacks: return self._callbacks[:] = [] for callback, ctx in callbacks: self._loop.call_soon(callback, self, context=ctx) def cancelled(self): """Return True if the future was cancelled.""" return self._state == _CANCELLED # Don't implement running(); see http://bugs.python.org/issue18699 def done(self): """Return True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. """ return self._state != _PENDING def result(self): """Return the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. """ if self._state == _CANCELLED: raise self._make_cancelled_error() if self._state != _FINISHED: raise exceptions.InvalidStateError('Result is not ready.') self.__log_traceback = False if self._exception is not None: raise self._exception.with_traceback(self._exception_tb) return self._result def exception(self): """Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. """ if self._state == _CANCELLED: raise self._make_cancelled_error() if self._state != _FINISHED: raise exceptions.InvalidStateError('Exception is not set.') self.__log_traceback = False return self._exception def add_done_callback(self, fn, *, context=None): """Add a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. """ if self._state != _PENDING: self._loop.call_soon(fn, self, context=context) else: if context is None: context = contextvars.copy_context() self._callbacks.append((fn, context)) # New method not in PEP 3148. def remove_done_callback(self, fn): """Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. """ filtered_callbacks = [(f, ctx) for (f, ctx) in self._callbacks if f != fn] removed_count = len(self._callbacks) - len(filtered_callbacks) if removed_count: self._callbacks[:] = filtered_callbacks return removed_count # So-called internal methods (note: no set_running_or_notify_cancel()). def set_result(self, result): """Mark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. """ if self._state != _PENDING: raise exceptions.InvalidStateError(f'{self._state}: {self!r}') self._result = result self._state = _FINISHED self.__schedule_callbacks() def set_exception(self, exception): """Mark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. """ if self._state != _PENDING: raise exceptions.InvalidStateError(f'{self._state}: {self!r}') if isinstance(exception, type): exception = exception() if isinstance(exception, StopIteration): new_exc = RuntimeError("StopIteration interacts badly with " "generators and cannot be raised into a " "Future") new_exc.__cause__ = exception new_exc.__context__ = exception exception = new_exc self._exception = exception self._exception_tb = exception.__traceback__ self._state = _FINISHED self.__schedule_callbacks() self.__log_traceback = True def __await__(self): if not self.done(): self._asyncio_future_blocking = True yield self # This tells Task to wait for completion. if not self.done(): raise RuntimeError("await wasn't used with future") return self.result() # May raise too. __iter__ = __await__ # make compatible with 'yield from'. # Needed for testing purposes. _PyFuture = Future def _get_loop(fut): # Tries to call Future.get_loop() if it's available. # Otherwise fallbacks to using the old '_loop' property. try: get_loop = fut.get_loop except AttributeError: pass else: return get_loop() return fut._loop def _set_result_unless_cancelled(fut, result): """Helper setting the result only if the future was not cancelled.""" if fut.cancelled(): return fut.set_result(result) def _convert_future_exc(exc): exc_class = type(exc) if exc_class is concurrent.futures.CancelledError: return exceptions.CancelledError(*exc.args) elif exc_class is concurrent.futures.TimeoutError: return exceptions.TimeoutError(*exc.args) elif exc_class is concurrent.futures.InvalidStateError: return exceptions.InvalidStateError(*exc.args) else: return exc def _set_concurrent_future_state(concurrent, source): """Copy state from a future to a concurrent.futures.Future.""" assert source.done() if source.cancelled(): concurrent.cancel() if not concurrent.set_running_or_notify_cancel(): return exception = source.exception() if exception is not None: concurrent.set_exception(_convert_future_exc(exception)) else: result = source.result() concurrent.set_result(result) def _copy_future_state(source, dest): """Internal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. """ assert source.done() if dest.cancelled(): return assert not dest.done() if source.cancelled(): dest.cancel() else: exception = source.exception() if exception is not None: dest.set_exception(_convert_future_exc(exception)) else: result = source.result() dest.set_result(result) def _chain_future(source, destination): """Chain two futures so that when one completes, so does the other. The result (or exception) of source will be copied to destination. If destination is cancelled, source gets cancelled too. Compatible with both asyncio.Future and concurrent.futures.Future. """ if not isfuture(source) and not isinstance(source, concurrent.futures.Future): raise TypeError('A future is required for source argument') if not isfuture(destination) and not isinstance(destination, concurrent.futures.Future): raise TypeError('A future is required for destination argument') source_loop = _get_loop(source) if isfuture(source) else None dest_loop = _get_loop(destination) if isfuture(destination) else None def _set_state(future, other): if isfuture(future): _copy_future_state(other, future) else: _set_concurrent_future_state(future, other) def _call_check_cancel(destination): if destination.cancelled(): if source_loop is None or source_loop is dest_loop: source.cancel() else: source_loop.call_soon_threadsafe(source.cancel) def _call_set_state(source): if (destination.cancelled() and dest_loop is not None and dest_loop.is_closed()): return if dest_loop is None or dest_loop is source_loop: _set_state(destination, source) else: if dest_loop.is_closed(): return dest_loop.call_soon_threadsafe(_set_state, destination, source) destination.add_done_callback(_call_check_cancel) source.add_done_callback(_call_set_state) def wrap_future(future, *, loop=None): """Wrap concurrent.futures.Future object.""" if isfuture(future): return future assert isinstance(future, concurrent.futures.Future), \ f'concurrent.futures.Future is expected, got {future!r}' if loop is None: loop = events.get_event_loop() new_future = loop.create_future() _chain_future(future, new_future) return new_future try: import _asyncio except ImportError: pass else: # _CFuture is needed for tests. Future = _CFuture = _asyncio.Future locks.py000064400000045063151706172570006254 0ustar00"""Synchronization primitives.""" __all__ = ('Lock', 'Event', 'Condition', 'Semaphore', 'BoundedSemaphore', 'Barrier') import collections import enum from . import exceptions from . import mixins class _ContextManagerMixin: async def __aenter__(self): await self.acquire() # We have no use for the "as ..." clause in the with # statement for locks. return None async def __aexit__(self, exc_type, exc, tb): self.release() class Lock(_ContextManagerMixin, mixins._LoopBoundMixin): """Primitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'await'. Locks also support the asynchronous context management protocol. 'async with lock' statement should be used. Usage: lock = Lock() ... await lock.acquire() try: ... finally: lock.release() Context manager usage: lock = Lock() ... async with lock: ... Lock objects can be tested for locking state: if not lock.locked(): await lock.acquire() else: # lock is acquired ... """ def __init__(self): self._waiters = None self._locked = False def __repr__(self): res = super().__repr__() extra = 'locked' if self._locked else 'unlocked' if self._waiters: extra = f'{extra}, waiters:{len(self._waiters)}' return f'<{res[1:-1]} [{extra}]>' def locked(self): """Return True if lock is acquired.""" return self._locked async def acquire(self): """Acquire a lock. This method blocks until the lock is unlocked, then sets it to locked and returns True. """ if (not self._locked and (self._waiters is None or all(w.cancelled() for w in self._waiters))): self._locked = True return True if self._waiters is None: self._waiters = collections.deque() fut = self._get_loop().create_future() self._waiters.append(fut) # Finally block should be called before the CancelledError # handling as we don't want CancelledError to call # _wake_up_first() and attempt to wake up itself. try: try: await fut finally: self._waiters.remove(fut) except exceptions.CancelledError: if not self._locked: self._wake_up_first() raise self._locked = True return True def release(self): """Release a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. """ if self._locked: self._locked = False self._wake_up_first() else: raise RuntimeError('Lock is not acquired.') def _wake_up_first(self): """Wake up the first waiter if it isn't done.""" if not self._waiters: return try: fut = next(iter(self._waiters)) except StopIteration: return # .done() necessarily means that a waiter will wake up later on and # either take the lock, or, if it was cancelled and lock wasn't # taken already, will hit this again and wake up a new waiter. if not fut.done(): fut.set_result(True) class Event(mixins._LoopBoundMixin): """Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. """ def __init__(self): self._waiters = collections.deque() self._value = False def __repr__(self): res = super().__repr__() extra = 'set' if self._value else 'unset' if self._waiters: extra = f'{extra}, waiters:{len(self._waiters)}' return f'<{res[1:-1]} [{extra}]>' def is_set(self): """Return True if and only if the internal flag is true.""" return self._value def set(self): """Set the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all. """ if not self._value: self._value = True for fut in self._waiters: if not fut.done(): fut.set_result(True) def clear(self): """Reset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.""" self._value = False async def wait(self): """Block until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. """ if self._value: return True fut = self._get_loop().create_future() self._waiters.append(fut) try: await fut return True finally: self._waiters.remove(fut) class Condition(_ContextManagerMixin, mixins._LoopBoundMixin): """Asynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more coroutines to wait until they are notified by another coroutine. A new Lock object is created and used as the underlying lock. """ def __init__(self, lock=None): if lock is None: lock = Lock() self._lock = lock # Export the lock's locked(), acquire() and release() methods. self.locked = lock.locked self.acquire = lock.acquire self.release = lock.release self._waiters = collections.deque() def __repr__(self): res = super().__repr__() extra = 'locked' if self.locked() else 'unlocked' if self._waiters: extra = f'{extra}, waiters:{len(self._waiters)}' return f'<{res[1:-1]} [{extra}]>' async def wait(self): """Wait until notified. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another coroutine. Once awakened, it re-acquires the lock and returns True. """ if not self.locked(): raise RuntimeError('cannot wait on un-acquired lock') self.release() try: fut = self._get_loop().create_future() self._waiters.append(fut) try: await fut return True finally: self._waiters.remove(fut) finally: # Must reacquire lock even if wait is cancelled cancelled = False while True: try: await self.acquire() break except exceptions.CancelledError: cancelled = True if cancelled: raise exceptions.CancelledError async def wait_for(self, predicate): """Wait until a predicate becomes true. The predicate should be a callable which result will be interpreted as a boolean value. The final predicate value is the return value. """ result = predicate() while not result: await self.wait() result = predicate() return result def notify(self, n=1): """By default, wake up one coroutine waiting on this condition, if any. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the coroutines waiting for the condition variable; it is a no-op if no coroutines are waiting. Note: an awakened coroutine does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. """ if not self.locked(): raise RuntimeError('cannot notify on un-acquired lock') idx = 0 for fut in self._waiters: if idx >= n: break if not fut.done(): idx += 1 fut.set_result(False) def notify_all(self): """Wake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. """ self.notify(len(self._waiters)) class Semaphore(_ContextManagerMixin, mixins._LoopBoundMixin): """A Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. """ def __init__(self, value=1): if value < 0: raise ValueError("Semaphore initial value must be >= 0") self._waiters = None self._value = value def __repr__(self): res = super().__repr__() extra = 'locked' if self.locked() else f'unlocked, value:{self._value}' if self._waiters: extra = f'{extra}, waiters:{len(self._waiters)}' return f'<{res[1:-1]} [{extra}]>' def locked(self): """Returns True if semaphore cannot be acquired immediately.""" return self._value == 0 or ( any(not w.cancelled() for w in (self._waiters or ()))) async def acquire(self): """Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. """ if not self.locked(): self._value -= 1 return True if self._waiters is None: self._waiters = collections.deque() fut = self._get_loop().create_future() self._waiters.append(fut) # Finally block should be called before the CancelledError # handling as we don't want CancelledError to call # _wake_up_first() and attempt to wake up itself. try: try: await fut finally: self._waiters.remove(fut) except exceptions.CancelledError: if not fut.cancelled(): self._value += 1 self._wake_up_next() raise if self._value > 0: self._wake_up_next() return True def release(self): """Release a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. """ self._value += 1 self._wake_up_next() def _wake_up_next(self): """Wake up the first waiter that isn't done.""" if not self._waiters: return for fut in self._waiters: if not fut.done(): self._value -= 1 fut.set_result(True) return class BoundedSemaphore(Semaphore): """A bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. """ def __init__(self, value=1): self._bound_value = value super().__init__(value) def release(self): if self._value >= self._bound_value: raise ValueError('BoundedSemaphore released too many times') super().release() class _BarrierState(enum.Enum): FILLING = 'filling' DRAINING = 'draining' RESETTING = 'resetting' BROKEN = 'broken' class Barrier(mixins._LoopBoundMixin): """Asyncio equivalent to threading.Barrier Implements a Barrier primitive. Useful for synchronizing a fixed number of tasks at known synchronization points. Tasks block on 'wait()' and are simultaneously awoken once they have all made their call. """ def __init__(self, parties): """Create a barrier, initialised to 'parties' tasks.""" if parties < 1: raise ValueError('parties must be >= 1') self._cond = Condition() # notify all tasks when state changes self._parties = parties self._state = _BarrierState.FILLING self._count = 0 # count tasks in Barrier def __repr__(self): res = super().__repr__() extra = f'{self._state.value}' if not self.broken: extra += f', waiters:{self.n_waiting}/{self.parties}' return f'<{res[1:-1]} [{extra}]>' async def __aenter__(self): # wait for the barrier reaches the parties number # when start draining release and return index of waited task return await self.wait() async def __aexit__(self, *args): pass async def wait(self): """Wait for the barrier. When the specified number of tasks have started waiting, they are all simultaneously awoken. Returns an unique and individual index number from 0 to 'parties-1'. """ async with self._cond: await self._block() # Block while the barrier drains or resets. try: index = self._count self._count += 1 if index + 1 == self._parties: # We release the barrier await self._release() else: await self._wait() return index finally: self._count -= 1 # Wake up any tasks waiting for barrier to drain. self._exit() async def _block(self): # Block until the barrier is ready for us, # or raise an exception if it is broken. # # It is draining or resetting, wait until done # unless a CancelledError occurs await self._cond.wait_for( lambda: self._state not in ( _BarrierState.DRAINING, _BarrierState.RESETTING ) ) # see if the barrier is in a broken state if self._state is _BarrierState.BROKEN: raise exceptions.BrokenBarrierError("Barrier aborted") async def _release(self): # Release the tasks waiting in the barrier. # Enter draining state. # Next waiting tasks will be blocked until the end of draining. self._state = _BarrierState.DRAINING self._cond.notify_all() async def _wait(self): # Wait in the barrier until we are released. Raise an exception # if the barrier is reset or broken. # wait for end of filling # unless a CancelledError occurs await self._cond.wait_for(lambda: self._state is not _BarrierState.FILLING) if self._state in (_BarrierState.BROKEN, _BarrierState.RESETTING): raise exceptions.BrokenBarrierError("Abort or reset of barrier") def _exit(self): # If we are the last tasks to exit the barrier, signal any tasks # waiting for the barrier to drain. if self._count == 0: if self._state in (_BarrierState.RESETTING, _BarrierState.DRAINING): self._state = _BarrierState.FILLING self._cond.notify_all() async def reset(self): """Reset the barrier to the initial state. Any tasks currently waiting will get the BrokenBarrier exception raised. """ async with self._cond: if self._count > 0: if self._state is not _BarrierState.RESETTING: #reset the barrier, waking up tasks self._state = _BarrierState.RESETTING else: self._state = _BarrierState.FILLING self._cond.notify_all() async def abort(self): """Place the barrier into a 'broken' state. Useful in case of error. Any currently waiting tasks and tasks attempting to 'wait()' will have BrokenBarrierError raised. """ async with self._cond: self._state = _BarrierState.BROKEN self._cond.notify_all() @property def parties(self): """Return the number of tasks required to trip the barrier.""" return self._parties @property def n_waiting(self): """Return the number of tasks currently waiting at the barrier.""" if self._state is _BarrierState.FILLING: return self._count return 0 @property def broken(self): """Return True if the barrier is in a broken state.""" return self._state is _BarrierState.BROKEN log.py000064400000000174151706172570005714 0ustar00"""Logging configuration.""" import logging # Name the logger after the package. logger = logging.getLogger(__package__) mixins.py000064400000000741151706172570006442 0ustar00"""Event loop mixins.""" import threading from . import events _global_lock = threading.Lock() class _LoopBoundMixin: _loop = None def _get_loop(self): loop = events._get_running_loop() if self._loop is None: with _global_lock: if self._loop is None: self._loop = loop if loop is not self._loop: raise RuntimeError(f'{self!r} is bound to a different event loop') return loop proactor_events.py000064400000101334151706172570010350 0ustar00"""Event loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. """ __all__ = 'BaseProactorEventLoop', import io import os import socket import warnings import signal import threading import collections from . import base_events from . import constants from . import futures from . import exceptions from . import protocols from . import sslproto from . import transports from . import trsock from .log import logger def _set_socket_extra(transport, sock): transport._extra['socket'] = trsock.TransportSocket(sock) try: transport._extra['sockname'] = sock.getsockname() except socket.error: if transport._loop.get_debug(): logger.warning( "getsockname() failed on %r", sock, exc_info=True) if 'peername' not in transport._extra: try: transport._extra['peername'] = sock.getpeername() except socket.error: # UDP sockets may not have a peer name transport._extra['peername'] = None class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport): """Base class for pipe and socket transports.""" def __init__(self, loop, sock, protocol, waiter=None, extra=None, server=None): super().__init__(extra, loop) self._set_extra(sock) self._sock = sock self.set_protocol(protocol) self._server = server self._buffer = None # None or bytearray. self._read_fut = None self._write_fut = None self._pending_write = 0 self._conn_lost = 0 self._closing = False # Set when close() called. self._called_connection_lost = False self._eof_written = False if self._server is not None: self._server._attach() self._loop.call_soon(self._protocol.connection_made, self) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) def __repr__(self): info = [self.__class__.__name__] if self._sock is None: info.append('closed') elif self._closing: info.append('closing') if self._sock is not None: info.append(f'fd={self._sock.fileno()}') if self._read_fut is not None: info.append(f'read={self._read_fut!r}') if self._write_fut is not None: info.append(f'write={self._write_fut!r}') if self._buffer: info.append(f'write_bufsize={len(self._buffer)}') if self._eof_written: info.append('EOF written') return '<{}>'.format(' '.join(info)) def _set_extra(self, sock): self._extra['pipe'] = sock def set_protocol(self, protocol): self._protocol = protocol def get_protocol(self): return self._protocol def is_closing(self): return self._closing def close(self): if self._closing: return self._closing = True self._conn_lost += 1 if not self._buffer and self._write_fut is None: self._loop.call_soon(self._call_connection_lost, None) if self._read_fut is not None: self._read_fut.cancel() self._read_fut = None def __del__(self, _warn=warnings.warn): if self._sock is not None: _warn(f"unclosed transport {self!r}", ResourceWarning, source=self) self._sock.close() def _fatal_error(self, exc, message='Fatal error on pipe transport'): try: if isinstance(exc, OSError): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) finally: self._force_close(exc) def _force_close(self, exc): if self._empty_waiter is not None and not self._empty_waiter.done(): if exc is None: self._empty_waiter.set_result(None) else: self._empty_waiter.set_exception(exc) if self._closing and self._called_connection_lost: return self._closing = True self._conn_lost += 1 if self._write_fut: self._write_fut.cancel() self._write_fut = None if self._read_fut: self._read_fut.cancel() self._read_fut = None self._pending_write = 0 self._buffer = None self._loop.call_soon(self._call_connection_lost, exc) def _call_connection_lost(self, exc): if self._called_connection_lost: return try: self._protocol.connection_lost(exc) finally: # XXX If there is a pending overlapped read on the other # end then it may fail with ERROR_NETNAME_DELETED if we # just close our end. First calling shutdown() seems to # cure it, but maybe using DisconnectEx() would be better. if hasattr(self._sock, 'shutdown') and self._sock.fileno() != -1: self._sock.shutdown(socket.SHUT_RDWR) self._sock.close() self._sock = None server = self._server if server is not None: server._detach() self._server = None self._called_connection_lost = True def get_write_buffer_size(self): size = self._pending_write if self._buffer is not None: size += len(self._buffer) return size class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTransport): """Transport for read pipes.""" def __init__(self, loop, sock, protocol, waiter=None, extra=None, server=None, buffer_size=65536): self._pending_data_length = -1 self._paused = True super().__init__(loop, sock, protocol, waiter, extra, server) self._data = bytearray(buffer_size) self._loop.call_soon(self._loop_reading) self._paused = False def is_reading(self): return not self._paused and not self._closing def pause_reading(self): if self._closing or self._paused: return self._paused = True # bpo-33694: Don't cancel self._read_fut because cancelling an # overlapped WSASend() loss silently data with the current proactor # implementation. # # If CancelIoEx() fails with ERROR_NOT_FOUND, it means that WSASend() # completed (even if HasOverlappedIoCompleted() returns 0), but # Overlapped.cancel() currently silently ignores the ERROR_NOT_FOUND # error. Once the overlapped is ignored, the IOCP loop will ignores the # completion I/O event and so not read the result of the overlapped # WSARecv(). if self._loop.get_debug(): logger.debug("%r pauses reading", self) def resume_reading(self): if self._closing or not self._paused: return self._paused = False if self._read_fut is None: self._loop.call_soon(self._loop_reading, None) length = self._pending_data_length self._pending_data_length = -1 if length > -1: # Call the protocol method after calling _loop_reading(), # since the protocol can decide to pause reading again. self._loop.call_soon(self._data_received, self._data[:length], length) if self._loop.get_debug(): logger.debug("%r resumes reading", self) def _eof_received(self): if self._loop.get_debug(): logger.debug("%r received EOF", self) try: keep_open = self._protocol.eof_received() except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error( exc, 'Fatal error: protocol.eof_received() call failed.') return if not keep_open: self.close() def _data_received(self, data, length): if self._paused: # Don't call any protocol method while reading is paused. # The protocol will be called on resume_reading(). assert self._pending_data_length == -1 self._pending_data_length = length return if length == 0: self._eof_received() return if isinstance(self._protocol, protocols.BufferedProtocol): try: protocols._feed_data_to_buffered_proto(self._protocol, data) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error(exc, 'Fatal error: protocol.buffer_updated() ' 'call failed.') return else: self._protocol.data_received(data) def _loop_reading(self, fut=None): length = -1 data = None try: if fut is not None: assert self._read_fut is fut or (self._read_fut is None and self._closing) self._read_fut = None if fut.done(): # deliver data later in "finally" clause length = fut.result() if length == 0: # we got end-of-file so no need to reschedule a new read return # It's a new slice so make it immutable so protocols upstream don't have problems data = bytes(memoryview(self._data)[:length]) else: # the future will be replaced by next proactor.recv call fut.cancel() if self._closing: # since close() has been called we ignore any read data return # bpo-33694: buffer_updated() has currently no fast path because of # a data loss issue caused by overlapped WSASend() cancellation. if not self._paused: # reschedule a new read self._read_fut = self._loop._proactor.recv_into(self._sock, self._data) except ConnectionAbortedError as exc: if not self._closing: self._fatal_error(exc, 'Fatal read error on pipe transport') elif self._loop.get_debug(): logger.debug("Read error on pipe transport while closing", exc_info=True) except ConnectionResetError as exc: self._force_close(exc) except OSError as exc: self._fatal_error(exc, 'Fatal read error on pipe transport') except exceptions.CancelledError: if not self._closing: raise else: if not self._paused: self._read_fut.add_done_callback(self._loop_reading) finally: if length > -1: self._data_received(data, length) class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport): """Transport for write pipes.""" _start_tls_compatible = True def __init__(self, *args, **kw): super().__init__(*args, **kw) self._empty_waiter = None def write(self, data): if not isinstance(data, (bytes, bytearray, memoryview)): raise TypeError( f"data argument must be a bytes-like object, " f"not {type(data).__name__}") if self._eof_written: raise RuntimeError('write_eof() already called') if self._empty_waiter is not None: raise RuntimeError('unable to write; sendfile is in progress') if not data: return if self._conn_lost: if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('socket.send() raised exception.') self._conn_lost += 1 return # Observable states: # 1. IDLE: _write_fut and _buffer both None # 2. WRITING: _write_fut set; _buffer None # 3. BACKED UP: _write_fut set; _buffer a bytearray # We always copy the data, so the caller can't modify it # while we're still waiting for the I/O to happen. if self._write_fut is None: # IDLE -> WRITING assert self._buffer is None # Pass a copy, except if it's already immutable. self._loop_writing(data=bytes(data)) elif not self._buffer: # WRITING -> BACKED UP # Make a mutable copy which we can extend. self._buffer = bytearray(data) self._maybe_pause_protocol() else: # BACKED UP # Append to buffer (also copies). self._buffer.extend(data) self._maybe_pause_protocol() def _loop_writing(self, f=None, data=None): try: if f is not None and self._write_fut is None and self._closing: # XXX most likely self._force_close() has been called, and # it has set self._write_fut to None. return assert f is self._write_fut self._write_fut = None self._pending_write = 0 if f: f.result() if data is None: data = self._buffer self._buffer = None if not data: if self._closing: self._loop.call_soon(self._call_connection_lost, None) if self._eof_written: self._sock.shutdown(socket.SHUT_WR) # Now that we've reduced the buffer size, tell the # protocol to resume writing if it was paused. Note that # we do this last since the callback is called immediately # and it may add more data to the buffer (even causing the # protocol to be paused again). self._maybe_resume_protocol() else: self._write_fut = self._loop._proactor.send(self._sock, data) if not self._write_fut.done(): assert self._pending_write == 0 self._pending_write = len(data) self._write_fut.add_done_callback(self._loop_writing) self._maybe_pause_protocol() else: self._write_fut.add_done_callback(self._loop_writing) if self._empty_waiter is not None and self._write_fut is None: self._empty_waiter.set_result(None) except ConnectionResetError as exc: self._force_close(exc) except OSError as exc: self._fatal_error(exc, 'Fatal write error on pipe transport') def can_write_eof(self): return True def write_eof(self): self.close() def abort(self): self._force_close(None) def _make_empty_waiter(self): if self._empty_waiter is not None: raise RuntimeError("Empty waiter is already set") self._empty_waiter = self._loop.create_future() if self._write_fut is None: self._empty_waiter.set_result(None) return self._empty_waiter def _reset_empty_waiter(self): self._empty_waiter = None class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): def __init__(self, *args, **kw): super().__init__(*args, **kw) self._read_fut = self._loop._proactor.recv(self._sock, 16) self._read_fut.add_done_callback(self._pipe_closed) def _pipe_closed(self, fut): if fut.cancelled(): # the transport has been closed return assert fut.result() == b'' if self._closing: assert self._read_fut is None return assert fut is self._read_fut, (fut, self._read_fut) self._read_fut = None if self._write_fut is not None: self._force_close(BrokenPipeError()) else: self.close() class _ProactorDatagramTransport(_ProactorBasePipeTransport, transports.DatagramTransport): max_size = 256 * 1024 def __init__(self, loop, sock, protocol, address=None, waiter=None, extra=None): self._address = address self._empty_waiter = None self._buffer_size = 0 # We don't need to call _protocol.connection_made() since our base # constructor does it for us. super().__init__(loop, sock, protocol, waiter=waiter, extra=extra) # The base constructor sets _buffer = None, so we set it here self._buffer = collections.deque() self._loop.call_soon(self._loop_reading) def _set_extra(self, sock): _set_socket_extra(self, sock) def get_write_buffer_size(self): return self._buffer_size def abort(self): self._force_close(None) def sendto(self, data, addr=None): if not isinstance(data, (bytes, bytearray, memoryview)): raise TypeError('data argument must be bytes-like object (%r)', type(data)) if not data: return if self._address is not None and addr not in (None, self._address): raise ValueError( f'Invalid address: must be None or {self._address}') if self._conn_lost and self._address: if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('socket.sendto() raised exception.') self._conn_lost += 1 return # Ensure that what we buffer is immutable. self._buffer.append((bytes(data), addr)) self._buffer_size += len(data) if self._write_fut is None: # No current write operations are active, kick one off self._loop_writing() # else: A write operation is already kicked off self._maybe_pause_protocol() def _loop_writing(self, fut=None): try: if self._conn_lost: return assert fut is self._write_fut self._write_fut = None if fut: # We are in a _loop_writing() done callback, get the result fut.result() if not self._buffer or (self._conn_lost and self._address): # The connection has been closed if self._closing: self._loop.call_soon(self._call_connection_lost, None) return data, addr = self._buffer.popleft() self._buffer_size -= len(data) if self._address is not None: self._write_fut = self._loop._proactor.send(self._sock, data) else: self._write_fut = self._loop._proactor.sendto(self._sock, data, addr=addr) except OSError as exc: self._protocol.error_received(exc) except Exception as exc: self._fatal_error(exc, 'Fatal write error on datagram transport') else: self._write_fut.add_done_callback(self._loop_writing) self._maybe_resume_protocol() def _loop_reading(self, fut=None): data = None try: if self._conn_lost: return assert self._read_fut is fut or (self._read_fut is None and self._closing) self._read_fut = None if fut is not None: res = fut.result() if self._closing: # since close() has been called we ignore any read data data = None return if self._address is not None: data, addr = res, self._address else: data, addr = res if self._conn_lost: return if self._address is not None: self._read_fut = self._loop._proactor.recv(self._sock, self.max_size) else: self._read_fut = self._loop._proactor.recvfrom(self._sock, self.max_size) except OSError as exc: self._protocol.error_received(exc) except exceptions.CancelledError: if not self._closing: raise else: if self._read_fut is not None: self._read_fut.add_done_callback(self._loop_reading) finally: if data: self._protocol.datagram_received(data, addr) class _ProactorDuplexPipeTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): """Transport for duplex pipes.""" def can_write_eof(self): return False def write_eof(self): raise NotImplementedError class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): """Transport for connected sockets.""" _sendfile_compatible = constants._SendfileMode.TRY_NATIVE def __init__(self, loop, sock, protocol, waiter=None, extra=None, server=None): super().__init__(loop, sock, protocol, waiter, extra, server) base_events._set_nodelay(sock) def _set_extra(self, sock): _set_socket_extra(self, sock) def can_write_eof(self): return True def write_eof(self): if self._closing or self._eof_written: return self._eof_written = True if self._write_fut is None: self._sock.shutdown(socket.SHUT_WR) class BaseProactorEventLoop(base_events.BaseEventLoop): def __init__(self, proactor): super().__init__() logger.debug('Using proactor: %s', proactor.__class__.__name__) self._proactor = proactor self._selector = proactor # convenient alias self._self_reading_future = None self._accept_futures = {} # socket file descriptor => Future proactor.set_loop(self) self._make_self_pipe() if threading.current_thread() is threading.main_thread(): # wakeup fd can only be installed to a file descriptor from the main thread signal.set_wakeup_fd(self._csock.fileno()) def _make_socket_transport(self, sock, protocol, waiter=None, extra=None, server=None): return _ProactorSocketTransport(self, sock, protocol, waiter, extra, server) def _make_ssl_transport( self, rawsock, protocol, sslcontext, waiter=None, *, server_side=False, server_hostname=None, extra=None, server=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): ssl_protocol = sslproto.SSLProtocol( self, protocol, sslcontext, waiter, server_side, server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) _ProactorSocketTransport(self, rawsock, ssl_protocol, extra=extra, server=server) return ssl_protocol._app_transport def _make_datagram_transport(self, sock, protocol, address=None, waiter=None, extra=None): return _ProactorDatagramTransport(self, sock, protocol, address, waiter, extra) def _make_duplex_pipe_transport(self, sock, protocol, waiter=None, extra=None): return _ProactorDuplexPipeTransport(self, sock, protocol, waiter, extra) def _make_read_pipe_transport(self, sock, protocol, waiter=None, extra=None): return _ProactorReadPipeTransport(self, sock, protocol, waiter, extra) def _make_write_pipe_transport(self, sock, protocol, waiter=None, extra=None): # We want connection_lost() to be called when other end closes return _ProactorWritePipeTransport(self, sock, protocol, waiter, extra) def close(self): if self.is_running(): raise RuntimeError("Cannot close a running event loop") if self.is_closed(): return if threading.current_thread() is threading.main_thread(): signal.set_wakeup_fd(-1) # Call these methods before closing the event loop (before calling # BaseEventLoop.close), because they can schedule callbacks with # call_soon(), which is forbidden when the event loop is closed. self._stop_accept_futures() self._close_self_pipe() self._proactor.close() self._proactor = None self._selector = None # Close the event loop super().close() async def sock_recv(self, sock, n): return await self._proactor.recv(sock, n) async def sock_recv_into(self, sock, buf): return await self._proactor.recv_into(sock, buf) async def sock_recvfrom(self, sock, bufsize): return await self._proactor.recvfrom(sock, bufsize) async def sock_recvfrom_into(self, sock, buf, nbytes=0): if not nbytes: nbytes = len(buf) return await self._proactor.recvfrom_into(sock, buf, nbytes) async def sock_sendall(self, sock, data): return await self._proactor.send(sock, data) async def sock_sendto(self, sock, data, address): return await self._proactor.sendto(sock, data, 0, address) async def sock_connect(self, sock, address): if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") return await self._proactor.connect(sock, address) async def sock_accept(self, sock): return await self._proactor.accept(sock) async def _sock_sendfile_native(self, sock, file, offset, count): try: fileno = file.fileno() except (AttributeError, io.UnsupportedOperation) as err: raise exceptions.SendfileNotAvailableError("not a regular file") try: fsize = os.fstat(fileno).st_size except OSError: raise exceptions.SendfileNotAvailableError("not a regular file") blocksize = count if count else fsize if not blocksize: return 0 # empty file blocksize = min(blocksize, 0xffff_ffff) end_pos = min(offset + count, fsize) if count else fsize offset = min(offset, fsize) total_sent = 0 try: while True: blocksize = min(end_pos - offset, blocksize) if blocksize <= 0: return total_sent await self._proactor.sendfile(sock, file, offset, blocksize) offset += blocksize total_sent += blocksize finally: if total_sent > 0: file.seek(offset) async def _sendfile_native(self, transp, file, offset, count): resume_reading = transp.is_reading() transp.pause_reading() await transp._make_empty_waiter() try: return await self.sock_sendfile(transp._sock, file, offset, count, fallback=False) finally: transp._reset_empty_waiter() if resume_reading: transp.resume_reading() def _close_self_pipe(self): if self._self_reading_future is not None: self._self_reading_future.cancel() self._self_reading_future = None self._ssock.close() self._ssock = None self._csock.close() self._csock = None self._internal_fds -= 1 def _make_self_pipe(self): # A self-socket, really. :-) self._ssock, self._csock = socket.socketpair() self._ssock.setblocking(False) self._csock.setblocking(False) self._internal_fds += 1 def _loop_self_reading(self, f=None): try: if f is not None: f.result() # may raise if self._self_reading_future is not f: # When we scheduled this Future, we assigned it to # _self_reading_future. If it's not there now, something has # tried to cancel the loop while this callback was still in the # queue (see windows_events.ProactorEventLoop.run_forever). In # that case stop here instead of continuing to schedule a new # iteration. return f = self._proactor.recv(self._ssock, 4096) except exceptions.CancelledError: # _close_self_pipe() has been called, stop waiting for data return except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self.call_exception_handler({ 'message': 'Error on reading from the event loop self pipe', 'exception': exc, 'loop': self, }) else: self._self_reading_future = f f.add_done_callback(self._loop_self_reading) def _write_to_self(self): # This may be called from a different thread, possibly after # _close_self_pipe() has been called or even while it is # running. Guard for self._csock being None or closed. When # a socket is closed, send() raises OSError (with errno set to # EBADF, but let's not rely on the exact error code). csock = self._csock if csock is None: return try: csock.send(b'\0') except OSError: if self._debug: logger.debug("Fail to write a null byte into the " "self-pipe socket", exc_info=True) def _start_serving(self, protocol_factory, sock, sslcontext=None, server=None, backlog=100, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): def loop(f=None): try: if f is not None: conn, addr = f.result() if self._debug: logger.debug("%r got a new connection from %r: %r", server, addr, conn) protocol = protocol_factory() if sslcontext is not None: self._make_ssl_transport( conn, protocol, sslcontext, server_side=True, extra={'peername': addr}, server=server, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) else: self._make_socket_transport( conn, protocol, extra={'peername': addr}, server=server) if self.is_closed(): return f = self._proactor.accept(sock) except OSError as exc: if sock.fileno() != -1: self.call_exception_handler({ 'message': 'Accept failed on a socket', 'exception': exc, 'socket': trsock.TransportSocket(sock), }) sock.close() elif self._debug: logger.debug("Accept failed on socket %r", sock, exc_info=True) except exceptions.CancelledError: sock.close() else: self._accept_futures[sock.fileno()] = f f.add_done_callback(loop) self.call_soon(loop) def _process_events(self, event_list): # Events are processed in the IocpProactor._poll() method pass def _stop_accept_futures(self): for future in self._accept_futures.values(): future.cancel() self._accept_futures.clear() def _stop_serving(self, sock): future = self._accept_futures.pop(sock.fileno(), None) if future: future.cancel() self._proactor._stop_serving(sock) sock.close() protocols.py000064400000015455151706172570007167 0ustar00"""Abstract Protocol base classes.""" __all__ = ( 'BaseProtocol', 'Protocol', 'DatagramProtocol', 'SubprocessProtocol', 'BufferedProtocol', ) class BaseProtocol: """Common base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe """ __slots__ = () def connection_made(self, transport): """Called when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. """ def connection_lost(self, exc): """Called when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). """ def pause_writing(self): """Called when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). """ def resume_writing(self): """Called when the transport's buffer drains below the low-water mark. See pause_writing() for details. """ class Protocol(BaseProtocol): """Interface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() """ __slots__ = () def data_received(self, data): """Called when some data is received. The argument is a bytes object. """ def eof_received(self): """Called when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. """ class BufferedProtocol(BaseProtocol): """Interface for stream protocol with manual buffer control. Event methods, such as `create_server` and `create_connection`, accept factories that return protocols that implement this interface. The idea of BufferedProtocol is that it allows to manually allocate and control the receive buffer. Event loops can then use the buffer provided by the protocol to avoid unnecessary data copies. This can result in noticeable performance improvement for protocols that receive big amounts of data. Sophisticated protocols can allocate the buffer only once at creation time. State machine of calls: start -> CM [-> GB [-> BU?]]* [-> ER?] -> CL -> end * CM: connection_made() * GB: get_buffer() * BU: buffer_updated() * ER: eof_received() * CL: connection_lost() """ __slots__ = () def get_buffer(self, sizehint): """Called to allocate a new receive buffer. *sizehint* is a recommended minimal size for the returned buffer. When set to -1, the buffer size can be arbitrary. Must return an object that implements the :ref:`buffer protocol <bufferobjects>`. It is an error to return a zero-sized buffer. """ def buffer_updated(self, nbytes): """Called when the buffer was updated with the received data. *nbytes* is the total number of bytes that were written to the buffer. """ def eof_received(self): """Called when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. """ class DatagramProtocol(BaseProtocol): """Interface for datagram protocol.""" __slots__ = () def datagram_received(self, data, addr): """Called when some datagram is received.""" def error_received(self, exc): """Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) """ class SubprocessProtocol(BaseProtocol): """Interface for protocol for subprocess calls.""" __slots__ = () def pipe_data_received(self, fd, data): """Called when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. """ def pipe_connection_lost(self, fd, exc): """Called when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. """ def process_exited(self): """Called when subprocess has exited.""" def _feed_data_to_buffered_proto(proto, data): data_len = len(data) while data_len: buf = proto.get_buffer(data_len) buf_len = len(buf) if not buf_len: raise RuntimeError('get_buffer() returned an empty buffer') if buf_len >= data_len: buf[:data_len] = data proto.buffer_updated(data_len) return else: buf[:buf_len] = data[:buf_len] proto.buffer_updated(buf_len) data = data[buf_len:] data_len = len(data) queues.py000064400000017446151706172570006454 0ustar00__all__ = ('Queue', 'PriorityQueue', 'LifoQueue', 'QueueFull', 'QueueEmpty') import collections import heapq from types import GenericAlias from . import locks from . import mixins class QueueEmpty(Exception): """Raised when Queue.get_nowait() is called on an empty Queue.""" pass class QueueFull(Exception): """Raised when the Queue.put_nowait() method is called on a full Queue.""" pass class Queue(mixins._LoopBoundMixin): """A queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "await put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. """ def __init__(self, maxsize=0): self._maxsize = maxsize # Futures. self._getters = collections.deque() # Futures. self._putters = collections.deque() self._unfinished_tasks = 0 self._finished = locks.Event() self._finished.set() self._init(maxsize) # These three are overridable in subclasses. def _init(self, maxsize): self._queue = collections.deque() def _get(self): return self._queue.popleft() def _put(self, item): self._queue.append(item) # End of the overridable methods. def _wakeup_next(self, waiters): # Wake up the next waiter (if any) that isn't cancelled. while waiters: waiter = waiters.popleft() if not waiter.done(): waiter.set_result(None) break def __repr__(self): return f'<{type(self).__name__} at {id(self):#x} {self._format()}>' def __str__(self): return f'<{type(self).__name__} {self._format()}>' __class_getitem__ = classmethod(GenericAlias) def _format(self): result = f'maxsize={self._maxsize!r}' if getattr(self, '_queue', None): result += f' _queue={list(self._queue)!r}' if self._getters: result += f' _getters[{len(self._getters)}]' if self._putters: result += f' _putters[{len(self._putters)}]' if self._unfinished_tasks: result += f' tasks={self._unfinished_tasks}' return result def qsize(self): """Number of items in the queue.""" return len(self._queue) @property def maxsize(self): """Number of items allowed in the queue.""" return self._maxsize def empty(self): """Return True if the queue is empty, False otherwise.""" return not self._queue def full(self): """Return True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. """ if self._maxsize <= 0: return False else: return self.qsize() >= self._maxsize async def put(self, item): """Put an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. """ while self.full(): putter = self._get_loop().create_future() self._putters.append(putter) try: await putter except: putter.cancel() # Just in case putter is not done yet. try: # Clean self._putters from canceled putters. self._putters.remove(putter) except ValueError: # The putter could be removed from self._putters by a # previous get_nowait call. pass if not self.full() and not putter.cancelled(): # We were woken up by get_nowait(), but can't take # the call. Wake up the next in line. self._wakeup_next(self._putters) raise return self.put_nowait(item) def put_nowait(self, item): """Put an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. """ if self.full(): raise QueueFull self._put(item) self._unfinished_tasks += 1 self._finished.clear() self._wakeup_next(self._getters) async def get(self): """Remove and return an item from the queue. If queue is empty, wait until an item is available. """ while self.empty(): getter = self._get_loop().create_future() self._getters.append(getter) try: await getter except: getter.cancel() # Just in case getter is not done yet. try: # Clean self._getters from canceled getters. self._getters.remove(getter) except ValueError: # The getter could be removed from self._getters by a # previous put_nowait call. pass if not self.empty() and not getter.cancelled(): # We were woken up by put_nowait(), but can't take # the call. Wake up the next in line. self._wakeup_next(self._getters) raise return self.get_nowait() def get_nowait(self): """Remove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. """ if self.empty(): raise QueueEmpty item = self._get() self._wakeup_next(self._putters) return item def task_done(self): """Indicate that a formerly enqueued task is complete. Used by queue consumers. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue). Raises ValueError if called more times than there were items placed in the queue. """ if self._unfinished_tasks <= 0: raise ValueError('task_done() called too many times') self._unfinished_tasks -= 1 if self._unfinished_tasks == 0: self._finished.set() async def join(self): """Block until all items in the queue have been gotten and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer calls task_done() to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks. """ if self._unfinished_tasks > 0: await self._finished.wait() class PriorityQueue(Queue): """A subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). """ def _init(self, maxsize): self._queue = [] def _put(self, item, heappush=heapq.heappush): heappush(self._queue, item) def _get(self, heappop=heapq.heappop): return heappop(self._queue) class LifoQueue(Queue): """A subclass of Queue that retrieves most recently added entries first.""" def _init(self, maxsize): self._queue = [] def _put(self, item): self._queue.append(item) def _get(self): return self._queue.pop() runners.py000064400000016076151706172570006637 0ustar00__all__ = ('Runner', 'run') import contextvars import enum import functools import threading import signal from . import coroutines from . import events from . import exceptions from . import tasks from . import constants class _State(enum.Enum): CREATED = "created" INITIALIZED = "initialized" CLOSED = "closed" class Runner: """A context manager that controls event loop life cycle. The context manager always creates a new event loop, allows to run async functions inside it, and properly finalizes the loop at the context manager exit. If debug is True, the event loop will be run in debug mode. If loop_factory is passed, it is used for new event loop creation. asyncio.run(main(), debug=True) is a shortcut for with asyncio.Runner(debug=True) as runner: runner.run(main()) The run() method can be called multiple times within the runner's context. This can be useful for interactive console (e.g. IPython), unittest runners, console tools, -- everywhere when async code is called from existing sync framework and where the preferred single asyncio.run() call doesn't work. """ # Note: the class is final, it is not intended for inheritance. def __init__(self, *, debug=None, loop_factory=None): self._state = _State.CREATED self._debug = debug self._loop_factory = loop_factory self._loop = None self._context = None self._interrupt_count = 0 self._set_event_loop = False def __enter__(self): self._lazy_init() return self def __exit__(self, exc_type, exc_val, exc_tb): self.close() def close(self): """Shutdown and close event loop.""" if self._state is not _State.INITIALIZED: return try: loop = self._loop _cancel_all_tasks(loop) loop.run_until_complete(loop.shutdown_asyncgens()) loop.run_until_complete( loop.shutdown_default_executor(constants.THREAD_JOIN_TIMEOUT)) finally: if self._set_event_loop: events.set_event_loop(None) loop.close() self._loop = None self._state = _State.CLOSED def get_loop(self): """Return embedded event loop.""" self._lazy_init() return self._loop def run(self, coro, *, context=None): """Run a coroutine inside the embedded event loop.""" if not coroutines.iscoroutine(coro): raise ValueError("a coroutine was expected, got {!r}".format(coro)) if events._get_running_loop() is not None: # fail fast with short traceback raise RuntimeError( "Runner.run() cannot be called from a running event loop") self._lazy_init() if context is None: context = self._context task = self._loop.create_task(coro, context=context) if (threading.current_thread() is threading.main_thread() and signal.getsignal(signal.SIGINT) is signal.default_int_handler ): sigint_handler = functools.partial(self._on_sigint, main_task=task) try: signal.signal(signal.SIGINT, sigint_handler) except ValueError: # `signal.signal` may throw if `threading.main_thread` does # not support signals (e.g. embedded interpreter with signals # not registered - see gh-91880) sigint_handler = None else: sigint_handler = None self._interrupt_count = 0 try: return self._loop.run_until_complete(task) except exceptions.CancelledError: if self._interrupt_count > 0: uncancel = getattr(task, "uncancel", None) if uncancel is not None and uncancel() == 0: raise KeyboardInterrupt() raise # CancelledError finally: if (sigint_handler is not None and signal.getsignal(signal.SIGINT) is sigint_handler ): signal.signal(signal.SIGINT, signal.default_int_handler) def _lazy_init(self): if self._state is _State.CLOSED: raise RuntimeError("Runner is closed") if self._state is _State.INITIALIZED: return if self._loop_factory is None: self._loop = events.new_event_loop() if not self._set_event_loop: # Call set_event_loop only once to avoid calling # attach_loop multiple times on child watchers events.set_event_loop(self._loop) self._set_event_loop = True else: self._loop = self._loop_factory() if self._debug is not None: self._loop.set_debug(self._debug) self._context = contextvars.copy_context() self._state = _State.INITIALIZED def _on_sigint(self, signum, frame, main_task): self._interrupt_count += 1 if self._interrupt_count == 1 and not main_task.done(): main_task.cancel() # wakeup loop if it is blocked by select() with long timeout self._loop.call_soon_threadsafe(lambda: None) return raise KeyboardInterrupt() def run(main, *, debug=None, loop_factory=None): """Execute the coroutine and return the result. This function runs the passed coroutine, taking care of managing the asyncio event loop, finalizing asynchronous generators and closing the default executor. This function cannot be called when another asyncio event loop is running in the same thread. If debug is True, the event loop will be run in debug mode. If loop_factory is passed, it is used for new event loop creation. This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once. The executor is given a timeout duration of 5 minutes to shutdown. If the executor hasn't finished within that duration, a warning is emitted and the executor is closed. Example: async def main(): await asyncio.sleep(1) print('hello') asyncio.run(main()) """ if events._get_running_loop() is not None: # fail fast with short traceback raise RuntimeError( "asyncio.run() cannot be called from a running event loop") with Runner(debug=debug, loop_factory=loop_factory) as runner: return runner.run(main) def _cancel_all_tasks(loop): to_cancel = tasks.all_tasks(loop) if not to_cancel: return for task in to_cancel: task.cancel() loop.run_until_complete(tasks.gather(*to_cancel, return_exceptions=True)) for task in to_cancel: if task.cancelled(): continue if task.exception() is not None: loop.call_exception_handler({ 'message': 'unhandled exception during asyncio.run() shutdown', 'exception': task.exception(), 'task': task, }) selector_events.py000064400000136314151706172570010345 0ustar00"""Event loop using a selector and related classes. A selector is a "notify-when-ready" multiplexer. For a subclass which also includes support for signal handling, see the unix_events sub-module. """ __all__ = 'BaseSelectorEventLoop', import collections import errno import functools import itertools import os import selectors import socket import warnings import weakref try: import ssl except ImportError: # pragma: no cover ssl = None from . import base_events from . import constants from . import events from . import futures from . import protocols from . import sslproto from . import transports from . import trsock from .log import logger _HAS_SENDMSG = hasattr(socket.socket, 'sendmsg') if _HAS_SENDMSG: try: SC_IOV_MAX = os.sysconf('SC_IOV_MAX') except OSError: # Fallback to send _HAS_SENDMSG = False def _test_selector_event(selector, fd, event): # Test if the selector is monitoring 'event' events # for the file descriptor 'fd'. try: key = selector.get_key(fd) except KeyError: return False else: return bool(key.events & event) class BaseSelectorEventLoop(base_events.BaseEventLoop): """Selector event loop. See events.EventLoop for API specification. """ def __init__(self, selector=None): super().__init__() if selector is None: selector = selectors.DefaultSelector() logger.debug('Using selector: %s', selector.__class__.__name__) self._selector = selector self._make_self_pipe() self._transports = weakref.WeakValueDictionary() def _make_socket_transport(self, sock, protocol, waiter=None, *, extra=None, server=None): self._ensure_fd_no_transport(sock) return _SelectorSocketTransport(self, sock, protocol, waiter, extra, server) def _make_ssl_transport( self, rawsock, protocol, sslcontext, waiter=None, *, server_side=False, server_hostname=None, extra=None, server=None, ssl_handshake_timeout=constants.SSL_HANDSHAKE_TIMEOUT, ssl_shutdown_timeout=constants.SSL_SHUTDOWN_TIMEOUT, ): self._ensure_fd_no_transport(rawsock) ssl_protocol = sslproto.SSLProtocol( self, protocol, sslcontext, waiter, server_side, server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout ) _SelectorSocketTransport(self, rawsock, ssl_protocol, extra=extra, server=server) return ssl_protocol._app_transport def _make_datagram_transport(self, sock, protocol, address=None, waiter=None, extra=None): self._ensure_fd_no_transport(sock) return _SelectorDatagramTransport(self, sock, protocol, address, waiter, extra) def close(self): if self.is_running(): raise RuntimeError("Cannot close a running event loop") if self.is_closed(): return self._close_self_pipe() super().close() if self._selector is not None: self._selector.close() self._selector = None def _close_self_pipe(self): self._remove_reader(self._ssock.fileno()) self._ssock.close() self._ssock = None self._csock.close() self._csock = None self._internal_fds -= 1 def _make_self_pipe(self): # A self-socket, really. :-) self._ssock, self._csock = socket.socketpair() self._ssock.setblocking(False) self._csock.setblocking(False) self._internal_fds += 1 self._add_reader(self._ssock.fileno(), self._read_from_self) def _process_self_data(self, data): pass def _read_from_self(self): while True: try: data = self._ssock.recv(4096) if not data: break self._process_self_data(data) except InterruptedError: continue except BlockingIOError: break def _write_to_self(self): # This may be called from a different thread, possibly after # _close_self_pipe() has been called or even while it is # running. Guard for self._csock being None or closed. When # a socket is closed, send() raises OSError (with errno set to # EBADF, but let's not rely on the exact error code). csock = self._csock if csock is None: return try: csock.send(b'\0') except OSError: if self._debug: logger.debug("Fail to write a null byte into the " "self-pipe socket", exc_info=True) def _start_serving(self, protocol_factory, sock, sslcontext=None, server=None, backlog=100, ssl_handshake_timeout=constants.SSL_HANDSHAKE_TIMEOUT, ssl_shutdown_timeout=constants.SSL_SHUTDOWN_TIMEOUT): self._add_reader(sock.fileno(), self._accept_connection, protocol_factory, sock, sslcontext, server, backlog, ssl_handshake_timeout, ssl_shutdown_timeout) def _accept_connection( self, protocol_factory, sock, sslcontext=None, server=None, backlog=100, ssl_handshake_timeout=constants.SSL_HANDSHAKE_TIMEOUT, ssl_shutdown_timeout=constants.SSL_SHUTDOWN_TIMEOUT): # This method is only called once for each event loop tick where the # listening socket has triggered an EVENT_READ. There may be multiple # connections waiting for an .accept() so it is called in a loop. # See https://bugs.python.org/issue27906 for more details. for _ in range(backlog): try: conn, addr = sock.accept() if self._debug: logger.debug("%r got a new connection from %r: %r", server, addr, conn) conn.setblocking(False) except (BlockingIOError, InterruptedError, ConnectionAbortedError): # Early exit because the socket accept buffer is empty. return None except OSError as exc: # There's nowhere to send the error, so just log it. if exc.errno in (errno.EMFILE, errno.ENFILE, errno.ENOBUFS, errno.ENOMEM): # Some platforms (e.g. Linux keep reporting the FD as # ready, so we remove the read handler temporarily. # We'll try again in a while. self.call_exception_handler({ 'message': 'socket.accept() out of system resource', 'exception': exc, 'socket': trsock.TransportSocket(sock), }) self._remove_reader(sock.fileno()) self.call_later(constants.ACCEPT_RETRY_DELAY, self._start_serving, protocol_factory, sock, sslcontext, server, backlog, ssl_handshake_timeout, ssl_shutdown_timeout) else: raise # The event loop will catch, log and ignore it. else: extra = {'peername': addr} accept = self._accept_connection2( protocol_factory, conn, extra, sslcontext, server, ssl_handshake_timeout, ssl_shutdown_timeout) self.create_task(accept) async def _accept_connection2( self, protocol_factory, conn, extra, sslcontext=None, server=None, ssl_handshake_timeout=constants.SSL_HANDSHAKE_TIMEOUT, ssl_shutdown_timeout=constants.SSL_SHUTDOWN_TIMEOUT): protocol = None transport = None try: protocol = protocol_factory() waiter = self.create_future() if sslcontext: transport = self._make_ssl_transport( conn, protocol, sslcontext, waiter=waiter, server_side=True, extra=extra, server=server, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) else: transport = self._make_socket_transport( conn, protocol, waiter=waiter, extra=extra, server=server) try: await waiter except BaseException: transport.close() # gh-109534: When an exception is raised by the SSLProtocol object the # exception set in this future can keep the protocol object alive and # cause a reference cycle. waiter = None raise # It's now up to the protocol to handle the connection. except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: if self._debug: context = { 'message': 'Error on transport creation for incoming connection', 'exception': exc, } if protocol is not None: context['protocol'] = protocol if transport is not None: context['transport'] = transport self.call_exception_handler(context) def _ensure_fd_no_transport(self, fd): fileno = fd if not isinstance(fileno, int): try: fileno = int(fileno.fileno()) except (AttributeError, TypeError, ValueError): # This code matches selectors._fileobj_to_fd function. raise ValueError(f"Invalid file object: {fd!r}") from None try: transport = self._transports[fileno] except KeyError: pass else: if not transport.is_closing(): raise RuntimeError( f'File descriptor {fd!r} is used by transport ' f'{transport!r}') def _add_reader(self, fd, callback, *args): self._check_closed() handle = events.Handle(callback, args, self, None) try: key = self._selector.get_key(fd) except KeyError: self._selector.register(fd, selectors.EVENT_READ, (handle, None)) else: mask, (reader, writer) = key.events, key.data self._selector.modify(fd, mask | selectors.EVENT_READ, (handle, writer)) if reader is not None: reader.cancel() return handle def _remove_reader(self, fd): if self.is_closed(): return False try: key = self._selector.get_key(fd) except KeyError: return False else: mask, (reader, writer) = key.events, key.data mask &= ~selectors.EVENT_READ if not mask: self._selector.unregister(fd) else: self._selector.modify(fd, mask, (None, writer)) if reader is not None: reader.cancel() return True else: return False def _add_writer(self, fd, callback, *args): self._check_closed() handle = events.Handle(callback, args, self, None) try: key = self._selector.get_key(fd) except KeyError: self._selector.register(fd, selectors.EVENT_WRITE, (None, handle)) else: mask, (reader, writer) = key.events, key.data self._selector.modify(fd, mask | selectors.EVENT_WRITE, (reader, handle)) if writer is not None: writer.cancel() return handle def _remove_writer(self, fd): """Remove a writer callback.""" if self.is_closed(): return False try: key = self._selector.get_key(fd) except KeyError: return False else: mask, (reader, writer) = key.events, key.data # Remove both writer and connector. mask &= ~selectors.EVENT_WRITE if not mask: self._selector.unregister(fd) else: self._selector.modify(fd, mask, (reader, None)) if writer is not None: writer.cancel() return True else: return False def add_reader(self, fd, callback, *args): """Add a reader callback.""" self._ensure_fd_no_transport(fd) self._add_reader(fd, callback, *args) def remove_reader(self, fd): """Remove a reader callback.""" self._ensure_fd_no_transport(fd) return self._remove_reader(fd) def add_writer(self, fd, callback, *args): """Add a writer callback..""" self._ensure_fd_no_transport(fd) self._add_writer(fd, callback, *args) def remove_writer(self, fd): """Remove a writer callback.""" self._ensure_fd_no_transport(fd) return self._remove_writer(fd) async def sock_recv(self, sock, n): """Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by nbytes. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") try: return sock.recv(n) except (BlockingIOError, InterruptedError): pass fut = self.create_future() fd = sock.fileno() self._ensure_fd_no_transport(fd) handle = self._add_reader(fd, self._sock_recv, fut, sock, n) fut.add_done_callback( functools.partial(self._sock_read_done, fd, handle=handle)) return await fut def _sock_read_done(self, fd, fut, handle=None): if handle is None or not handle.cancelled(): self.remove_reader(fd) def _sock_recv(self, fut, sock, n): # _sock_recv() can add itself as an I/O callback if the operation can't # be done immediately. Don't use it directly, call sock_recv(). if fut.done(): return try: data = sock.recv(n) except (BlockingIOError, InterruptedError): return # try again next time except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result(data) async def sock_recv_into(self, sock, buf): """Receive data from the socket. The received data is written into *buf* (a writable buffer). The return value is the number of bytes written. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") try: return sock.recv_into(buf) except (BlockingIOError, InterruptedError): pass fut = self.create_future() fd = sock.fileno() self._ensure_fd_no_transport(fd) handle = self._add_reader(fd, self._sock_recv_into, fut, sock, buf) fut.add_done_callback( functools.partial(self._sock_read_done, fd, handle=handle)) return await fut def _sock_recv_into(self, fut, sock, buf): # _sock_recv_into() can add itself as an I/O callback if the operation # can't be done immediately. Don't use it directly, call # sock_recv_into(). if fut.done(): return try: nbytes = sock.recv_into(buf) except (BlockingIOError, InterruptedError): return # try again next time except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result(nbytes) async def sock_recvfrom(self, sock, bufsize): """Receive a datagram from a datagram socket. The return value is a tuple of (bytes, address) representing the datagram received and the address it came from. The maximum amount of data to be received at once is specified by nbytes. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") try: return sock.recvfrom(bufsize) except (BlockingIOError, InterruptedError): pass fut = self.create_future() fd = sock.fileno() self._ensure_fd_no_transport(fd) handle = self._add_reader(fd, self._sock_recvfrom, fut, sock, bufsize) fut.add_done_callback( functools.partial(self._sock_read_done, fd, handle=handle)) return await fut def _sock_recvfrom(self, fut, sock, bufsize): # _sock_recvfrom() can add itself as an I/O callback if the operation # can't be done immediately. Don't use it directly, call # sock_recvfrom(). if fut.done(): return try: result = sock.recvfrom(bufsize) except (BlockingIOError, InterruptedError): return # try again next time except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result(result) async def sock_recvfrom_into(self, sock, buf, nbytes=0): """Receive data from the socket. The received data is written into *buf* (a writable buffer). The return value is a tuple of (number of bytes written, address). """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") if not nbytes: nbytes = len(buf) try: return sock.recvfrom_into(buf, nbytes) except (BlockingIOError, InterruptedError): pass fut = self.create_future() fd = sock.fileno() self._ensure_fd_no_transport(fd) handle = self._add_reader(fd, self._sock_recvfrom_into, fut, sock, buf, nbytes) fut.add_done_callback( functools.partial(self._sock_read_done, fd, handle=handle)) return await fut def _sock_recvfrom_into(self, fut, sock, buf, bufsize): # _sock_recv_into() can add itself as an I/O callback if the operation # can't be done immediately. Don't use it directly, call # sock_recv_into(). if fut.done(): return try: result = sock.recvfrom_into(buf, bufsize) except (BlockingIOError, InterruptedError): return # try again next time except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result(result) async def sock_sendall(self, sock, data): """Send data to the socket. The socket must be connected to a remote socket. This method continues to send data from data until either all data has been sent or an error occurs. None is returned on success. On error, an exception is raised, and there is no way to determine how much data, if any, was successfully processed by the receiving end of the connection. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") try: n = sock.send(data) except (BlockingIOError, InterruptedError): n = 0 if n == len(data): # all data sent return fut = self.create_future() fd = sock.fileno() self._ensure_fd_no_transport(fd) # use a trick with a list in closure to store a mutable state handle = self._add_writer(fd, self._sock_sendall, fut, sock, memoryview(data), [n]) fut.add_done_callback( functools.partial(self._sock_write_done, fd, handle=handle)) return await fut def _sock_sendall(self, fut, sock, view, pos): if fut.done(): # Future cancellation can be scheduled on previous loop iteration return start = pos[0] try: n = sock.send(view[start:]) except (BlockingIOError, InterruptedError): return except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) return start += n if start == len(view): fut.set_result(None) else: pos[0] = start async def sock_sendto(self, sock, data, address): """Send data to the socket. The socket must be connected to a remote socket. This method continues to send data from data until either all data has been sent or an error occurs. None is returned on success. On error, an exception is raised, and there is no way to determine how much data, if any, was successfully processed by the receiving end of the connection. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") try: return sock.sendto(data, address) except (BlockingIOError, InterruptedError): pass fut = self.create_future() fd = sock.fileno() self._ensure_fd_no_transport(fd) # use a trick with a list in closure to store a mutable state handle = self._add_writer(fd, self._sock_sendto, fut, sock, data, address) fut.add_done_callback( functools.partial(self._sock_write_done, fd, handle=handle)) return await fut def _sock_sendto(self, fut, sock, data, address): if fut.done(): # Future cancellation can be scheduled on previous loop iteration return try: n = sock.sendto(data, 0, address) except (BlockingIOError, InterruptedError): return except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result(n) async def sock_connect(self, sock, address): """Connect to a remote socket at address. This method is a coroutine. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") if sock.family == socket.AF_INET or ( base_events._HAS_IPv6 and sock.family == socket.AF_INET6): resolved = await self._ensure_resolved( address, family=sock.family, type=sock.type, proto=sock.proto, loop=self, ) _, _, _, _, address = resolved[0] fut = self.create_future() self._sock_connect(fut, sock, address) try: return await fut finally: # Needed to break cycles when an exception occurs. fut = None def _sock_connect(self, fut, sock, address): fd = sock.fileno() try: sock.connect(address) except (BlockingIOError, InterruptedError): # Issue #23618: When the C function connect() fails with EINTR, the # connection runs in background. We have to wait until the socket # becomes writable to be notified when the connection succeed or # fails. self._ensure_fd_no_transport(fd) handle = self._add_writer( fd, self._sock_connect_cb, fut, sock, address) fut.add_done_callback( functools.partial(self._sock_write_done, fd, handle=handle)) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result(None) finally: fut = None def _sock_write_done(self, fd, fut, handle=None): if handle is None or not handle.cancelled(): self.remove_writer(fd) def _sock_connect_cb(self, fut, sock, address): if fut.done(): return try: err = sock.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR) if err != 0: # Jump to any except clause below. raise OSError(err, f'Connect call failed {address}') except (BlockingIOError, InterruptedError): # socket is still registered, the callback will be retried later pass except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result(None) finally: fut = None async def sock_accept(self, sock): """Accept a connection. The socket must be bound to an address and listening for connections. The return value is a pair (conn, address) where conn is a new socket object usable to send and receive data on the connection, and address is the address bound to the socket on the other end of the connection. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") fut = self.create_future() self._sock_accept(fut, sock) return await fut def _sock_accept(self, fut, sock): fd = sock.fileno() try: conn, address = sock.accept() conn.setblocking(False) except (BlockingIOError, InterruptedError): self._ensure_fd_no_transport(fd) handle = self._add_reader(fd, self._sock_accept, fut, sock) fut.add_done_callback( functools.partial(self._sock_read_done, fd, handle=handle)) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result((conn, address)) async def _sendfile_native(self, transp, file, offset, count): del self._transports[transp._sock_fd] resume_reading = transp.is_reading() transp.pause_reading() await transp._make_empty_waiter() try: return await self.sock_sendfile(transp._sock, file, offset, count, fallback=False) finally: transp._reset_empty_waiter() if resume_reading: transp.resume_reading() self._transports[transp._sock_fd] = transp def _process_events(self, event_list): for key, mask in event_list: fileobj, (reader, writer) = key.fileobj, key.data if mask & selectors.EVENT_READ and reader is not None: if reader._cancelled: self._remove_reader(fileobj) else: self._add_callback(reader) if mask & selectors.EVENT_WRITE and writer is not None: if writer._cancelled: self._remove_writer(fileobj) else: self._add_callback(writer) def _stop_serving(self, sock): self._remove_reader(sock.fileno()) sock.close() class _SelectorTransport(transports._FlowControlMixin, transports.Transport): max_size = 256 * 1024 # Buffer size passed to recv(). # Attribute used in the destructor: it must be set even if the constructor # is not called (see _SelectorSslTransport which may start by raising an # exception) _sock = None def __init__(self, loop, sock, protocol, extra=None, server=None): super().__init__(extra, loop) self._extra['socket'] = trsock.TransportSocket(sock) try: self._extra['sockname'] = sock.getsockname() except OSError: self._extra['sockname'] = None if 'peername' not in self._extra: try: self._extra['peername'] = sock.getpeername() except socket.error: self._extra['peername'] = None self._sock = sock self._sock_fd = sock.fileno() self._protocol_connected = False self.set_protocol(protocol) self._server = server self._buffer = collections.deque() self._conn_lost = 0 # Set when call to connection_lost scheduled. self._closing = False # Set when close() called. self._paused = False # Set when pause_reading() called if self._server is not None: self._server._attach() loop._transports[self._sock_fd] = self def __repr__(self): info = [self.__class__.__name__] if self._sock is None: info.append('closed') elif self._closing: info.append('closing') info.append(f'fd={self._sock_fd}') # test if the transport was closed if self._loop is not None and not self._loop.is_closed(): polling = _test_selector_event(self._loop._selector, self._sock_fd, selectors.EVENT_READ) if polling: info.append('read=polling') else: info.append('read=idle') polling = _test_selector_event(self._loop._selector, self._sock_fd, selectors.EVENT_WRITE) if polling: state = 'polling' else: state = 'idle' bufsize = self.get_write_buffer_size() info.append(f'write=<{state}, bufsize={bufsize}>') return '<{}>'.format(' '.join(info)) def abort(self): self._force_close(None) def set_protocol(self, protocol): self._protocol = protocol self._protocol_connected = True def get_protocol(self): return self._protocol def is_closing(self): return self._closing def is_reading(self): return not self.is_closing() and not self._paused def pause_reading(self): if not self.is_reading(): return self._paused = True self._loop._remove_reader(self._sock_fd) if self._loop.get_debug(): logger.debug("%r pauses reading", self) def resume_reading(self): if self._closing or not self._paused: return self._paused = False self._add_reader(self._sock_fd, self._read_ready) if self._loop.get_debug(): logger.debug("%r resumes reading", self) def close(self): if self._closing: return self._closing = True self._loop._remove_reader(self._sock_fd) if not self._buffer: self._conn_lost += 1 self._loop._remove_writer(self._sock_fd) self._loop.call_soon(self._call_connection_lost, None) def __del__(self, _warn=warnings.warn): if self._sock is not None: _warn(f"unclosed transport {self!r}", ResourceWarning, source=self) self._sock.close() def _fatal_error(self, exc, message='Fatal error on transport'): # Should be called from exception handler only. if isinstance(exc, OSError): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) self._force_close(exc) def _force_close(self, exc): if self._conn_lost: return if self._buffer: self._buffer.clear() self._loop._remove_writer(self._sock_fd) if not self._closing: self._closing = True self._loop._remove_reader(self._sock_fd) self._conn_lost += 1 self._loop.call_soon(self._call_connection_lost, exc) def _call_connection_lost(self, exc): try: if self._protocol_connected: self._protocol.connection_lost(exc) finally: self._sock.close() self._sock = None self._protocol = None self._loop = None server = self._server if server is not None: server._detach() self._server = None def get_write_buffer_size(self): return sum(map(len, self._buffer)) def _add_reader(self, fd, callback, *args): if not self.is_reading(): return self._loop._add_reader(fd, callback, *args) class _SelectorSocketTransport(_SelectorTransport): _start_tls_compatible = True _sendfile_compatible = constants._SendfileMode.TRY_NATIVE def __init__(self, loop, sock, protocol, waiter=None, extra=None, server=None): self._read_ready_cb = None super().__init__(loop, sock, protocol, extra, server) self._eof = False self._empty_waiter = None if _HAS_SENDMSG: self._write_ready = self._write_sendmsg else: self._write_ready = self._write_send # Disable the Nagle algorithm -- small writes will be # sent without waiting for the TCP ACK. This generally # decreases the latency (in some cases significantly.) base_events._set_nodelay(self._sock) self._loop.call_soon(self._protocol.connection_made, self) # only start reading when connection_made() has been called self._loop.call_soon(self._add_reader, self._sock_fd, self._read_ready) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) def set_protocol(self, protocol): if isinstance(protocol, protocols.BufferedProtocol): self._read_ready_cb = self._read_ready__get_buffer else: self._read_ready_cb = self._read_ready__data_received super().set_protocol(protocol) def _read_ready(self): self._read_ready_cb() def _read_ready__get_buffer(self): if self._conn_lost: return try: buf = self._protocol.get_buffer(-1) if not len(buf): raise RuntimeError('get_buffer() returned an empty buffer') except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error( exc, 'Fatal error: protocol.get_buffer() call failed.') return try: nbytes = self._sock.recv_into(buf) except (BlockingIOError, InterruptedError): return except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error(exc, 'Fatal read error on socket transport') return if not nbytes: self._read_ready__on_eof() return try: self._protocol.buffer_updated(nbytes) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error( exc, 'Fatal error: protocol.buffer_updated() call failed.') def _read_ready__data_received(self): if self._conn_lost: return try: data = self._sock.recv(self.max_size) except (BlockingIOError, InterruptedError): return except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error(exc, 'Fatal read error on socket transport') return if not data: self._read_ready__on_eof() return try: self._protocol.data_received(data) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error( exc, 'Fatal error: protocol.data_received() call failed.') def _read_ready__on_eof(self): if self._loop.get_debug(): logger.debug("%r received EOF", self) try: keep_open = self._protocol.eof_received() except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error( exc, 'Fatal error: protocol.eof_received() call failed.') return if keep_open: # We're keeping the connection open so the # protocol can write more, but we still can't # receive more, so remove the reader callback. self._loop._remove_reader(self._sock_fd) else: self.close() def write(self, data): if not isinstance(data, (bytes, bytearray, memoryview)): raise TypeError(f'data argument must be a bytes-like object, ' f'not {type(data).__name__!r}') if self._eof: raise RuntimeError('Cannot call write() after write_eof()') if self._empty_waiter is not None: raise RuntimeError('unable to write; sendfile is in progress') if not data: return if self._conn_lost: if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('socket.send() raised exception.') self._conn_lost += 1 return if not self._buffer: # Optimization: try to send now. try: n = self._sock.send(data) except (BlockingIOError, InterruptedError): pass except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error(exc, 'Fatal write error on socket transport') return else: data = memoryview(data)[n:] if not data: return # Not all was written; register write handler. self._loop._add_writer(self._sock_fd, self._write_ready) # Add it to the buffer. self._buffer.append(data) self._maybe_pause_protocol() def _get_sendmsg_buffer(self): return itertools.islice(self._buffer, SC_IOV_MAX) def _write_sendmsg(self): assert self._buffer, 'Data should not be empty' if self._conn_lost: return try: nbytes = self._sock.sendmsg(self._get_sendmsg_buffer()) self._adjust_leftover_buffer(nbytes) except (BlockingIOError, InterruptedError): pass except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._loop._remove_writer(self._sock_fd) self._buffer.clear() self._fatal_error(exc, 'Fatal write error on socket transport') if self._empty_waiter is not None: self._empty_waiter.set_exception(exc) else: self._maybe_resume_protocol() # May append to buffer. if not self._buffer: self._loop._remove_writer(self._sock_fd) if self._empty_waiter is not None: self._empty_waiter.set_result(None) if self._closing: self._call_connection_lost(None) elif self._eof: self._sock.shutdown(socket.SHUT_WR) def _adjust_leftover_buffer(self, nbytes: int) -> None: buffer = self._buffer while nbytes: b = buffer.popleft() b_len = len(b) if b_len <= nbytes: nbytes -= b_len else: buffer.appendleft(b[nbytes:]) break def _write_send(self): assert self._buffer, 'Data should not be empty' if self._conn_lost: return try: buffer = self._buffer.popleft() n = self._sock.send(buffer) if n != len(buffer): # Not all data was written self._buffer.appendleft(buffer[n:]) except (BlockingIOError, InterruptedError): pass except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._loop._remove_writer(self._sock_fd) self._buffer.clear() self._fatal_error(exc, 'Fatal write error on socket transport') if self._empty_waiter is not None: self._empty_waiter.set_exception(exc) else: self._maybe_resume_protocol() # May append to buffer. if not self._buffer: self._loop._remove_writer(self._sock_fd) if self._empty_waiter is not None: self._empty_waiter.set_result(None) if self._closing: self._call_connection_lost(None) elif self._eof: self._sock.shutdown(socket.SHUT_WR) def write_eof(self): if self._closing or self._eof: return self._eof = True if not self._buffer: self._sock.shutdown(socket.SHUT_WR) def writelines(self, list_of_data): if self._eof: raise RuntimeError('Cannot call writelines() after write_eof()') if self._empty_waiter is not None: raise RuntimeError('unable to writelines; sendfile is in progress') if not list_of_data: return self._buffer.extend([memoryview(data) for data in list_of_data]) self._write_ready() # If the entire buffer couldn't be written, register a write handler if self._buffer: self._loop._add_writer(self._sock_fd, self._write_ready) self._maybe_pause_protocol() def can_write_eof(self): return True def _call_connection_lost(self, exc): try: super()._call_connection_lost(exc) finally: self._write_ready = None if self._empty_waiter is not None: self._empty_waiter.set_exception( ConnectionError("Connection is closed by peer")) def _make_empty_waiter(self): if self._empty_waiter is not None: raise RuntimeError("Empty waiter is already set") self._empty_waiter = self._loop.create_future() if not self._buffer: self._empty_waiter.set_result(None) return self._empty_waiter def _reset_empty_waiter(self): self._empty_waiter = None def close(self): self._read_ready_cb = None super().close() class _SelectorDatagramTransport(_SelectorTransport, transports.DatagramTransport): _buffer_factory = collections.deque def __init__(self, loop, sock, protocol, address=None, waiter=None, extra=None): super().__init__(loop, sock, protocol, extra) self._address = address self._buffer_size = 0 self._loop.call_soon(self._protocol.connection_made, self) # only start reading when connection_made() has been called self._loop.call_soon(self._add_reader, self._sock_fd, self._read_ready) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) def get_write_buffer_size(self): return self._buffer_size def _read_ready(self): if self._conn_lost: return try: data, addr = self._sock.recvfrom(self.max_size) except (BlockingIOError, InterruptedError): pass except OSError as exc: self._protocol.error_received(exc) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error(exc, 'Fatal read error on datagram transport') else: self._protocol.datagram_received(data, addr) def sendto(self, data, addr=None): if not isinstance(data, (bytes, bytearray, memoryview)): raise TypeError(f'data argument must be a bytes-like object, ' f'not {type(data).__name__!r}') if not data: return if self._address: if addr not in (None, self._address): raise ValueError( f'Invalid address: must be None or {self._address}') addr = self._address if self._conn_lost and self._address: if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('socket.send() raised exception.') self._conn_lost += 1 return if not self._buffer: # Attempt to send it right away first. try: if self._extra['peername']: self._sock.send(data) else: self._sock.sendto(data, addr) return except (BlockingIOError, InterruptedError): self._loop._add_writer(self._sock_fd, self._sendto_ready) except OSError as exc: self._protocol.error_received(exc) return except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error( exc, 'Fatal write error on datagram transport') return # Ensure that what we buffer is immutable. self._buffer.append((bytes(data), addr)) self._buffer_size += len(data) self._maybe_pause_protocol() def _sendto_ready(self): while self._buffer: data, addr = self._buffer.popleft() self._buffer_size -= len(data) try: if self._extra['peername']: self._sock.send(data) else: self._sock.sendto(data, addr) except (BlockingIOError, InterruptedError): self._buffer.appendleft((data, addr)) # Try again later. self._buffer_size += len(data) break except OSError as exc: self._protocol.error_received(exc) return except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error( exc, 'Fatal write error on datagram transport') return self._maybe_resume_protocol() # May append to buffer. if not self._buffer: self._loop._remove_writer(self._sock_fd) if self._closing: self._call_connection_lost(None) sslproto.py000064400000076233151706172570007031 0ustar00# Contains code from https://github.com/MagicStack/uvloop/tree/v0.16.0 # SPDX-License-Identifier: PSF-2.0 AND (MIT OR Apache-2.0) # SPDX-FileCopyrightText: Copyright (c) 2015-2021 MagicStack Inc. http://magic.io import collections import enum import warnings try: import ssl except ImportError: # pragma: no cover ssl = None from . import constants from . import exceptions from . import protocols from . import transports from .log import logger if ssl is not None: SSLAgainErrors = (ssl.SSLWantReadError, ssl.SSLSyscallError) class SSLProtocolState(enum.Enum): UNWRAPPED = "UNWRAPPED" DO_HANDSHAKE = "DO_HANDSHAKE" WRAPPED = "WRAPPED" FLUSHING = "FLUSHING" SHUTDOWN = "SHUTDOWN" class AppProtocolState(enum.Enum): # This tracks the state of app protocol (https://git.io/fj59P): # # INIT -cm-> CON_MADE [-dr*->] [-er-> EOF?] -cl-> CON_LOST # # * cm: connection_made() # * dr: data_received() # * er: eof_received() # * cl: connection_lost() STATE_INIT = "STATE_INIT" STATE_CON_MADE = "STATE_CON_MADE" STATE_EOF = "STATE_EOF" STATE_CON_LOST = "STATE_CON_LOST" def _create_transport_context(server_side, server_hostname): if server_side: raise ValueError('Server side SSL needs a valid SSLContext') # Client side may pass ssl=True to use a default # context; in that case the sslcontext passed is None. # The default is secure for client connections. # Python 3.4+: use up-to-date strong settings. sslcontext = ssl.create_default_context() if not server_hostname: sslcontext.check_hostname = False return sslcontext def add_flowcontrol_defaults(high, low, kb): if high is None: if low is None: hi = kb * 1024 else: lo = low hi = 4 * lo else: hi = high if low is None: lo = hi // 4 else: lo = low if not hi >= lo >= 0: raise ValueError('high (%r) must be >= low (%r) must be >= 0' % (hi, lo)) return hi, lo class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport): _start_tls_compatible = True _sendfile_compatible = constants._SendfileMode.FALLBACK def __init__(self, loop, ssl_protocol): self._loop = loop self._ssl_protocol = ssl_protocol self._closed = False def get_extra_info(self, name, default=None): """Get optional transport information.""" return self._ssl_protocol._get_extra_info(name, default) def set_protocol(self, protocol): self._ssl_protocol._set_app_protocol(protocol) def get_protocol(self): return self._ssl_protocol._app_protocol def is_closing(self): return self._closed or self._ssl_protocol._is_transport_closing() def close(self): """Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. """ if not self._closed: self._closed = True self._ssl_protocol._start_shutdown() else: self._ssl_protocol = None def __del__(self, _warnings=warnings): if not self._closed: self._closed = True _warnings.warn( "unclosed transport <asyncio._SSLProtocolTransport " "object>", ResourceWarning) def is_reading(self): return not self._ssl_protocol._app_reading_paused def pause_reading(self): """Pause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. """ self._ssl_protocol._pause_reading() def resume_reading(self): """Resume the receiving end. Data received will once again be passed to the protocol's data_received() method. """ self._ssl_protocol._resume_reading() def set_write_buffer_limits(self, high=None, low=None): """Set the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. """ self._ssl_protocol._set_write_buffer_limits(high, low) self._ssl_protocol._control_app_writing() def get_write_buffer_limits(self): return (self._ssl_protocol._outgoing_low_water, self._ssl_protocol._outgoing_high_water) def get_write_buffer_size(self): """Return the current size of the write buffers.""" return self._ssl_protocol._get_write_buffer_size() def set_read_buffer_limits(self, high=None, low=None): """Set the high- and low-water limits for read flow control. These two values control when to call the upstream transport's pause_reading() and resume_reading() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_reading() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_reading() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. """ self._ssl_protocol._set_read_buffer_limits(high, low) self._ssl_protocol._control_ssl_reading() def get_read_buffer_limits(self): return (self._ssl_protocol._incoming_low_water, self._ssl_protocol._incoming_high_water) def get_read_buffer_size(self): """Return the current size of the read buffer.""" return self._ssl_protocol._get_read_buffer_size() @property def _protocol_paused(self): # Required for sendfile fallback pause_writing/resume_writing logic return self._ssl_protocol._app_writing_paused def write(self, data): """Write some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. """ if not isinstance(data, (bytes, bytearray, memoryview)): raise TypeError(f"data: expecting a bytes-like instance, " f"got {type(data).__name__}") if not data: return self._ssl_protocol._write_appdata((data,)) def writelines(self, list_of_data): """Write a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. """ self._ssl_protocol._write_appdata(list_of_data) def write_eof(self): """Close the write end after flushing buffered data. This raises :exc:`NotImplementedError` right now. """ raise NotImplementedError def can_write_eof(self): """Return True if this transport supports write_eof(), False if not.""" return False def abort(self): """Close the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. """ self._force_close(None) def _force_close(self, exc): self._closed = True if self._ssl_protocol is not None: self._ssl_protocol._abort(exc) def _test__append_write_backlog(self, data): # for test only self._ssl_protocol._write_backlog.append(data) self._ssl_protocol._write_buffer_size += len(data) class SSLProtocol(protocols.BufferedProtocol): max_size = 256 * 1024 # Buffer size passed to read() _handshake_start_time = None _handshake_timeout_handle = None _shutdown_timeout_handle = None def __init__(self, loop, app_protocol, sslcontext, waiter, server_side=False, server_hostname=None, call_connection_made=True, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): if ssl is None: raise RuntimeError("stdlib ssl module not available") self._ssl_buffer = bytearray(self.max_size) self._ssl_buffer_view = memoryview(self._ssl_buffer) if ssl_handshake_timeout is None: ssl_handshake_timeout = constants.SSL_HANDSHAKE_TIMEOUT elif ssl_handshake_timeout <= 0: raise ValueError( f"ssl_handshake_timeout should be a positive number, " f"got {ssl_handshake_timeout}") if ssl_shutdown_timeout is None: ssl_shutdown_timeout = constants.SSL_SHUTDOWN_TIMEOUT elif ssl_shutdown_timeout <= 0: raise ValueError( f"ssl_shutdown_timeout should be a positive number, " f"got {ssl_shutdown_timeout}") if not sslcontext: sslcontext = _create_transport_context( server_side, server_hostname) self._server_side = server_side if server_hostname and not server_side: self._server_hostname = server_hostname else: self._server_hostname = None self._sslcontext = sslcontext # SSL-specific extra info. More info are set when the handshake # completes. self._extra = dict(sslcontext=sslcontext) # App data write buffering self._write_backlog = collections.deque() self._write_buffer_size = 0 self._waiter = waiter self._loop = loop self._set_app_protocol(app_protocol) self._app_transport = None self._app_transport_created = False # transport, ex: SelectorSocketTransport self._transport = None self._ssl_handshake_timeout = ssl_handshake_timeout self._ssl_shutdown_timeout = ssl_shutdown_timeout # SSL and state machine self._incoming = ssl.MemoryBIO() self._outgoing = ssl.MemoryBIO() self._state = SSLProtocolState.UNWRAPPED self._conn_lost = 0 # Set when connection_lost called if call_connection_made: self._app_state = AppProtocolState.STATE_INIT else: self._app_state = AppProtocolState.STATE_CON_MADE self._sslobj = self._sslcontext.wrap_bio( self._incoming, self._outgoing, server_side=self._server_side, server_hostname=self._server_hostname) # Flow Control self._ssl_writing_paused = False self._app_reading_paused = False self._ssl_reading_paused = False self._incoming_high_water = 0 self._incoming_low_water = 0 self._set_read_buffer_limits() self._eof_received = False self._app_writing_paused = False self._outgoing_high_water = 0 self._outgoing_low_water = 0 self._set_write_buffer_limits() self._get_app_transport() def _set_app_protocol(self, app_protocol): self._app_protocol = app_protocol # Make fast hasattr check first if (hasattr(app_protocol, 'get_buffer') and isinstance(app_protocol, protocols.BufferedProtocol)): self._app_protocol_get_buffer = app_protocol.get_buffer self._app_protocol_buffer_updated = app_protocol.buffer_updated self._app_protocol_is_buffer = True else: self._app_protocol_is_buffer = False def _wakeup_waiter(self, exc=None): if self._waiter is None: return if not self._waiter.cancelled(): if exc is not None: self._waiter.set_exception(exc) else: self._waiter.set_result(None) self._waiter = None def _get_app_transport(self): if self._app_transport is None: if self._app_transport_created: raise RuntimeError('Creating _SSLProtocolTransport twice') self._app_transport = _SSLProtocolTransport(self._loop, self) self._app_transport_created = True return self._app_transport def _is_transport_closing(self): return self._transport is not None and self._transport.is_closing() def connection_made(self, transport): """Called when the low-level connection is made. Start the SSL handshake. """ self._transport = transport self._start_handshake() def connection_lost(self, exc): """Called when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). """ self._write_backlog.clear() self._outgoing.read() self._conn_lost += 1 # Just mark the app transport as closed so that its __dealloc__ # doesn't complain. if self._app_transport is not None: self._app_transport._closed = True if self._state != SSLProtocolState.DO_HANDSHAKE: if ( self._app_state == AppProtocolState.STATE_CON_MADE or self._app_state == AppProtocolState.STATE_EOF ): self._app_state = AppProtocolState.STATE_CON_LOST self._loop.call_soon(self._app_protocol.connection_lost, exc) self._set_state(SSLProtocolState.UNWRAPPED) self._transport = None self._app_transport = None self._app_protocol = None self._wakeup_waiter(exc) if self._shutdown_timeout_handle: self._shutdown_timeout_handle.cancel() self._shutdown_timeout_handle = None if self._handshake_timeout_handle: self._handshake_timeout_handle.cancel() self._handshake_timeout_handle = None def get_buffer(self, n): want = n if want <= 0 or want > self.max_size: want = self.max_size if len(self._ssl_buffer) < want: self._ssl_buffer = bytearray(want) self._ssl_buffer_view = memoryview(self._ssl_buffer) return self._ssl_buffer_view def buffer_updated(self, nbytes): self._incoming.write(self._ssl_buffer_view[:nbytes]) if self._state == SSLProtocolState.DO_HANDSHAKE: self._do_handshake() elif self._state == SSLProtocolState.WRAPPED: self._do_read() elif self._state == SSLProtocolState.FLUSHING: self._do_flush() elif self._state == SSLProtocolState.SHUTDOWN: self._do_shutdown() def eof_received(self): """Called when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. """ self._eof_received = True try: if self._loop.get_debug(): logger.debug("%r received EOF", self) if self._state == SSLProtocolState.DO_HANDSHAKE: self._on_handshake_complete(ConnectionResetError) elif self._state == SSLProtocolState.WRAPPED: self._set_state(SSLProtocolState.FLUSHING) if self._app_reading_paused: return True else: self._do_flush() elif self._state == SSLProtocolState.FLUSHING: self._do_write() self._set_state(SSLProtocolState.SHUTDOWN) self._do_shutdown() elif self._state == SSLProtocolState.SHUTDOWN: self._do_shutdown() except Exception: self._transport.close() raise def _get_extra_info(self, name, default=None): if name in self._extra: return self._extra[name] elif self._transport is not None: return self._transport.get_extra_info(name, default) else: return default def _set_state(self, new_state): allowed = False if new_state == SSLProtocolState.UNWRAPPED: allowed = True elif ( self._state == SSLProtocolState.UNWRAPPED and new_state == SSLProtocolState.DO_HANDSHAKE ): allowed = True elif ( self._state == SSLProtocolState.DO_HANDSHAKE and new_state == SSLProtocolState.WRAPPED ): allowed = True elif ( self._state == SSLProtocolState.WRAPPED and new_state == SSLProtocolState.FLUSHING ): allowed = True elif ( self._state == SSLProtocolState.FLUSHING and new_state == SSLProtocolState.SHUTDOWN ): allowed = True if allowed: self._state = new_state else: raise RuntimeError( 'cannot switch state from {} to {}'.format( self._state, new_state)) # Handshake flow def _start_handshake(self): if self._loop.get_debug(): logger.debug("%r starts SSL handshake", self) self._handshake_start_time = self._loop.time() else: self._handshake_start_time = None self._set_state(SSLProtocolState.DO_HANDSHAKE) # start handshake timeout count down self._handshake_timeout_handle = \ self._loop.call_later(self._ssl_handshake_timeout, lambda: self._check_handshake_timeout()) self._do_handshake() def _check_handshake_timeout(self): if self._state == SSLProtocolState.DO_HANDSHAKE: msg = ( f"SSL handshake is taking longer than " f"{self._ssl_handshake_timeout} seconds: " f"aborting the connection" ) self._fatal_error(ConnectionAbortedError(msg)) def _do_handshake(self): try: self._sslobj.do_handshake() except SSLAgainErrors: self._process_outgoing() except ssl.SSLError as exc: self._on_handshake_complete(exc) else: self._on_handshake_complete(None) def _on_handshake_complete(self, handshake_exc): if self._handshake_timeout_handle is not None: self._handshake_timeout_handle.cancel() self._handshake_timeout_handle = None sslobj = self._sslobj try: if handshake_exc is None: self._set_state(SSLProtocolState.WRAPPED) else: raise handshake_exc peercert = sslobj.getpeercert() except Exception as exc: handshake_exc = None self._set_state(SSLProtocolState.UNWRAPPED) if isinstance(exc, ssl.CertificateError): msg = 'SSL handshake failed on verifying the certificate' else: msg = 'SSL handshake failed' self._fatal_error(exc, msg) self._wakeup_waiter(exc) return if self._loop.get_debug(): dt = self._loop.time() - self._handshake_start_time logger.debug("%r: SSL handshake took %.1f ms", self, dt * 1e3) # Add extra info that becomes available after handshake. self._extra.update(peercert=peercert, cipher=sslobj.cipher(), compression=sslobj.compression(), ssl_object=sslobj) if self._app_state == AppProtocolState.STATE_INIT: self._app_state = AppProtocolState.STATE_CON_MADE self._app_protocol.connection_made(self._get_app_transport()) self._wakeup_waiter() self._do_read() # Shutdown flow def _start_shutdown(self): if ( self._state in ( SSLProtocolState.FLUSHING, SSLProtocolState.SHUTDOWN, SSLProtocolState.UNWRAPPED ) ): return if self._app_transport is not None: self._app_transport._closed = True if self._state == SSLProtocolState.DO_HANDSHAKE: self._abort(None) else: self._set_state(SSLProtocolState.FLUSHING) self._shutdown_timeout_handle = self._loop.call_later( self._ssl_shutdown_timeout, lambda: self._check_shutdown_timeout() ) self._do_flush() def _check_shutdown_timeout(self): if ( self._state in ( SSLProtocolState.FLUSHING, SSLProtocolState.SHUTDOWN ) ): self._transport._force_close( exceptions.TimeoutError('SSL shutdown timed out')) def _do_flush(self): self._do_read() self._set_state(SSLProtocolState.SHUTDOWN) self._do_shutdown() def _do_shutdown(self): try: if not self._eof_received: self._sslobj.unwrap() except SSLAgainErrors: self._process_outgoing() except ssl.SSLError as exc: self._on_shutdown_complete(exc) else: self._process_outgoing() self._call_eof_received() self._on_shutdown_complete(None) def _on_shutdown_complete(self, shutdown_exc): if self._shutdown_timeout_handle is not None: self._shutdown_timeout_handle.cancel() self._shutdown_timeout_handle = None if shutdown_exc: self._fatal_error(shutdown_exc) else: self._loop.call_soon(self._transport.close) def _abort(self, exc): self._set_state(SSLProtocolState.UNWRAPPED) if self._transport is not None: self._transport._force_close(exc) # Outgoing flow def _write_appdata(self, list_of_data): if ( self._state in ( SSLProtocolState.FLUSHING, SSLProtocolState.SHUTDOWN, SSLProtocolState.UNWRAPPED ) ): if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('SSL connection is closed') self._conn_lost += 1 return for data in list_of_data: self._write_backlog.append(data) self._write_buffer_size += len(data) try: if self._state == SSLProtocolState.WRAPPED: self._do_write() except Exception as ex: self._fatal_error(ex, 'Fatal error on SSL protocol') def _do_write(self): try: while self._write_backlog: data = self._write_backlog[0] count = self._sslobj.write(data) data_len = len(data) if count < data_len: self._write_backlog[0] = data[count:] self._write_buffer_size -= count else: del self._write_backlog[0] self._write_buffer_size -= data_len except SSLAgainErrors: pass self._process_outgoing() def _process_outgoing(self): if not self._ssl_writing_paused: data = self._outgoing.read() if len(data): self._transport.write(data) self._control_app_writing() # Incoming flow def _do_read(self): if ( self._state not in ( SSLProtocolState.WRAPPED, SSLProtocolState.FLUSHING, ) ): return try: if not self._app_reading_paused: if self._app_protocol_is_buffer: self._do_read__buffered() else: self._do_read__copied() if self._write_backlog: self._do_write() else: self._process_outgoing() self._control_ssl_reading() except Exception as ex: self._fatal_error(ex, 'Fatal error on SSL protocol') def _do_read__buffered(self): offset = 0 count = 1 buf = self._app_protocol_get_buffer(self._get_read_buffer_size()) wants = len(buf) try: count = self._sslobj.read(wants, buf) if count > 0: offset = count while offset < wants: count = self._sslobj.read(wants - offset, buf[offset:]) if count > 0: offset += count else: break else: self._loop.call_soon(lambda: self._do_read()) except SSLAgainErrors: pass if offset > 0: self._app_protocol_buffer_updated(offset) if not count: # close_notify self._call_eof_received() self._start_shutdown() def _do_read__copied(self): chunk = b'1' zero = True one = False try: while True: chunk = self._sslobj.read(self.max_size) if not chunk: break if zero: zero = False one = True first = chunk elif one: one = False data = [first, chunk] else: data.append(chunk) except SSLAgainErrors: pass if one: self._app_protocol.data_received(first) elif not zero: self._app_protocol.data_received(b''.join(data)) if not chunk: # close_notify self._call_eof_received() self._start_shutdown() def _call_eof_received(self): try: if self._app_state == AppProtocolState.STATE_CON_MADE: self._app_state = AppProtocolState.STATE_EOF keep_open = self._app_protocol.eof_received() if keep_open: logger.warning('returning true from eof_received() ' 'has no effect when using ssl') except (KeyboardInterrupt, SystemExit): raise except BaseException as ex: self._fatal_error(ex, 'Error calling eof_received()') # Flow control for writes from APP socket def _control_app_writing(self): size = self._get_write_buffer_size() if size >= self._outgoing_high_water and not self._app_writing_paused: self._app_writing_paused = True try: self._app_protocol.pause_writing() except (KeyboardInterrupt, SystemExit): raise except BaseException as exc: self._loop.call_exception_handler({ 'message': 'protocol.pause_writing() failed', 'exception': exc, 'transport': self._app_transport, 'protocol': self, }) elif size <= self._outgoing_low_water and self._app_writing_paused: self._app_writing_paused = False try: self._app_protocol.resume_writing() except (KeyboardInterrupt, SystemExit): raise except BaseException as exc: self._loop.call_exception_handler({ 'message': 'protocol.resume_writing() failed', 'exception': exc, 'transport': self._app_transport, 'protocol': self, }) def _get_write_buffer_size(self): return self._outgoing.pending + self._write_buffer_size def _set_write_buffer_limits(self, high=None, low=None): high, low = add_flowcontrol_defaults( high, low, constants.FLOW_CONTROL_HIGH_WATER_SSL_WRITE) self._outgoing_high_water = high self._outgoing_low_water = low # Flow control for reads to APP socket def _pause_reading(self): self._app_reading_paused = True def _resume_reading(self): if self._app_reading_paused: self._app_reading_paused = False def resume(): if self._state == SSLProtocolState.WRAPPED: self._do_read() elif self._state == SSLProtocolState.FLUSHING: self._do_flush() elif self._state == SSLProtocolState.SHUTDOWN: self._do_shutdown() self._loop.call_soon(resume) # Flow control for reads from SSL socket def _control_ssl_reading(self): size = self._get_read_buffer_size() if size >= self._incoming_high_water and not self._ssl_reading_paused: self._ssl_reading_paused = True self._transport.pause_reading() elif size <= self._incoming_low_water and self._ssl_reading_paused: self._ssl_reading_paused = False self._transport.resume_reading() def _set_read_buffer_limits(self, high=None, low=None): high, low = add_flowcontrol_defaults( high, low, constants.FLOW_CONTROL_HIGH_WATER_SSL_READ) self._incoming_high_water = high self._incoming_low_water = low def _get_read_buffer_size(self): return self._incoming.pending # Flow control for writes to SSL socket def pause_writing(self): """Called when the low-level transport's buffer goes over the high-water mark. """ assert not self._ssl_writing_paused self._ssl_writing_paused = True def resume_writing(self): """Called when the low-level transport's buffer drains below the low-water mark. """ assert self._ssl_writing_paused self._ssl_writing_paused = False self._process_outgoing() def _fatal_error(self, exc, message='Fatal error on transport'): if self._transport: self._transport._force_close(exc) if isinstance(exc, OSError): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) elif not isinstance(exc, exceptions.CancelledError): self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self._transport, 'protocol': self, }) staggered.py000064400000015645151706172570007111 0ustar00"""Support for running coroutines in parallel with staggered start times.""" __all__ = 'staggered_race', import contextlib from . import events from . import exceptions as exceptions_mod from . import locks from . import tasks async def staggered_race(coro_fns, delay, *, loop=None): """Run coroutines with staggered start times and take the first to finish. This method takes an iterable of coroutine functions. The first one is started immediately. From then on, whenever the immediately preceding one fails (raises an exception), or when *delay* seconds has passed, the next coroutine is started. This continues until one of the coroutines complete successfully, in which case all others are cancelled, or until all coroutines fail. The coroutines provided should be well-behaved in the following way: * They should only ``return`` if completed successfully. * They should always raise an exception if they did not complete successfully. In particular, if they handle cancellation, they should probably reraise, like this:: try: # do work except asyncio.CancelledError: # undo partially completed work raise Args: coro_fns: an iterable of coroutine functions, i.e. callables that return a coroutine object when called. Use ``functools.partial`` or lambdas to pass arguments. delay: amount of time, in seconds, between starting coroutines. If ``None``, the coroutines will run sequentially. loop: the event loop to use. Returns: tuple *(winner_result, winner_index, exceptions)* where - *winner_result*: the result of the winning coroutine, or ``None`` if no coroutines won. - *winner_index*: the index of the winning coroutine in ``coro_fns``, or ``None`` if no coroutines won. If the winning coroutine may return None on success, *winner_index* can be used to definitively determine whether any coroutine won. - *exceptions*: list of exceptions returned by the coroutines. ``len(exceptions)`` is equal to the number of coroutines actually started, and the order is the same as in ``coro_fns``. The winning coroutine's entry is ``None``. """ # TODO: when we have aiter() and anext(), allow async iterables in coro_fns. loop = loop or events.get_running_loop() enum_coro_fns = enumerate(coro_fns) winner_result = None winner_index = None unhandled_exceptions = [] exceptions = [] running_tasks = set() on_completed_fut = None def task_done(task): running_tasks.discard(task) if ( on_completed_fut is not None and not on_completed_fut.done() and not running_tasks ): on_completed_fut.set_result(None) if task.cancelled(): return exc = task.exception() if exc is None: return unhandled_exceptions.append(exc) async def run_one_coro(ok_to_start, previous_failed) -> None: # in eager tasks this waits for the calling task to append this task # to running_tasks, in regular tasks this wait is a no-op that does # not yield a future. See gh-124309. await ok_to_start.wait() # Wait for the previous task to finish, or for delay seconds if previous_failed is not None: with contextlib.suppress(exceptions_mod.TimeoutError): # Use asyncio.wait_for() instead of asyncio.wait() here, so # that if we get cancelled at this point, Event.wait() is also # cancelled, otherwise there will be a "Task destroyed but it is # pending" later. await tasks.wait_for(previous_failed.wait(), delay) # Get the next coroutine to run try: this_index, coro_fn = next(enum_coro_fns) except StopIteration: return # Start task that will run the next coroutine this_failed = locks.Event() next_ok_to_start = locks.Event() next_task = loop.create_task(run_one_coro(next_ok_to_start, this_failed)) running_tasks.add(next_task) next_task.add_done_callback(task_done) # next_task has been appended to running_tasks so next_task is ok to # start. next_ok_to_start.set() # Prepare place to put this coroutine's exceptions if not won exceptions.append(None) assert len(exceptions) == this_index + 1 try: result = await coro_fn() except (SystemExit, KeyboardInterrupt): raise except BaseException as e: exceptions[this_index] = e this_failed.set() # Kickstart the next coroutine else: # Store winner's results nonlocal winner_index, winner_result assert winner_index is None winner_index = this_index winner_result = result # Cancel all other tasks. We take care to not cancel the current # task as well. If we do so, then since there is no `await` after # here and CancelledError are usually thrown at one, we will # encounter a curious corner case where the current task will end # up as done() == True, cancelled() == False, exception() == # asyncio.CancelledError. This behavior is specified in # https://bugs.python.org/issue30048 current_task = tasks.current_task(loop) for t in running_tasks: if t is not current_task: t.cancel() propagate_cancellation_error = None try: ok_to_start = locks.Event() first_task = loop.create_task(run_one_coro(ok_to_start, None)) running_tasks.add(first_task) first_task.add_done_callback(task_done) # first_task has been appended to running_tasks so first_task is ok to start. ok_to_start.set() propagate_cancellation_error = None # Make sure no tasks are left running if we leave this function while running_tasks: on_completed_fut = loop.create_future() try: await on_completed_fut except exceptions_mod.CancelledError as ex: propagate_cancellation_error = ex for task in running_tasks: task.cancel(*ex.args) on_completed_fut = None if __debug__ and unhandled_exceptions: # If run_one_coro raises an unhandled exception, it's probably a # programming error, and I want to see it. raise ExceptionGroup("staggered race failed", unhandled_exceptions) if propagate_cancellation_error is not None: raise propagate_cancellation_error return winner_result, winner_index, exceptions finally: del exceptions, propagate_cancellation_error, unhandled_exceptions streams.py000064400000065743151706172570006626 0ustar00__all__ = ( 'StreamReader', 'StreamWriter', 'StreamReaderProtocol', 'open_connection', 'start_server') import collections import socket import sys import warnings import weakref if hasattr(socket, 'AF_UNIX'): __all__ += ('open_unix_connection', 'start_unix_server') from . import coroutines from . import events from . import exceptions from . import format_helpers from . import protocols from .log import logger from .tasks import sleep _DEFAULT_LIMIT = 2 ** 16 # 64 KiB async def open_connection(host=None, port=None, *, limit=_DEFAULT_LIMIT, **kwds): """A wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) """ loop = events.get_running_loop() reader = StreamReader(limit=limit, loop=loop) protocol = StreamReaderProtocol(reader, loop=loop) transport, _ = await loop.create_connection( lambda: protocol, host, port, **kwds) writer = StreamWriter(transport, protocol, reader, loop) return reader, writer async def start_server(client_connected_cb, host=None, port=None, *, limit=_DEFAULT_LIMIT, **kwds): """Start a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword argument is limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. """ loop = events.get_running_loop() def factory(): reader = StreamReader(limit=limit, loop=loop) protocol = StreamReaderProtocol(reader, client_connected_cb, loop=loop) return protocol return await loop.create_server(factory, host, port, **kwds) if hasattr(socket, 'AF_UNIX'): # UNIX Domain Sockets are supported on this platform async def open_unix_connection(path=None, *, limit=_DEFAULT_LIMIT, **kwds): """Similar to `open_connection` but works with UNIX Domain Sockets.""" loop = events.get_running_loop() reader = StreamReader(limit=limit, loop=loop) protocol = StreamReaderProtocol(reader, loop=loop) transport, _ = await loop.create_unix_connection( lambda: protocol, path, **kwds) writer = StreamWriter(transport, protocol, reader, loop) return reader, writer async def start_unix_server(client_connected_cb, path=None, *, limit=_DEFAULT_LIMIT, **kwds): """Similar to `start_server` but works with UNIX Domain Sockets.""" loop = events.get_running_loop() def factory(): reader = StreamReader(limit=limit, loop=loop) protocol = StreamReaderProtocol(reader, client_connected_cb, loop=loop) return protocol return await loop.create_unix_server(factory, path, **kwds) class FlowControlMixin(protocols.Protocol): """Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_writing() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. """ def __init__(self, loop=None): if loop is None: self._loop = events.get_event_loop() else: self._loop = loop self._paused = False self._drain_waiters = collections.deque() self._connection_lost = False def pause_writing(self): assert not self._paused self._paused = True if self._loop.get_debug(): logger.debug("%r pauses writing", self) def resume_writing(self): assert self._paused self._paused = False if self._loop.get_debug(): logger.debug("%r resumes writing", self) for waiter in self._drain_waiters: if not waiter.done(): waiter.set_result(None) def connection_lost(self, exc): self._connection_lost = True # Wake up the writer(s) if currently paused. if not self._paused: return for waiter in self._drain_waiters: if not waiter.done(): if exc is None: waiter.set_result(None) else: waiter.set_exception(exc) async def _drain_helper(self): if self._connection_lost: raise ConnectionResetError('Connection lost') if not self._paused: return waiter = self._loop.create_future() self._drain_waiters.append(waiter) try: await waiter finally: self._drain_waiters.remove(waiter) def _get_close_waiter(self, stream): raise NotImplementedError class StreamReaderProtocol(FlowControlMixin, protocols.Protocol): """Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) """ _source_traceback = None def __init__(self, stream_reader, client_connected_cb=None, loop=None): super().__init__(loop=loop) if stream_reader is not None: self._stream_reader_wr = weakref.ref(stream_reader) self._source_traceback = stream_reader._source_traceback else: self._stream_reader_wr = None if client_connected_cb is not None: # This is a stream created by the `create_server()` function. # Keep a strong reference to the reader until a connection # is established. self._strong_reader = stream_reader self._reject_connection = False self._stream_writer = None self._task = None self._transport = None self._client_connected_cb = client_connected_cb self._over_ssl = False self._closed = self._loop.create_future() @property def _stream_reader(self): if self._stream_reader_wr is None: return None return self._stream_reader_wr() def _replace_writer(self, writer): loop = self._loop transport = writer.transport self._stream_writer = writer self._transport = transport self._over_ssl = transport.get_extra_info('sslcontext') is not None def connection_made(self, transport): if self._reject_connection: context = { 'message': ('An open stream was garbage collected prior to ' 'establishing network connection; ' 'call "stream.close()" explicitly.') } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) transport.abort() return self._transport = transport reader = self._stream_reader if reader is not None: reader.set_transport(transport) self._over_ssl = transport.get_extra_info('sslcontext') is not None if self._client_connected_cb is not None: self._stream_writer = StreamWriter(transport, self, reader, self._loop) res = self._client_connected_cb(reader, self._stream_writer) if coroutines.iscoroutine(res): def callback(task): if task.cancelled(): transport.close() return exc = task.exception() if exc is not None: self._loop.call_exception_handler({ 'message': 'Unhandled exception in client_connected_cb', 'exception': exc, 'transport': transport, }) transport.close() self._task = self._loop.create_task(res) self._task.add_done_callback(callback) self._strong_reader = None def connection_lost(self, exc): reader = self._stream_reader if reader is not None: if exc is None: reader.feed_eof() else: reader.set_exception(exc) if not self._closed.done(): if exc is None: self._closed.set_result(None) else: self._closed.set_exception(exc) super().connection_lost(exc) self._stream_reader_wr = None self._stream_writer = None self._task = None self._transport = None def data_received(self, data): reader = self._stream_reader if reader is not None: reader.feed_data(data) def eof_received(self): reader = self._stream_reader if reader is not None: reader.feed_eof() if self._over_ssl: # Prevent a warning in SSLProtocol.eof_received: # "returning true from eof_received() # has no effect when using ssl" return False return True def _get_close_waiter(self, stream): return self._closed def __del__(self): # Prevent reports about unhandled exceptions. # Better than self._closed._log_traceback = False hack try: closed = self._closed except AttributeError: pass # failed constructor else: if closed.done() and not closed.cancelled(): closed.exception() class StreamWriter: """Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. """ def __init__(self, transport, protocol, reader, loop): self._transport = transport self._protocol = protocol # drain() expects that the reader has an exception() method assert reader is None or isinstance(reader, StreamReader) self._reader = reader self._loop = loop self._complete_fut = self._loop.create_future() self._complete_fut.set_result(None) def __repr__(self): info = [self.__class__.__name__, f'transport={self._transport!r}'] if self._reader is not None: info.append(f'reader={self._reader!r}') return '<{}>'.format(' '.join(info)) @property def transport(self): return self._transport def write(self, data): self._transport.write(data) def writelines(self, data): self._transport.writelines(data) def write_eof(self): return self._transport.write_eof() def can_write_eof(self): return self._transport.can_write_eof() def close(self): return self._transport.close() def is_closing(self): return self._transport.is_closing() async def wait_closed(self): await self._protocol._get_close_waiter(self) def get_extra_info(self, name, default=None): return self._transport.get_extra_info(name, default) async def drain(self): """Flush the write buffer. The intended use is to write w.write(data) await w.drain() """ if self._reader is not None: exc = self._reader.exception() if exc is not None: raise exc if self._transport.is_closing(): # Wait for protocol.connection_lost() call # Raise connection closing error if any, # ConnectionResetError otherwise # Yield to the event loop so connection_lost() may be # called. Without this, _drain_helper() would return # immediately, and code that calls # write(...); await drain() # in a loop would never call connection_lost(), so it # would not see an error when the socket is closed. await sleep(0) await self._protocol._drain_helper() async def start_tls(self, sslcontext, *, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): """Upgrade an existing stream-based connection to TLS.""" server_side = self._protocol._client_connected_cb is not None protocol = self._protocol await self.drain() new_transport = await self._loop.start_tls( # type: ignore self._transport, protocol, sslcontext, server_side=server_side, server_hostname=server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) self._transport = new_transport protocol._replace_writer(self) def __del__(self): if not self._transport.is_closing(): if self._loop.is_closed(): warnings.warn("loop is closed", ResourceWarning) else: self.close() warnings.warn(f"unclosed {self!r}", ResourceWarning) class StreamReader: _source_traceback = None def __init__(self, limit=_DEFAULT_LIMIT, loop=None): # The line length limit is a security feature; # it also doubles as half the buffer limit. if limit <= 0: raise ValueError('Limit cannot be <= 0') self._limit = limit if loop is None: self._loop = events.get_event_loop() else: self._loop = loop self._buffer = bytearray() self._eof = False # Whether we're done. self._waiter = None # A future used by _wait_for_data() self._exception = None self._transport = None self._paused = False if self._loop.get_debug(): self._source_traceback = format_helpers.extract_stack( sys._getframe(1)) def __repr__(self): info = ['StreamReader'] if self._buffer: info.append(f'{len(self._buffer)} bytes') if self._eof: info.append('eof') if self._limit != _DEFAULT_LIMIT: info.append(f'limit={self._limit}') if self._waiter: info.append(f'waiter={self._waiter!r}') if self._exception: info.append(f'exception={self._exception!r}') if self._transport: info.append(f'transport={self._transport!r}') if self._paused: info.append('paused') return '<{}>'.format(' '.join(info)) def exception(self): return self._exception def set_exception(self, exc): self._exception = exc waiter = self._waiter if waiter is not None: self._waiter = None if not waiter.cancelled(): waiter.set_exception(exc) def _wakeup_waiter(self): """Wakeup read*() functions waiting for data or EOF.""" waiter = self._waiter if waiter is not None: self._waiter = None if not waiter.cancelled(): waiter.set_result(None) def set_transport(self, transport): assert self._transport is None, 'Transport already set' self._transport = transport def _maybe_resume_transport(self): if self._paused and len(self._buffer) <= self._limit: self._paused = False self._transport.resume_reading() def feed_eof(self): self._eof = True self._wakeup_waiter() def at_eof(self): """Return True if the buffer is empty and 'feed_eof' was called.""" return self._eof and not self._buffer def feed_data(self, data): assert not self._eof, 'feed_data after feed_eof' if not data: return self._buffer.extend(data) self._wakeup_waiter() if (self._transport is not None and not self._paused and len(self._buffer) > 2 * self._limit): try: self._transport.pause_reading() except NotImplementedError: # The transport can't be paused. # We'll just have to buffer all data. # Forget the transport so we don't keep trying. self._transport = None else: self._paused = True async def _wait_for_data(self, func_name): """Wait until feed_data() or feed_eof() is called. If stream was paused, automatically resume it. """ # StreamReader uses a future to link the protocol feed_data() method # to a read coroutine. Running two read coroutines at the same time # would have an unexpected behaviour. It would not possible to know # which coroutine would get the next data. if self._waiter is not None: raise RuntimeError( f'{func_name}() called while another coroutine is ' f'already waiting for incoming data') assert not self._eof, '_wait_for_data after EOF' # Waiting for data while paused will make deadlock, so prevent it. # This is essential for readexactly(n) for case when n > self._limit. if self._paused: self._paused = False self._transport.resume_reading() self._waiter = self._loop.create_future() try: await self._waiter finally: self._waiter = None async def readline(self): """Read chunk of data from the stream until newline (b'\n') is found. On success, return chunk that ends with newline. If only partial line can be read due to EOF, return incomplete line without terminating newline. When EOF was reached while no bytes read, empty bytes object is returned. If limit is reached, ValueError will be raised. In that case, if newline was found, complete line including newline will be removed from internal buffer. Else, internal buffer will be cleared. Limit is compared against part of the line without newline. If stream was paused, this function will automatically resume it if needed. """ sep = b'\n' seplen = len(sep) try: line = await self.readuntil(sep) except exceptions.IncompleteReadError as e: return e.partial except exceptions.LimitOverrunError as e: if self._buffer.startswith(sep, e.consumed): del self._buffer[:e.consumed + seplen] else: self._buffer.clear() self._maybe_resume_transport() raise ValueError(e.args[0]) return line async def readuntil(self, separator=b'\n'): """Read data from the stream until ``separator`` is found. On success, the data and separator will be removed from the internal buffer (consumed). Returned data will include the separator at the end. Configured stream limit is used to check result. Limit sets the maximal length of data that can be returned, not counting the separator. If an EOF occurs and the complete separator is still not found, an IncompleteReadError exception will be raised, and the internal buffer will be reset. The IncompleteReadError.partial attribute may contain the separator partially. If the data cannot be read because of over limit, a LimitOverrunError exception will be raised, and the data will be left in the internal buffer, so it can be read again. """ seplen = len(separator) if seplen == 0: raise ValueError('Separator should be at least one-byte string') if self._exception is not None: raise self._exception # Consume whole buffer except last bytes, which length is # one less than seplen. Let's check corner cases with # separator='SEPARATOR': # * we have received almost complete separator (without last # byte). i.e buffer='some textSEPARATO'. In this case we # can safely consume len(separator) - 1 bytes. # * last byte of buffer is first byte of separator, i.e. # buffer='abcdefghijklmnopqrS'. We may safely consume # everything except that last byte, but this require to # analyze bytes of buffer that match partial separator. # This is slow and/or require FSM. For this case our # implementation is not optimal, since require rescanning # of data that is known to not belong to separator. In # real world, separator will not be so long to notice # performance problems. Even when reading MIME-encoded # messages :) # `offset` is the number of bytes from the beginning of the buffer # where there is no occurrence of `separator`. offset = 0 # Loop until we find `separator` in the buffer, exceed the buffer size, # or an EOF has happened. while True: buflen = len(self._buffer) # Check if we now have enough data in the buffer for `separator` to # fit. if buflen - offset >= seplen: isep = self._buffer.find(separator, offset) if isep != -1: # `separator` is in the buffer. `isep` will be used later # to retrieve the data. break # see upper comment for explanation. offset = buflen + 1 - seplen if offset > self._limit: raise exceptions.LimitOverrunError( 'Separator is not found, and chunk exceed the limit', offset) # Complete message (with full separator) may be present in buffer # even when EOF flag is set. This may happen when the last chunk # adds data which makes separator be found. That's why we check for # EOF *ater* inspecting the buffer. if self._eof: chunk = bytes(self._buffer) self._buffer.clear() raise exceptions.IncompleteReadError(chunk, None) # _wait_for_data() will resume reading if stream was paused. await self._wait_for_data('readuntil') if isep > self._limit: raise exceptions.LimitOverrunError( 'Separator is found, but chunk is longer than limit', isep) chunk = self._buffer[:isep + seplen] del self._buffer[:isep + seplen] self._maybe_resume_transport() return bytes(chunk) async def read(self, n=-1): """Read up to `n` bytes from the stream. If `n` is not provided or set to -1, read until EOF, then return all read bytes. If EOF was received and the internal buffer is empty, return an empty bytes object. If `n` is 0, return an empty bytes object immediately. If `n` is positive, return at most `n` available bytes as soon as at least 1 byte is available in the internal buffer. If EOF is received before any byte is read, return an empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. """ if self._exception is not None: raise self._exception if n == 0: return b'' if n < 0: # This used to just loop creating a new waiter hoping to # collect everything in self._buffer, but that would # deadlock if the subprocess sends more than self.limit # bytes. So just call self.read(self._limit) until EOF. blocks = [] while True: block = await self.read(self._limit) if not block: break blocks.append(block) return b''.join(blocks) if not self._buffer and not self._eof: await self._wait_for_data('read') # This will work right even if buffer is less than n bytes data = bytes(memoryview(self._buffer)[:n]) del self._buffer[:n] self._maybe_resume_transport() return data async def readexactly(self, n): """Read exactly `n` bytes. Raise an IncompleteReadError if EOF is reached before `n` bytes can be read. The IncompleteReadError.partial attribute of the exception will contain the partial read bytes. if n is zero, return empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. """ if n < 0: raise ValueError('readexactly size can not be less than zero') if self._exception is not None: raise self._exception if n == 0: return b'' while len(self._buffer) < n: if self._eof: incomplete = bytes(self._buffer) self._buffer.clear() raise exceptions.IncompleteReadError(incomplete, n) await self._wait_for_data('readexactly') if len(self._buffer) == n: data = bytes(self._buffer) self._buffer.clear() else: data = bytes(memoryview(self._buffer)[:n]) del self._buffer[:n] self._maybe_resume_transport() return data def __aiter__(self): return self async def __anext__(self): val = await self.readline() if val == b'': raise StopAsyncIteration return val subprocess.py000064400000017071151706172570007327 0ustar00__all__ = 'create_subprocess_exec', 'create_subprocess_shell' import subprocess from . import events from . import protocols from . import streams from . import tasks from .log import logger PIPE = subprocess.PIPE STDOUT = subprocess.STDOUT DEVNULL = subprocess.DEVNULL class SubprocessStreamProtocol(streams.FlowControlMixin, protocols.SubprocessProtocol): """Like StreamReaderProtocol, but for a subprocess.""" def __init__(self, limit, loop): super().__init__(loop=loop) self._limit = limit self.stdin = self.stdout = self.stderr = None self._transport = None self._process_exited = False self._pipe_fds = [] self._stdin_closed = self._loop.create_future() def __repr__(self): info = [self.__class__.__name__] if self.stdin is not None: info.append(f'stdin={self.stdin!r}') if self.stdout is not None: info.append(f'stdout={self.stdout!r}') if self.stderr is not None: info.append(f'stderr={self.stderr!r}') return '<{}>'.format(' '.join(info)) def connection_made(self, transport): self._transport = transport stdout_transport = transport.get_pipe_transport(1) if stdout_transport is not None: self.stdout = streams.StreamReader(limit=self._limit, loop=self._loop) self.stdout.set_transport(stdout_transport) self._pipe_fds.append(1) stderr_transport = transport.get_pipe_transport(2) if stderr_transport is not None: self.stderr = streams.StreamReader(limit=self._limit, loop=self._loop) self.stderr.set_transport(stderr_transport) self._pipe_fds.append(2) stdin_transport = transport.get_pipe_transport(0) if stdin_transport is not None: self.stdin = streams.StreamWriter(stdin_transport, protocol=self, reader=None, loop=self._loop) def pipe_data_received(self, fd, data): if fd == 1: reader = self.stdout elif fd == 2: reader = self.stderr else: reader = None if reader is not None: reader.feed_data(data) def pipe_connection_lost(self, fd, exc): if fd == 0: pipe = self.stdin if pipe is not None: pipe.close() self.connection_lost(exc) if exc is None: self._stdin_closed.set_result(None) else: self._stdin_closed.set_exception(exc) # Since calling `wait_closed()` is not mandatory, # we shouldn't log the traceback if this is not awaited. self._stdin_closed._log_traceback = False return if fd == 1: reader = self.stdout elif fd == 2: reader = self.stderr else: reader = None if reader is not None: if exc is None: reader.feed_eof() else: reader.set_exception(exc) if fd in self._pipe_fds: self._pipe_fds.remove(fd) self._maybe_close_transport() def process_exited(self): self._process_exited = True self._maybe_close_transport() def _maybe_close_transport(self): if len(self._pipe_fds) == 0 and self._process_exited: self._transport.close() self._transport = None def _get_close_waiter(self, stream): if stream is self.stdin: return self._stdin_closed class Process: def __init__(self, transport, protocol, loop): self._transport = transport self._protocol = protocol self._loop = loop self.stdin = protocol.stdin self.stdout = protocol.stdout self.stderr = protocol.stderr self.pid = transport.get_pid() def __repr__(self): return f'<{self.__class__.__name__} {self.pid}>' @property def returncode(self): return self._transport.get_returncode() async def wait(self): """Wait until the process exit and return the process return code.""" return await self._transport._wait() def send_signal(self, signal): self._transport.send_signal(signal) def terminate(self): self._transport.terminate() def kill(self): self._transport.kill() async def _feed_stdin(self, input): debug = self._loop.get_debug() try: if input is not None: self.stdin.write(input) if debug: logger.debug( '%r communicate: feed stdin (%s bytes)', self, len(input)) await self.stdin.drain() except (BrokenPipeError, ConnectionResetError) as exc: # communicate() ignores BrokenPipeError and ConnectionResetError. # write() and drain() can raise these exceptions. if debug: logger.debug('%r communicate: stdin got %r', self, exc) if debug: logger.debug('%r communicate: close stdin', self) self.stdin.close() async def _noop(self): return None async def _read_stream(self, fd): transport = self._transport.get_pipe_transport(fd) if fd == 2: stream = self.stderr else: assert fd == 1 stream = self.stdout if self._loop.get_debug(): name = 'stdout' if fd == 1 else 'stderr' logger.debug('%r communicate: read %s', self, name) output = await stream.read() if self._loop.get_debug(): name = 'stdout' if fd == 1 else 'stderr' logger.debug('%r communicate: close %s', self, name) transport.close() return output async def communicate(self, input=None): if self.stdin is not None: stdin = self._feed_stdin(input) else: stdin = self._noop() if self.stdout is not None: stdout = self._read_stream(1) else: stdout = self._noop() if self.stderr is not None: stderr = self._read_stream(2) else: stderr = self._noop() stdin, stdout, stderr = await tasks.gather(stdin, stdout, stderr) await self.wait() return (stdout, stderr) async def create_subprocess_shell(cmd, stdin=None, stdout=None, stderr=None, limit=streams._DEFAULT_LIMIT, **kwds): loop = events.get_running_loop() protocol_factory = lambda: SubprocessStreamProtocol(limit=limit, loop=loop) transport, protocol = await loop.subprocess_shell( protocol_factory, cmd, stdin=stdin, stdout=stdout, stderr=stderr, **kwds) return Process(transport, protocol, loop) async def create_subprocess_exec(program, *args, stdin=None, stdout=None, stderr=None, limit=streams._DEFAULT_LIMIT, **kwds): loop = events.get_running_loop() protocol_factory = lambda: SubprocessStreamProtocol(limit=limit, loop=loop) transport, protocol = await loop.subprocess_exec( protocol_factory, program, *args, stdin=stdin, stdout=stdout, stderr=stderr, **kwds) return Process(transport, protocol, loop) taskgroups.py000064400000022527151706172570007343 0ustar00# Adapted with permission from the EdgeDB project; # license: PSFL. __all__ = ("TaskGroup",) from . import events from . import exceptions from . import tasks class TaskGroup: """Asynchronous context manager for managing groups of tasks. Example use: async with asyncio.TaskGroup() as group: task1 = group.create_task(some_coroutine(...)) task2 = group.create_task(other_coroutine(...)) print("Both tasks have completed now.") All tasks are awaited when the context manager exits. Any exceptions other than `asyncio.CancelledError` raised within a task will cancel all remaining tasks and wait for them to exit. The exceptions are then combined and raised as an `ExceptionGroup`. """ def __init__(self): self._entered = False self._exiting = False self._aborting = False self._loop = None self._parent_task = None self._parent_cancel_requested = False self._tasks = set() self._errors = [] self._base_error = None self._on_completed_fut = None def __repr__(self): info = [''] if self._tasks: info.append(f'tasks={len(self._tasks)}') if self._errors: info.append(f'errors={len(self._errors)}') if self._aborting: info.append('cancelling') elif self._entered: info.append('entered') info_str = ' '.join(info) return f'<TaskGroup{info_str}>' async def __aenter__(self): if self._entered: raise RuntimeError( f"TaskGroup {self!r} has already been entered") if self._loop is None: self._loop = events.get_running_loop() self._parent_task = tasks.current_task(self._loop) if self._parent_task is None: raise RuntimeError( f'TaskGroup {self!r} cannot determine the parent task') self._entered = True return self async def __aexit__(self, et, exc, tb): tb = None try: return await self._aexit(et, exc) finally: # Exceptions are heavy objects that can have object # cycles (bad for GC); let's not keep a reference to # a bunch of them. It would be nicer to use a try/finally # in __aexit__ directly but that introduced some diff noise self._parent_task = None self._errors = None self._base_error = None exc = None async def _aexit(self, et, exc): self._exiting = True if (exc is not None and self._is_base_error(exc) and self._base_error is None): self._base_error = exc propagate_cancellation_error = \ exc if et is exceptions.CancelledError else None if self._parent_cancel_requested: # If this flag is set we *must* call uncancel(). if self._parent_task.uncancel() == 0: # If there are no pending cancellations left, # don't propagate CancelledError. propagate_cancellation_error = None if et is not None: if not self._aborting: # Our parent task is being cancelled: # # async with TaskGroup() as g: # g.create_task(...) # await ... # <- CancelledError # # or there's an exception in "async with": # # async with TaskGroup() as g: # g.create_task(...) # 1 / 0 # self._abort() # We use while-loop here because "self._on_completed_fut" # can be cancelled multiple times if our parent task # is being cancelled repeatedly (or even once, when # our own cancellation is already in progress) while self._tasks: if self._on_completed_fut is None: self._on_completed_fut = self._loop.create_future() try: await self._on_completed_fut except exceptions.CancelledError as ex: if not self._aborting: # Our parent task is being cancelled: # # async def wrapper(): # async with TaskGroup() as g: # g.create_task(foo) # # "wrapper" is being cancelled while "foo" is # still running. propagate_cancellation_error = ex self._abort() self._on_completed_fut = None assert not self._tasks if self._base_error is not None: try: raise self._base_error finally: exc = None # Propagate CancelledError if there is one, except if there # are other errors -- those have priority. try: if propagate_cancellation_error and not self._errors: try: raise propagate_cancellation_error finally: exc = None finally: propagate_cancellation_error = None if et is not None and et is not exceptions.CancelledError: self._errors.append(exc) if self._errors: try: raise BaseExceptionGroup( 'unhandled errors in a TaskGroup', self._errors, ) from None finally: exc = None def create_task(self, coro, *, name=None, context=None): """Create a new task in this group and return it. Similar to `asyncio.create_task`. """ if not self._entered: raise RuntimeError(f"TaskGroup {self!r} has not been entered") if self._exiting and not self._tasks: raise RuntimeError(f"TaskGroup {self!r} is finished") if self._aborting: raise RuntimeError(f"TaskGroup {self!r} is shutting down") if context is None: task = self._loop.create_task(coro) else: task = self._loop.create_task(coro, context=context) tasks._set_task_name(task, name) # Always schedule the done callback even if the task is # already done (e.g. if the coro was able to complete eagerly), # otherwise if the task completes with an exception then it will cancel # the current task too early. gh-128550, gh-128588 self._tasks.add(task) task.add_done_callback(self._on_task_done) try: return task finally: # gh-128552: prevent a refcycle of # task.exception().__traceback__->TaskGroup.create_task->task del task # Since Python 3.8 Tasks propagate all exceptions correctly, # except for KeyboardInterrupt and SystemExit which are # still considered special. def _is_base_error(self, exc: BaseException) -> bool: assert isinstance(exc, BaseException) return isinstance(exc, (SystemExit, KeyboardInterrupt)) def _abort(self): self._aborting = True for t in self._tasks: if not t.done(): t.cancel() def _on_task_done(self, task): self._tasks.discard(task) if self._on_completed_fut is not None and not self._tasks: if not self._on_completed_fut.done(): self._on_completed_fut.set_result(True) if task.cancelled(): return exc = task.exception() if exc is None: return self._errors.append(exc) if self._is_base_error(exc) and self._base_error is None: self._base_error = exc if self._parent_task.done(): # Not sure if this case is possible, but we want to handle # it anyways. self._loop.call_exception_handler({ 'message': f'Task {task!r} has errored out but its parent ' f'task {self._parent_task} is already completed', 'exception': exc, 'task': task, }) return if not self._aborting and not self._parent_cancel_requested: # If parent task *is not* being cancelled, it means that we want # to manually cancel it to abort whatever is being run right now # in the TaskGroup. But we want to mark parent task as # "not cancelled" later in __aexit__. Example situation that # we need to handle: # # async def foo(): # try: # async with TaskGroup() as g: # g.create_task(crash_soon()) # await something # <- this needs to be canceled # # by the TaskGroup, e.g. # # foo() needs to be cancelled # except Exception: # # Ignore any exceptions raised in the TaskGroup # pass # await something_else # this line has to be called # # after TaskGroup is finished. self._abort() self._parent_cancel_requested = True self._parent_task.cancel() tasks.py000064400000110762151706172570006265 0ustar00"""Support for tasks, coroutines and the scheduler.""" __all__ = ( 'Task', 'create_task', 'FIRST_COMPLETED', 'FIRST_EXCEPTION', 'ALL_COMPLETED', 'wait', 'wait_for', 'as_completed', 'sleep', 'gather', 'shield', 'ensure_future', 'run_coroutine_threadsafe', 'current_task', 'all_tasks', 'create_eager_task_factory', 'eager_task_factory', '_register_task', '_unregister_task', '_enter_task', '_leave_task', ) import concurrent.futures import contextvars import functools import inspect import itertools import types import warnings import weakref from types import GenericAlias from . import base_tasks from . import coroutines from . import events from . import exceptions from . import futures from . import timeouts # Helper to generate new task names # This uses itertools.count() instead of a "+= 1" operation because the latter # is not thread safe. See bpo-11866 for a longer explanation. _task_name_counter = itertools.count(1).__next__ def current_task(loop=None): """Return a currently executed task.""" if loop is None: loop = events.get_running_loop() return _current_tasks.get(loop) def all_tasks(loop=None): """Return a set of all tasks for the loop.""" if loop is None: loop = events.get_running_loop() # capturing the set of eager tasks first, so if an eager task "graduates" # to a regular task in another thread, we don't risk missing it. eager_tasks = list(_eager_tasks) # Looping over the WeakSet isn't safe as it can be updated from another # thread, therefore we cast it to list prior to filtering. The list cast # itself requires iteration, so we repeat it several times ignoring # RuntimeErrors (which are not very likely to occur). # See issues 34970 and 36607 for details. scheduled_tasks = None i = 0 while True: try: scheduled_tasks = list(_scheduled_tasks) except RuntimeError: i += 1 if i >= 1000: raise else: break return {t for t in itertools.chain(scheduled_tasks, eager_tasks) if futures._get_loop(t) is loop and not t.done()} def _set_task_name(task, name): if name is not None: try: set_name = task.set_name except AttributeError: warnings.warn("Task.set_name() was added in Python 3.8, " "the method support will be mandatory for third-party " "task implementations since 3.13.", DeprecationWarning, stacklevel=3) else: set_name(name) class Task(futures._PyFuture): # Inherit Python Task implementation # from a Python Future implementation. """A coroutine wrapped in a Future.""" # An important invariant maintained while a Task not done: # _fut_waiter is either None or a Future. The Future # can be either done() or not done(). # The task can be in any of 3 states: # # - 1: _fut_waiter is not None and not _fut_waiter.done(): # __step() is *not* scheduled and the Task is waiting for _fut_waiter. # - 2: (_fut_waiter is None or _fut_waiter.done()) and __step() is scheduled: # the Task is waiting for __step() to be executed. # - 3: _fut_waiter is None and __step() is *not* scheduled: # the Task is currently executing (in __step()). # # * In state 1, one of the callbacks of __fut_waiter must be __wakeup(). # * The transition from 1 to 2 happens when _fut_waiter becomes done(), # as it schedules __wakeup() to be called (which calls __step() so # we way that __step() is scheduled). # * It transitions from 2 to 3 when __step() is executed, and it clears # _fut_waiter to None. # If False, don't log a message if the task is destroyed while its # status is still pending _log_destroy_pending = True def __init__(self, coro, *, loop=None, name=None, context=None, eager_start=False): super().__init__(loop=loop) if self._source_traceback: del self._source_traceback[-1] if not coroutines.iscoroutine(coro): # raise after Future.__init__(), attrs are required for __del__ # prevent logging for pending task in __del__ self._log_destroy_pending = False raise TypeError(f"a coroutine was expected, got {coro!r}") if name is None: self._name = f'Task-{_task_name_counter()}' else: self._name = str(name) self._num_cancels_requested = 0 self._must_cancel = False self._fut_waiter = None self._coro = coro if context is None: self._context = contextvars.copy_context() else: self._context = context if eager_start and self._loop.is_running(): self.__eager_start() else: self._loop.call_soon(self.__step, context=self._context) _register_task(self) def __del__(self): if self._state == futures._PENDING and self._log_destroy_pending: context = { 'task': self, 'message': 'Task was destroyed but it is pending!', } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) super().__del__() __class_getitem__ = classmethod(GenericAlias) def __repr__(self): return base_tasks._task_repr(self) def get_coro(self): return self._coro def get_context(self): return self._context def get_name(self): return self._name def set_name(self, value): self._name = str(value) def set_result(self, result): raise RuntimeError('Task does not support set_result operation') def set_exception(self, exception): raise RuntimeError('Task does not support set_exception operation') def get_stack(self, *, limit=None): """Return the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. """ return base_tasks._task_get_stack(self, limit) def print_stack(self, *, limit=None, file=None): """Print the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. """ return base_tasks._task_print_stack(self, limit, file) def cancel(self, msg=None): """Request that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). This also increases the task's count of cancellation requests. """ self._log_traceback = False if self.done(): return False self._num_cancels_requested += 1 # These two lines are controversial. See discussion starting at # https://github.com/python/cpython/pull/31394#issuecomment-1053545331 # Also remember that this is duplicated in _asynciomodule.c. # if self._num_cancels_requested > 1: # return False if self._fut_waiter is not None: if self._fut_waiter.cancel(msg=msg): # Leave self._fut_waiter; it may be a Task that # catches and ignores the cancellation so we may have # to cancel it again later. return True # It must be the case that self.__step is already scheduled. self._must_cancel = True self._cancel_message = msg return True def cancelling(self): """Return the count of the task's cancellation requests. This count is incremented when .cancel() is called and may be decremented using .uncancel(). """ return self._num_cancels_requested def uncancel(self): """Decrement the task's count of cancellation requests. This should be called by the party that called `cancel()` on the task beforehand. Returns the remaining number of cancellation requests. """ if self._num_cancels_requested > 0: self._num_cancels_requested -= 1 return self._num_cancels_requested def __eager_start(self): prev_task = _swap_current_task(self._loop, self) try: _register_eager_task(self) try: self._context.run(self.__step_run_and_handle_result, None) finally: _unregister_eager_task(self) finally: try: curtask = _swap_current_task(self._loop, prev_task) assert curtask is self finally: if self.done(): self._coro = None self = None # Needed to break cycles when an exception occurs. else: _register_task(self) def __step(self, exc=None): if self.done(): raise exceptions.InvalidStateError( f'_step(): already done: {self!r}, {exc!r}') if self._must_cancel: if not isinstance(exc, exceptions.CancelledError): exc = self._make_cancelled_error() self._must_cancel = False self._fut_waiter = None _enter_task(self._loop, self) try: self.__step_run_and_handle_result(exc) finally: _leave_task(self._loop, self) self = None # Needed to break cycles when an exception occurs. def __step_run_and_handle_result(self, exc): coro = self._coro try: if exc is None: # We use the `send` method directly, because coroutines # don't have `__iter__` and `__next__` methods. result = coro.send(None) else: result = coro.throw(exc) except StopIteration as exc: if self._must_cancel: # Task is cancelled right before coro stops. self._must_cancel = False super().cancel(msg=self._cancel_message) else: super().set_result(exc.value) except exceptions.CancelledError as exc: # Save the original exception so we can chain it later. self._cancelled_exc = exc super().cancel() # I.e., Future.cancel(self). except (KeyboardInterrupt, SystemExit) as exc: super().set_exception(exc) raise except BaseException as exc: super().set_exception(exc) else: blocking = getattr(result, '_asyncio_future_blocking', None) if blocking is not None: # Yielded Future must come from Future.__iter__(). if futures._get_loop(result) is not self._loop: new_exc = RuntimeError( f'Task {self!r} got Future ' f'{result!r} attached to a different loop') self._loop.call_soon( self.__step, new_exc, context=self._context) elif blocking: if result is self: new_exc = RuntimeError( f'Task cannot await on itself: {self!r}') self._loop.call_soon( self.__step, new_exc, context=self._context) else: result._asyncio_future_blocking = False result.add_done_callback( self.__wakeup, context=self._context) self._fut_waiter = result if self._must_cancel: if self._fut_waiter.cancel( msg=self._cancel_message): self._must_cancel = False else: new_exc = RuntimeError( f'yield was used instead of yield from ' f'in task {self!r} with {result!r}') self._loop.call_soon( self.__step, new_exc, context=self._context) elif result is None: # Bare yield relinquishes control for one event loop iteration. self._loop.call_soon(self.__step, context=self._context) elif inspect.isgenerator(result): # Yielding a generator is just wrong. new_exc = RuntimeError( f'yield was used instead of yield from for ' f'generator in task {self!r} with {result!r}') self._loop.call_soon( self.__step, new_exc, context=self._context) else: # Yielding something else is an error. new_exc = RuntimeError(f'Task got bad yield: {result!r}') self._loop.call_soon( self.__step, new_exc, context=self._context) finally: self = None # Needed to break cycles when an exception occurs. def __wakeup(self, future): try: future.result() except BaseException as exc: # This may also be a cancellation. self.__step(exc) else: # Don't pass the value of `future.result()` explicitly, # as `Future.__iter__` and `Future.__await__` don't need it. # If we call `_step(value, None)` instead of `_step()`, # Python eval loop would use `.send(value)` method call, # instead of `__next__()`, which is slower for futures # that return non-generator iterators from their `__iter__`. self.__step() self = None # Needed to break cycles when an exception occurs. _PyTask = Task try: import _asyncio except ImportError: pass else: # _CTask is needed for tests. Task = _CTask = _asyncio.Task def create_task(coro, *, name=None, context=None): """Schedule the execution of a coroutine object in a spawn task. Return a Task object. """ loop = events.get_running_loop() if context is None: # Use legacy API if context is not needed task = loop.create_task(coro) else: task = loop.create_task(coro, context=context) _set_task_name(task, name) return task # wait() and as_completed() similar to those in PEP 3148. FIRST_COMPLETED = concurrent.futures.FIRST_COMPLETED FIRST_EXCEPTION = concurrent.futures.FIRST_EXCEPTION ALL_COMPLETED = concurrent.futures.ALL_COMPLETED async def wait(fs, *, timeout=None, return_when=ALL_COMPLETED): """Wait for the Futures or Tasks given by fs to complete. The fs iterable must not be empty. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending). Usage: done, pending = await asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. """ if futures.isfuture(fs) or coroutines.iscoroutine(fs): raise TypeError(f"expect a list of futures, not {type(fs).__name__}") if not fs: raise ValueError('Set of Tasks/Futures is empty.') if return_when not in (FIRST_COMPLETED, FIRST_EXCEPTION, ALL_COMPLETED): raise ValueError(f'Invalid return_when value: {return_when}') fs = set(fs) if any(coroutines.iscoroutine(f) for f in fs): raise TypeError("Passing coroutines is forbidden, use tasks explicitly.") loop = events.get_running_loop() return await _wait(fs, timeout, return_when, loop) def _release_waiter(waiter, *args): if not waiter.done(): waiter.set_result(None) async def wait_for(fut, timeout): """Wait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. If the task suppresses the cancellation and returns a value instead, that value is returned. This function is a coroutine. """ # The special case for timeout <= 0 is for the following case: # # async def test_waitfor(): # func_started = False # # async def func(): # nonlocal func_started # func_started = True # # try: # await asyncio.wait_for(func(), 0) # except asyncio.TimeoutError: # assert not func_started # else: # assert False # # asyncio.run(test_waitfor()) if timeout is not None and timeout <= 0: fut = ensure_future(fut) if fut.done(): return fut.result() await _cancel_and_wait(fut) try: return fut.result() except exceptions.CancelledError as exc: raise TimeoutError from exc async with timeouts.timeout(timeout): return await fut async def _wait(fs, timeout, return_when, loop): """Internal helper for wait(). The fs argument must be a collection of Futures. """ assert fs, 'Set of Futures is empty.' waiter = loop.create_future() timeout_handle = None if timeout is not None: timeout_handle = loop.call_later(timeout, _release_waiter, waiter) counter = len(fs) def _on_completion(f): nonlocal counter counter -= 1 if (counter <= 0 or return_when == FIRST_COMPLETED or return_when == FIRST_EXCEPTION and (not f.cancelled() and f.exception() is not None)): if timeout_handle is not None: timeout_handle.cancel() if not waiter.done(): waiter.set_result(None) for f in fs: f.add_done_callback(_on_completion) try: await waiter finally: if timeout_handle is not None: timeout_handle.cancel() for f in fs: f.remove_done_callback(_on_completion) done, pending = set(), set() for f in fs: if f.done(): done.add(f) else: pending.add(f) return done, pending async def _cancel_and_wait(fut): """Cancel the *fut* future or task and wait until it completes.""" loop = events.get_running_loop() waiter = loop.create_future() cb = functools.partial(_release_waiter, waiter) fut.add_done_callback(cb) try: fut.cancel() # We cannot wait on *fut* directly to make # sure _cancel_and_wait itself is reliably cancellable. await waiter finally: fut.remove_done_callback(cb) # This is *not* a @coroutine! It is just an iterator (yielding Futures). def as_completed(fs, *, timeout=None): """Return an iterator whose values are coroutines. When waiting for the yielded coroutines you'll get the results (or exceptions!) of the original Futures (or coroutines), in the order in which and as soon as they complete. This differs from PEP 3148; the proper way to use this is: for f in as_completed(fs): result = await f # The 'await' may raise. # Use result. If a timeout is specified, the 'await' will raise TimeoutError when the timeout occurs before all Futures are done. Note: The futures 'f' are not necessarily members of fs. """ if futures.isfuture(fs) or coroutines.iscoroutine(fs): raise TypeError(f"expect an iterable of futures, not {type(fs).__name__}") from .queues import Queue # Import here to avoid circular import problem. done = Queue() loop = events.get_event_loop() todo = {ensure_future(f, loop=loop) for f in set(fs)} timeout_handle = None def _on_timeout(): for f in todo: f.remove_done_callback(_on_completion) done.put_nowait(None) # Queue a dummy value for _wait_for_one(). todo.clear() # Can't do todo.remove(f) in the loop. def _on_completion(f): if not todo: return # _on_timeout() was here first. todo.remove(f) done.put_nowait(f) if not todo and timeout_handle is not None: timeout_handle.cancel() async def _wait_for_one(): f = await done.get() if f is None: # Dummy value from _on_timeout(). raise exceptions.TimeoutError return f.result() # May raise f.exception(). for f in todo: f.add_done_callback(_on_completion) if todo and timeout is not None: timeout_handle = loop.call_later(timeout, _on_timeout) for _ in range(len(todo)): yield _wait_for_one() @types.coroutine def __sleep0(): """Skip one event loop run cycle. This is a private helper for 'asyncio.sleep()', used when the 'delay' is set to 0. It uses a bare 'yield' expression (which Task.__step knows how to handle) instead of creating a Future object. """ yield async def sleep(delay, result=None): """Coroutine that completes after a given time (in seconds).""" if delay <= 0: await __sleep0() return result loop = events.get_running_loop() future = loop.create_future() h = loop.call_later(delay, futures._set_result_unless_cancelled, future, result) try: return await future finally: h.cancel() def ensure_future(coro_or_future, *, loop=None): """Wrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. """ if futures.isfuture(coro_or_future): if loop is not None and loop is not futures._get_loop(coro_or_future): raise ValueError('The future belongs to a different loop than ' 'the one specified as the loop argument') return coro_or_future should_close = True if not coroutines.iscoroutine(coro_or_future): if inspect.isawaitable(coro_or_future): async def _wrap_awaitable(awaitable): return await awaitable coro_or_future = _wrap_awaitable(coro_or_future) should_close = False else: raise TypeError('An asyncio.Future, a coroutine or an awaitable ' 'is required') if loop is None: loop = events.get_event_loop() try: return loop.create_task(coro_or_future) except RuntimeError: if should_close: coro_or_future.close() raise class _GatheringFuture(futures.Future): """Helper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. """ def __init__(self, children, *, loop): assert loop is not None super().__init__(loop=loop) self._children = children self._cancel_requested = False def cancel(self, msg=None): if self.done(): return False ret = False for child in self._children: if child.cancel(msg=msg): ret = True if ret: # If any child tasks were actually cancelled, we should # propagate the cancellation request regardless of # *return_exceptions* argument. See issue 32684. self._cancel_requested = True return ret def gather(*coros_or_futures, return_exceptions=False): """Return a future aggregating results from the given coroutines/futures. Coroutines will be wrapped in a future and scheduled in the event loop. They will not necessarily be scheduled in the same order as passed in. All futures must share the same event loop. If all the tasks are done successfully, the returned future's result is the list of results (in the order of the original sequence, not necessarily the order of results arrival). If *return_exceptions* is True, exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first raised exception will be immediately propagated to the returned future. Cancellation: if the outer Future is cancelled, all children (that have not completed yet) are also cancelled. If any child is cancelled, this is treated as if it raised CancelledError -- the outer Future is *not* cancelled in this case. (This is to prevent the cancellation of one child to cause other children to be cancelled.) If *return_exceptions* is False, cancelling gather() after it has been marked done won't cancel any submitted awaitables. For instance, gather can be marked done after propagating an exception to the caller, therefore, calling ``gather.cancel()`` after catching an exception (raised by one of the awaitables) from gather won't cancel any other awaitables. """ if not coros_or_futures: loop = events.get_event_loop() outer = loop.create_future() outer.set_result([]) return outer def _done_callback(fut): nonlocal nfinished nfinished += 1 if outer is None or outer.done(): if not fut.cancelled(): # Mark exception retrieved. fut.exception() return if not return_exceptions: if fut.cancelled(): # Check if 'fut' is cancelled first, as # 'fut.exception()' will *raise* a CancelledError # instead of returning it. exc = fut._make_cancelled_error() outer.set_exception(exc) return else: exc = fut.exception() if exc is not None: outer.set_exception(exc) return if nfinished == nfuts: # All futures are done; create a list of results # and set it to the 'outer' future. results = [] for fut in children: if fut.cancelled(): # Check if 'fut' is cancelled first, as 'fut.exception()' # will *raise* a CancelledError instead of returning it. # Also, since we're adding the exception return value # to 'results' instead of raising it, don't bother # setting __context__. This also lets us preserve # calling '_make_cancelled_error()' at most once. res = exceptions.CancelledError( '' if fut._cancel_message is None else fut._cancel_message) else: res = fut.exception() if res is None: res = fut.result() results.append(res) if outer._cancel_requested: # If gather is being cancelled we must propagate the # cancellation regardless of *return_exceptions* argument. # See issue 32684. exc = fut._make_cancelled_error() outer.set_exception(exc) else: outer.set_result(results) arg_to_fut = {} children = [] nfuts = 0 nfinished = 0 done_futs = [] loop = None outer = None # bpo-46672 for arg in coros_or_futures: if arg not in arg_to_fut: fut = ensure_future(arg, loop=loop) if loop is None: loop = futures._get_loop(fut) if fut is not arg: # 'arg' was not a Future, therefore, 'fut' is a new # Future created specifically for 'arg'. Since the caller # can't control it, disable the "destroy pending task" # warning. fut._log_destroy_pending = False nfuts += 1 arg_to_fut[arg] = fut if fut.done(): done_futs.append(fut) else: fut.add_done_callback(_done_callback) else: # There's a duplicate Future object in coros_or_futures. fut = arg_to_fut[arg] children.append(fut) outer = _GatheringFuture(children, loop=loop) # Run done callbacks after GatheringFuture created so any post-processing # can be performed at this point # optimization: in the special case that *all* futures finished eagerly, # this will effectively complete the gather eagerly, with the last # callback setting the result (or exception) on outer before returning it for fut in done_futs: _done_callback(fut) return outer def shield(arg): """Wait for a future, shielding it from cancellation. The statement task = asyncio.create_task(something()) res = await shield(task) is exactly equivalent to the statement res = await something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: task = asyncio.create_task(something()) try: res = await shield(task) except CancelledError: res = None Save a reference to tasks passed to this function, to avoid a task disappearing mid-execution. The event loop only keeps weak references to tasks. A task that isn't referenced elsewhere may get garbage collected at any time, even before it's done. """ inner = ensure_future(arg) if inner.done(): # Shortcut. return inner loop = futures._get_loop(inner) outer = loop.create_future() def _inner_done_callback(inner): if outer.cancelled(): if not inner.cancelled(): # Mark inner's result as retrieved. inner.exception() return if inner.cancelled(): outer.cancel() else: exc = inner.exception() if exc is not None: outer.set_exception(exc) else: outer.set_result(inner.result()) def _outer_done_callback(outer): if not inner.done(): inner.remove_done_callback(_inner_done_callback) inner.add_done_callback(_inner_done_callback) outer.add_done_callback(_outer_done_callback) return outer def run_coroutine_threadsafe(coro, loop): """Submit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. """ if not coroutines.iscoroutine(coro): raise TypeError('A coroutine object is required') future = concurrent.futures.Future() def callback(): try: futures._chain_future(ensure_future(coro, loop=loop), future) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: if future.set_running_or_notify_cancel(): future.set_exception(exc) raise loop.call_soon_threadsafe(callback) return future def create_eager_task_factory(custom_task_constructor): """Create a function suitable for use as a task factory on an event-loop. Example usage: loop.set_task_factory( asyncio.create_eager_task_factory(my_task_constructor)) Now, tasks created will be started immediately (rather than being first scheduled to an event loop). The constructor argument can be any callable that returns a Task-compatible object and has a signature compatible with `Task.__init__`; it must have the `eager_start` keyword argument. Most applications will use `Task` for `custom_task_constructor` and in this case there's no need to call `create_eager_task_factory()` directly. Instead the global `eager_task_factory` instance can be used. E.g. `loop.set_task_factory(asyncio.eager_task_factory)`. """ def factory(loop, coro, *, name=None, context=None): return custom_task_constructor( coro, loop=loop, name=name, context=context, eager_start=True) return factory eager_task_factory = create_eager_task_factory(Task) # Collectively these two sets hold references to the complete set of active # tasks. Eagerly executed tasks use a faster regular set as an optimization # but may graduate to a WeakSet if the task blocks on IO. _scheduled_tasks = weakref.WeakSet() _eager_tasks = set() # Dictionary containing tasks that are currently active in # all running event loops. {EventLoop: Task} _current_tasks = {} def _register_task(task): """Register an asyncio Task scheduled to run on an event loop.""" _scheduled_tasks.add(task) def _register_eager_task(task): """Register an asyncio Task about to be eagerly executed.""" _eager_tasks.add(task) def _enter_task(loop, task): current_task = _current_tasks.get(loop) if current_task is not None: raise RuntimeError(f"Cannot enter into task {task!r} while another " f"task {current_task!r} is being executed.") _current_tasks[loop] = task def _leave_task(loop, task): current_task = _current_tasks.get(loop) if current_task is not task: raise RuntimeError(f"Leaving task {task!r} does not match " f"the current task {current_task!r}.") del _current_tasks[loop] def _swap_current_task(loop, task): prev_task = _current_tasks.get(loop) if task is None: del _current_tasks[loop] else: _current_tasks[loop] = task return prev_task def _unregister_task(task): """Unregister a completed, scheduled Task.""" _scheduled_tasks.discard(task) def _unregister_eager_task(task): """Unregister a task which finished its first eager step.""" _eager_tasks.discard(task) _py_current_task = current_task _py_register_task = _register_task _py_register_eager_task = _register_eager_task _py_unregister_task = _unregister_task _py_unregister_eager_task = _unregister_eager_task _py_enter_task = _enter_task _py_leave_task = _leave_task _py_swap_current_task = _swap_current_task try: from _asyncio import (_register_task, _register_eager_task, _unregister_task, _unregister_eager_task, _enter_task, _leave_task, _swap_current_task, _scheduled_tasks, _eager_tasks, _current_tasks, current_task) except ImportError: pass else: _c_current_task = current_task _c_register_task = _register_task _c_register_eager_task = _register_eager_task _c_unregister_task = _unregister_task _c_unregister_eager_task = _unregister_eager_task _c_enter_task = _enter_task _c_leave_task = _leave_task _c_swap_current_task = _swap_current_task threads.py000064400000001426151706172570006566 0ustar00"""High-level support for working with threads in asyncio""" import functools import contextvars from . import events __all__ = "to_thread", async def to_thread(func, /, *args, **kwargs): """Asynchronously run function *func* in a separate thread. Any *args and **kwargs supplied for this function are directly passed to *func*. Also, the current :class:`contextvars.Context` is propagated, allowing context variables from the main thread to be accessed in the separate thread. Return a coroutine that can be awaited to get the eventual result of *func*. """ loop = events.get_running_loop() ctx = contextvars.copy_context() func_call = functools.partial(ctx.run, func, *args, **kwargs) return await loop.run_in_executor(None, func_call) timeouts.py000064400000012311151706172570007000 0ustar00import enum from types import TracebackType from typing import final, Optional, Type from . import events from . import exceptions from . import tasks __all__ = ( "Timeout", "timeout", "timeout_at", ) class _State(enum.Enum): CREATED = "created" ENTERED = "active" EXPIRING = "expiring" EXPIRED = "expired" EXITED = "finished" @final class Timeout: """Asynchronous context manager for cancelling overdue coroutines. Use `timeout()` or `timeout_at()` rather than instantiating this class directly. """ def __init__(self, when: Optional[float]) -> None: """Schedule a timeout that will trigger at a given loop time. - If `when` is `None`, the timeout will never trigger. - If `when < loop.time()`, the timeout will trigger on the next iteration of the event loop. """ self._state = _State.CREATED self._timeout_handler: Optional[events.TimerHandle] = None self._task: Optional[tasks.Task] = None self._when = when def when(self) -> Optional[float]: """Return the current deadline.""" return self._when def reschedule(self, when: Optional[float]) -> None: """Reschedule the timeout.""" if self._state is not _State.ENTERED: if self._state is _State.CREATED: raise RuntimeError("Timeout has not been entered") raise RuntimeError( f"Cannot change state of {self._state.value} Timeout", ) self._when = when if self._timeout_handler is not None: self._timeout_handler.cancel() if when is None: self._timeout_handler = None else: loop = events.get_running_loop() if when <= loop.time(): self._timeout_handler = loop.call_soon(self._on_timeout) else: self._timeout_handler = loop.call_at(when, self._on_timeout) def expired(self) -> bool: """Is timeout expired during execution?""" return self._state in (_State.EXPIRING, _State.EXPIRED) def __repr__(self) -> str: info = [''] if self._state is _State.ENTERED: when = round(self._when, 3) if self._when is not None else None info.append(f"when={when}") info_str = ' '.join(info) return f"<Timeout [{self._state.value}]{info_str}>" async def __aenter__(self) -> "Timeout": if self._state is not _State.CREATED: raise RuntimeError("Timeout has already been entered") task = tasks.current_task() if task is None: raise RuntimeError("Timeout should be used inside a task") self._state = _State.ENTERED self._task = task self._cancelling = self._task.cancelling() self.reschedule(self._when) return self async def __aexit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType], ) -> Optional[bool]: assert self._state in (_State.ENTERED, _State.EXPIRING) if self._timeout_handler is not None: self._timeout_handler.cancel() self._timeout_handler = None if self._state is _State.EXPIRING: self._state = _State.EXPIRED if self._task.uncancel() <= self._cancelling and exc_type is exceptions.CancelledError: # Since there are no new cancel requests, we're # handling this. raise TimeoutError from exc_val elif self._state is _State.ENTERED: self._state = _State.EXITED return None def _on_timeout(self) -> None: assert self._state is _State.ENTERED self._task.cancel() self._state = _State.EXPIRING # drop the reference early self._timeout_handler = None def timeout(delay: Optional[float]) -> Timeout: """Timeout async context manager. Useful in cases when you want to apply timeout logic around block of code or in cases when asyncio.wait_for is not suitable. For example: >>> async with asyncio.timeout(10): # 10 seconds timeout ... await long_running_task() delay - value in seconds or None to disable timeout logic long_running_task() is interrupted by raising asyncio.CancelledError, the top-most affected timeout() context manager converts CancelledError into TimeoutError. """ loop = events.get_running_loop() return Timeout(loop.time() + delay if delay is not None else None) def timeout_at(when: Optional[float]) -> Timeout: """Schedule the timeout at absolute time. Like timeout() but argument gives absolute time in the same clock system as loop.time(). Please note: it is not POSIX time but a time with undefined starting base, e.g. the time of the system power on. >>> async with asyncio.timeout_at(loop.time() + 10): ... await long_running_task() when - a deadline when timeout occurs or None to disable timeout logic long_running_task() is interrupted by raising asyncio.CancelledError, the top-most affected timeout() context manager converts CancelledError into TimeoutError. """ return Timeout(when) transports.py000064400000024742151706172570007361 0ustar00"""Abstract Transport class.""" __all__ = ( 'BaseTransport', 'ReadTransport', 'WriteTransport', 'Transport', 'DatagramTransport', 'SubprocessTransport', ) class BaseTransport: """Base class for transports.""" __slots__ = ('_extra',) def __init__(self, extra=None): if extra is None: extra = {} self._extra = extra def get_extra_info(self, name, default=None): """Get optional transport information.""" return self._extra.get(name, default) def is_closing(self): """Return True if the transport is closing or closed.""" raise NotImplementedError def close(self): """Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) be called with None as its argument. """ raise NotImplementedError def set_protocol(self, protocol): """Set a new protocol.""" raise NotImplementedError def get_protocol(self): """Return the current protocol.""" raise NotImplementedError class ReadTransport(BaseTransport): """Interface for read-only transports.""" __slots__ = () def is_reading(self): """Return True if the transport is receiving.""" raise NotImplementedError def pause_reading(self): """Pause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. """ raise NotImplementedError def resume_reading(self): """Resume the receiving end. Data received will once again be passed to the protocol's data_received() method. """ raise NotImplementedError class WriteTransport(BaseTransport): """Interface for write-only transports.""" __slots__ = () def set_write_buffer_limits(self, high=None, low=None): """Set the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. """ raise NotImplementedError def get_write_buffer_size(self): """Return the current size of the write buffer.""" raise NotImplementedError def get_write_buffer_limits(self): """Get the high and low watermarks for write flow control. Return a tuple (low, high) where low and high are positive number of bytes.""" raise NotImplementedError def write(self, data): """Write some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. """ raise NotImplementedError def writelines(self, list_of_data): """Write a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. """ data = b''.join(list_of_data) self.write(data) def write_eof(self): """Close the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. """ raise NotImplementedError def can_write_eof(self): """Return True if this transport supports write_eof(), False if not.""" raise NotImplementedError def abort(self): """Close the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. """ raise NotImplementedError class Transport(ReadTransport, WriteTransport): """Interface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. """ __slots__ = () class DatagramTransport(BaseTransport): """Interface for datagram (UDP) transports.""" __slots__ = () def sendto(self, data, addr=None): """Send data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. """ raise NotImplementedError def abort(self): """Close the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. """ raise NotImplementedError class SubprocessTransport(BaseTransport): __slots__ = () def get_pid(self): """Get subprocess id.""" raise NotImplementedError def get_returncode(self): """Get subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode """ raise NotImplementedError def get_pipe_transport(self, fd): """Get transport for pipe with number fd.""" raise NotImplementedError def send_signal(self, signal): """Send signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal """ raise NotImplementedError def terminate(self): """Stop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate """ raise NotImplementedError def kill(self): """Kill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill """ raise NotImplementedError class _FlowControlMixin(Transport): """All the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. """ __slots__ = ('_loop', '_protocol_paused', '_high_water', '_low_water') def __init__(self, extra=None, loop=None): super().__init__(extra) assert loop is not None self._loop = loop self._protocol_paused = False self._set_write_buffer_limits() def _maybe_pause_protocol(self): size = self.get_write_buffer_size() if size <= self._high_water: return if not self._protocol_paused: self._protocol_paused = True try: self._protocol.pause_writing() except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._loop.call_exception_handler({ 'message': 'protocol.pause_writing() failed', 'exception': exc, 'transport': self, 'protocol': self._protocol, }) def _maybe_resume_protocol(self): if (self._protocol_paused and self.get_write_buffer_size() <= self._low_water): self._protocol_paused = False try: self._protocol.resume_writing() except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._loop.call_exception_handler({ 'message': 'protocol.resume_writing() failed', 'exception': exc, 'transport': self, 'protocol': self._protocol, }) def get_write_buffer_limits(self): return (self._low_water, self._high_water) def _set_write_buffer_limits(self, high=None, low=None): if high is None: if low is None: high = 64 * 1024 else: high = 4 * low if low is None: low = high // 4 if not high >= low >= 0: raise ValueError( f'high ({high!r}) must be >= low ({low!r}) must be >= 0') self._high_water = high self._low_water = low def set_write_buffer_limits(self, high=None, low=None): self._set_write_buffer_limits(high=high, low=low) self._maybe_pause_protocol() def get_write_buffer_size(self): raise NotImplementedError trsock.py000064400000004653151706172570006446 0ustar00import socket class TransportSocket: """A socket-like wrapper for exposing real transport sockets. These objects can be safely returned by APIs like `transport.get_extra_info('socket')`. All potentially disruptive operations (like "socket.close()") are banned. """ __slots__ = ('_sock',) def __init__(self, sock: socket.socket): self._sock = sock @property def family(self): return self._sock.family @property def type(self): return self._sock.type @property def proto(self): return self._sock.proto def __repr__(self): s = ( f"<asyncio.TransportSocket fd={self.fileno()}, " f"family={self.family!s}, type={self.type!s}, " f"proto={self.proto}" ) if self.fileno() != -1: try: laddr = self.getsockname() if laddr: s = f"{s}, laddr={laddr}" except socket.error: pass try: raddr = self.getpeername() if raddr: s = f"{s}, raddr={raddr}" except socket.error: pass return f"{s}>" def __getstate__(self): raise TypeError("Cannot serialize asyncio.TransportSocket object") def fileno(self): return self._sock.fileno() def dup(self): return self._sock.dup() def get_inheritable(self): return self._sock.get_inheritable() def shutdown(self, how): # asyncio doesn't currently provide a high-level transport API # to shutdown the connection. self._sock.shutdown(how) def getsockopt(self, *args, **kwargs): return self._sock.getsockopt(*args, **kwargs) def setsockopt(self, *args, **kwargs): self._sock.setsockopt(*args, **kwargs) def getpeername(self): return self._sock.getpeername() def getsockname(self): return self._sock.getsockname() def getsockbyname(self): return self._sock.getsockbyname() def settimeout(self, value): if value == 0: return raise ValueError( 'settimeout(): only 0 timeout is allowed on transport sockets') def gettimeout(self): return 0 def setblocking(self, flag): if not flag: return raise ValueError( 'setblocking(): transport sockets cannot be blocking') unix_events.py000064400000147604151706172570007514 0ustar00"""Selector event loop for Unix with signal handling.""" import errno import io import itertools import os import selectors import signal import socket import stat import subprocess import sys import threading import warnings from . import base_events from . import base_subprocess from . import constants from . import coroutines from . import events from . import exceptions from . import futures from . import selector_events from . import tasks from . import transports from .log import logger __all__ = ( 'SelectorEventLoop', 'AbstractChildWatcher', 'SafeChildWatcher', 'FastChildWatcher', 'PidfdChildWatcher', 'MultiLoopChildWatcher', 'ThreadedChildWatcher', 'DefaultEventLoopPolicy', ) if sys.platform == 'win32': # pragma: no cover raise ImportError('Signals are not really supported on Windows') def _sighandler_noop(signum, frame): """Dummy signal handler.""" pass def waitstatus_to_exitcode(status): try: return os.waitstatus_to_exitcode(status) except ValueError: # The child exited, but we don't understand its status. # This shouldn't happen, but if it does, let's just # return that status; perhaps that helps debug it. return status class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop): """Unix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. """ def __init__(self, selector=None): super().__init__(selector) self._signal_handlers = {} def close(self): super().close() if not sys.is_finalizing(): for sig in list(self._signal_handlers): self.remove_signal_handler(sig) else: if self._signal_handlers: warnings.warn(f"Closing the loop {self!r} " f"on interpreter shutdown " f"stage, skipping signal handlers removal", ResourceWarning, source=self) self._signal_handlers.clear() def _process_self_data(self, data): for signum in data: if not signum: # ignore null bytes written by _write_to_self() continue self._handle_signal(signum) def add_signal_handler(self, sig, callback, *args): """Add a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. """ if (coroutines.iscoroutine(callback) or coroutines.iscoroutinefunction(callback)): raise TypeError("coroutines cannot be used " "with add_signal_handler()") self._check_signal(sig) self._check_closed() try: # set_wakeup_fd() raises ValueError if this is not the # main thread. By calling it early we ensure that an # event loop running in another thread cannot add a signal # handler. signal.set_wakeup_fd(self._csock.fileno()) except (ValueError, OSError) as exc: raise RuntimeError(str(exc)) handle = events.Handle(callback, args, self, None) self._signal_handlers[sig] = handle try: # Register a dummy signal handler to ask Python to write the signal # number in the wakeup file descriptor. _process_self_data() will # read signal numbers from this file descriptor to handle signals. signal.signal(sig, _sighandler_noop) # Set SA_RESTART to limit EINTR occurrences. signal.siginterrupt(sig, False) except OSError as exc: del self._signal_handlers[sig] if not self._signal_handlers: try: signal.set_wakeup_fd(-1) except (ValueError, OSError) as nexc: logger.info('set_wakeup_fd(-1) failed: %s', nexc) if exc.errno == errno.EINVAL: raise RuntimeError(f'sig {sig} cannot be caught') else: raise def _handle_signal(self, sig): """Internal helper that is the actual signal handler.""" handle = self._signal_handlers.get(sig) if handle is None: return # Assume it's some race condition. if handle._cancelled: self.remove_signal_handler(sig) # Remove it properly. else: self._add_callback_signalsafe(handle) def remove_signal_handler(self, sig): """Remove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. """ self._check_signal(sig) try: del self._signal_handlers[sig] except KeyError: return False if sig == signal.SIGINT: handler = signal.default_int_handler else: handler = signal.SIG_DFL try: signal.signal(sig, handler) except OSError as exc: if exc.errno == errno.EINVAL: raise RuntimeError(f'sig {sig} cannot be caught') else: raise if not self._signal_handlers: try: signal.set_wakeup_fd(-1) except (ValueError, OSError) as exc: logger.info('set_wakeup_fd(-1) failed: %s', exc) return True def _check_signal(self, sig): """Internal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. """ if not isinstance(sig, int): raise TypeError(f'sig must be an int, not {sig!r}') if sig not in signal.valid_signals(): raise ValueError(f'invalid signal number {sig}') def _make_read_pipe_transport(self, pipe, protocol, waiter=None, extra=None): return _UnixReadPipeTransport(self, pipe, protocol, waiter, extra) def _make_write_pipe_transport(self, pipe, protocol, waiter=None, extra=None): return _UnixWritePipeTransport(self, pipe, protocol, waiter, extra) async def _make_subprocess_transport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, extra=None, **kwargs): with warnings.catch_warnings(): warnings.simplefilter('ignore', DeprecationWarning) watcher = events.get_child_watcher() with watcher: if not watcher.is_active(): # Check early. # Raising exception before process creation # prevents subprocess execution if the watcher # is not ready to handle it. raise RuntimeError("asyncio.get_child_watcher() is not activated, " "subprocess support is not installed.") waiter = self.create_future() transp = _UnixSubprocessTransport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, waiter=waiter, extra=extra, **kwargs) watcher.add_child_handler(transp.get_pid(), self._child_watcher_callback, transp) try: await waiter except (SystemExit, KeyboardInterrupt): raise except BaseException: transp.close() await transp._wait() raise return transp def _child_watcher_callback(self, pid, returncode, transp): self.call_soon_threadsafe(transp._process_exited, returncode) async def create_unix_connection( self, protocol_factory, path=None, *, ssl=None, sock=None, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): assert server_hostname is None or isinstance(server_hostname, str) if ssl: if server_hostname is None: raise ValueError( 'you have to pass server_hostname when using ssl') else: if server_hostname is not None: raise ValueError('server_hostname is only meaningful with ssl') if ssl_handshake_timeout is not None: raise ValueError( 'ssl_handshake_timeout is only meaningful with ssl') if ssl_shutdown_timeout is not None: raise ValueError( 'ssl_shutdown_timeout is only meaningful with ssl') if path is not None: if sock is not None: raise ValueError( 'path and sock can not be specified at the same time') path = os.fspath(path) sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0) try: sock.setblocking(False) await self.sock_connect(sock, path) except: sock.close() raise else: if sock is None: raise ValueError('no path and sock were specified') if (sock.family != socket.AF_UNIX or sock.type != socket.SOCK_STREAM): raise ValueError( f'A UNIX Domain Stream Socket was expected, got {sock!r}') sock.setblocking(False) transport, protocol = await self._create_connection_transport( sock, protocol_factory, ssl, server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) return transport, protocol async def create_unix_server( self, protocol_factory, path=None, *, sock=None, backlog=100, ssl=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, start_serving=True): if isinstance(ssl, bool): raise TypeError('ssl argument must be an SSLContext or None') if ssl_handshake_timeout is not None and not ssl: raise ValueError( 'ssl_handshake_timeout is only meaningful with ssl') if ssl_shutdown_timeout is not None and not ssl: raise ValueError( 'ssl_shutdown_timeout is only meaningful with ssl') if path is not None: if sock is not None: raise ValueError( 'path and sock can not be specified at the same time') path = os.fspath(path) sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) # Check for abstract socket. `str` and `bytes` paths are supported. if path[0] not in (0, '\x00'): try: if stat.S_ISSOCK(os.stat(path).st_mode): os.remove(path) except FileNotFoundError: pass except OSError as err: # Directory may have permissions only to create socket. logger.error('Unable to check or remove stale UNIX socket ' '%r: %r', path, err) try: sock.bind(path) except OSError as exc: sock.close() if exc.errno == errno.EADDRINUSE: # Let's improve the error message by adding # with what exact address it occurs. msg = f'Address {path!r} is already in use' raise OSError(errno.EADDRINUSE, msg) from None else: raise except: sock.close() raise else: if sock is None: raise ValueError( 'path was not specified, and no sock specified') if (sock.family != socket.AF_UNIX or sock.type != socket.SOCK_STREAM): raise ValueError( f'A UNIX Domain Stream Socket was expected, got {sock!r}') sock.setblocking(False) server = base_events.Server(self, [sock], protocol_factory, ssl, backlog, ssl_handshake_timeout, ssl_shutdown_timeout) if start_serving: server._start_serving() # Skip one loop iteration so that all 'loop.add_reader' # go through. await tasks.sleep(0) return server async def _sock_sendfile_native(self, sock, file, offset, count): try: os.sendfile except AttributeError: raise exceptions.SendfileNotAvailableError( "os.sendfile() is not available") try: fileno = file.fileno() except (AttributeError, io.UnsupportedOperation) as err: raise exceptions.SendfileNotAvailableError("not a regular file") try: fsize = os.fstat(fileno).st_size except OSError: raise exceptions.SendfileNotAvailableError("not a regular file") blocksize = count if count else fsize if not blocksize: return 0 # empty file fut = self.create_future() self._sock_sendfile_native_impl(fut, None, sock, fileno, offset, count, blocksize, 0) return await fut def _sock_sendfile_native_impl(self, fut, registered_fd, sock, fileno, offset, count, blocksize, total_sent): fd = sock.fileno() if registered_fd is not None: # Remove the callback early. It should be rare that the # selector says the fd is ready but the call still returns # EAGAIN, and I am willing to take a hit in that case in # order to simplify the common case. self.remove_writer(registered_fd) if fut.cancelled(): self._sock_sendfile_update_filepos(fileno, offset, total_sent) return if count: blocksize = count - total_sent if blocksize <= 0: self._sock_sendfile_update_filepos(fileno, offset, total_sent) fut.set_result(total_sent) return try: sent = os.sendfile(fd, fileno, offset, blocksize) except (BlockingIOError, InterruptedError): if registered_fd is None: self._sock_add_cancellation_callback(fut, sock) self.add_writer(fd, self._sock_sendfile_native_impl, fut, fd, sock, fileno, offset, count, blocksize, total_sent) except OSError as exc: if (registered_fd is not None and exc.errno == errno.ENOTCONN and type(exc) is not ConnectionError): # If we have an ENOTCONN and this isn't a first call to # sendfile(), i.e. the connection was closed in the middle # of the operation, normalize the error to ConnectionError # to make it consistent across all Posix systems. new_exc = ConnectionError( "socket is not connected", errno.ENOTCONN) new_exc.__cause__ = exc exc = new_exc if total_sent == 0: # We can get here for different reasons, the main # one being 'file' is not a regular mmap(2)-like # file, in which case we'll fall back on using # plain send(). err = exceptions.SendfileNotAvailableError( "os.sendfile call failed") self._sock_sendfile_update_filepos(fileno, offset, total_sent) fut.set_exception(err) else: self._sock_sendfile_update_filepos(fileno, offset, total_sent) fut.set_exception(exc) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._sock_sendfile_update_filepos(fileno, offset, total_sent) fut.set_exception(exc) else: if sent == 0: # EOF self._sock_sendfile_update_filepos(fileno, offset, total_sent) fut.set_result(total_sent) else: offset += sent total_sent += sent if registered_fd is None: self._sock_add_cancellation_callback(fut, sock) self.add_writer(fd, self._sock_sendfile_native_impl, fut, fd, sock, fileno, offset, count, blocksize, total_sent) def _sock_sendfile_update_filepos(self, fileno, offset, total_sent): if total_sent > 0: os.lseek(fileno, offset, os.SEEK_SET) def _sock_add_cancellation_callback(self, fut, sock): def cb(fut): if fut.cancelled(): fd = sock.fileno() if fd != -1: self.remove_writer(fd) fut.add_done_callback(cb) class _UnixReadPipeTransport(transports.ReadTransport): max_size = 256 * 1024 # max bytes we read in one event loop iteration def __init__(self, loop, pipe, protocol, waiter=None, extra=None): super().__init__(extra) self._extra['pipe'] = pipe self._loop = loop self._pipe = pipe self._fileno = pipe.fileno() self._protocol = protocol self._closing = False self._paused = False mode = os.fstat(self._fileno).st_mode if not (stat.S_ISFIFO(mode) or stat.S_ISSOCK(mode) or stat.S_ISCHR(mode)): self._pipe = None self._fileno = None self._protocol = None raise ValueError("Pipe transport is for pipes/sockets only.") os.set_blocking(self._fileno, False) self._loop.call_soon(self._protocol.connection_made, self) # only start reading when connection_made() has been called self._loop.call_soon(self._add_reader, self._fileno, self._read_ready) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) def _add_reader(self, fd, callback): if not self.is_reading(): return self._loop._add_reader(fd, callback) def is_reading(self): return not self._paused and not self._closing def __repr__(self): info = [self.__class__.__name__] if self._pipe is None: info.append('closed') elif self._closing: info.append('closing') info.append(f'fd={self._fileno}') selector = getattr(self._loop, '_selector', None) if self._pipe is not None and selector is not None: polling = selector_events._test_selector_event( selector, self._fileno, selectors.EVENT_READ) if polling: info.append('polling') else: info.append('idle') elif self._pipe is not None: info.append('open') else: info.append('closed') return '<{}>'.format(' '.join(info)) def _read_ready(self): try: data = os.read(self._fileno, self.max_size) except (BlockingIOError, InterruptedError): pass except OSError as exc: self._fatal_error(exc, 'Fatal read error on pipe transport') else: if data: self._protocol.data_received(data) else: if self._loop.get_debug(): logger.info("%r was closed by peer", self) self._closing = True self._loop._remove_reader(self._fileno) self._loop.call_soon(self._protocol.eof_received) self._loop.call_soon(self._call_connection_lost, None) def pause_reading(self): if not self.is_reading(): return self._paused = True self._loop._remove_reader(self._fileno) if self._loop.get_debug(): logger.debug("%r pauses reading", self) def resume_reading(self): if self._closing or not self._paused: return self._paused = False self._loop._add_reader(self._fileno, self._read_ready) if self._loop.get_debug(): logger.debug("%r resumes reading", self) def set_protocol(self, protocol): self._protocol = protocol def get_protocol(self): return self._protocol def is_closing(self): return self._closing def close(self): if not self._closing: self._close(None) def __del__(self, _warn=warnings.warn): if self._pipe is not None: _warn(f"unclosed transport {self!r}", ResourceWarning, source=self) self._pipe.close() def _fatal_error(self, exc, message='Fatal error on pipe transport'): # should be called by exception handler only if (isinstance(exc, OSError) and exc.errno == errno.EIO): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) self._close(exc) def _close(self, exc): self._closing = True self._loop._remove_reader(self._fileno) self._loop.call_soon(self._call_connection_lost, exc) def _call_connection_lost(self, exc): try: self._protocol.connection_lost(exc) finally: self._pipe.close() self._pipe = None self._protocol = None self._loop = None class _UnixWritePipeTransport(transports._FlowControlMixin, transports.WriteTransport): def __init__(self, loop, pipe, protocol, waiter=None, extra=None): super().__init__(extra, loop) self._extra['pipe'] = pipe self._pipe = pipe self._fileno = pipe.fileno() self._protocol = protocol self._buffer = bytearray() self._conn_lost = 0 self._closing = False # Set when close() or write_eof() called. mode = os.fstat(self._fileno).st_mode is_char = stat.S_ISCHR(mode) is_fifo = stat.S_ISFIFO(mode) is_socket = stat.S_ISSOCK(mode) if not (is_char or is_fifo or is_socket): self._pipe = None self._fileno = None self._protocol = None raise ValueError("Pipe transport is only for " "pipes, sockets and character devices") os.set_blocking(self._fileno, False) self._loop.call_soon(self._protocol.connection_made, self) # On AIX, the reader trick (to be notified when the read end of the # socket is closed) only works for sockets. On other platforms it # works for pipes and sockets. (Exception: OS X 10.4? Issue #19294.) if is_socket or (is_fifo and not sys.platform.startswith("aix")): # only start reading when connection_made() has been called self._loop.call_soon(self._loop._add_reader, self._fileno, self._read_ready) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) def __repr__(self): info = [self.__class__.__name__] if self._pipe is None: info.append('closed') elif self._closing: info.append('closing') info.append(f'fd={self._fileno}') selector = getattr(self._loop, '_selector', None) if self._pipe is not None and selector is not None: polling = selector_events._test_selector_event( selector, self._fileno, selectors.EVENT_WRITE) if polling: info.append('polling') else: info.append('idle') bufsize = self.get_write_buffer_size() info.append(f'bufsize={bufsize}') elif self._pipe is not None: info.append('open') else: info.append('closed') return '<{}>'.format(' '.join(info)) def get_write_buffer_size(self): return len(self._buffer) def _read_ready(self): # Pipe was closed by peer. if self._loop.get_debug(): logger.info("%r was closed by peer", self) if self._buffer: self._close(BrokenPipeError()) else: self._close() def write(self, data): assert isinstance(data, (bytes, bytearray, memoryview)), repr(data) if isinstance(data, bytearray): data = memoryview(data) if not data: return if self._conn_lost or self._closing: if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('pipe closed by peer or ' 'os.write(pipe, data) raised exception.') self._conn_lost += 1 return if not self._buffer: # Attempt to send it right away first. try: n = os.write(self._fileno, data) except (BlockingIOError, InterruptedError): n = 0 except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._conn_lost += 1 self._fatal_error(exc, 'Fatal write error on pipe transport') return if n == len(data): return elif n > 0: data = memoryview(data)[n:] self._loop._add_writer(self._fileno, self._write_ready) self._buffer += data self._maybe_pause_protocol() def _write_ready(self): assert self._buffer, 'Data should not be empty' try: n = os.write(self._fileno, self._buffer) except (BlockingIOError, InterruptedError): pass except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._buffer.clear() self._conn_lost += 1 # Remove writer here, _fatal_error() doesn't it # because _buffer is empty. self._loop._remove_writer(self._fileno) self._fatal_error(exc, 'Fatal write error on pipe transport') else: if n == len(self._buffer): self._buffer.clear() self._loop._remove_writer(self._fileno) self._maybe_resume_protocol() # May append to buffer. if self._closing: self._loop._remove_reader(self._fileno) self._call_connection_lost(None) return elif n > 0: del self._buffer[:n] def can_write_eof(self): return True def write_eof(self): if self._closing: return assert self._pipe self._closing = True if not self._buffer: self._loop._remove_reader(self._fileno) self._loop.call_soon(self._call_connection_lost, None) def set_protocol(self, protocol): self._protocol = protocol def get_protocol(self): return self._protocol def is_closing(self): return self._closing def close(self): if self._pipe is not None and not self._closing: # write_eof is all what we needed to close the write pipe self.write_eof() def __del__(self, _warn=warnings.warn): if self._pipe is not None: _warn(f"unclosed transport {self!r}", ResourceWarning, source=self) self._pipe.close() def abort(self): self._close(None) def _fatal_error(self, exc, message='Fatal error on pipe transport'): # should be called by exception handler only if isinstance(exc, OSError): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) self._close(exc) def _close(self, exc=None): self._closing = True if self._buffer: self._loop._remove_writer(self._fileno) self._buffer.clear() self._loop._remove_reader(self._fileno) self._loop.call_soon(self._call_connection_lost, exc) def _call_connection_lost(self, exc): try: self._protocol.connection_lost(exc) finally: self._pipe.close() self._pipe = None self._protocol = None self._loop = None class _UnixSubprocessTransport(base_subprocess.BaseSubprocessTransport): def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs): stdin_w = None if stdin == subprocess.PIPE and sys.platform.startswith('aix'): # Use a socket pair for stdin on AIX, since it does not # support selecting read events on the write end of a # socket (which we use in order to detect closing of the # other end). stdin, stdin_w = socket.socketpair() try: self._proc = subprocess.Popen( args, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr, universal_newlines=False, bufsize=bufsize, **kwargs) if stdin_w is not None: stdin.close() self._proc.stdin = open(stdin_w.detach(), 'wb', buffering=bufsize) stdin_w = None finally: if stdin_w is not None: stdin.close() stdin_w.close() class AbstractChildWatcher: """Abstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. """ def __init_subclass__(cls) -> None: if cls.__module__ != __name__: warnings._deprecated("AbstractChildWatcher", "{name!r} is deprecated as of Python 3.12 and will be " "removed in Python {remove}.", remove=(3, 14)) def add_child_handler(self, pid, callback, *args): """Register a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. """ raise NotImplementedError() def remove_child_handler(self, pid): """Removes the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.""" raise NotImplementedError() def attach_loop(self, loop): """Attach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. """ raise NotImplementedError() def close(self): """Close the watcher. This must be called to make sure that any underlying resource is freed. """ raise NotImplementedError() def is_active(self): """Return ``True`` if the watcher is active and is used by the event loop. Return True if the watcher is installed and ready to handle process exit notifications. """ raise NotImplementedError() def __enter__(self): """Enter the watcher's context and allow starting new processes This function must return self""" raise NotImplementedError() def __exit__(self, a, b, c): """Exit the watcher's context""" raise NotImplementedError() class PidfdChildWatcher(AbstractChildWatcher): """Child watcher implementation using Linux's pid file descriptors. This child watcher polls process file descriptors (pidfds) to await child process termination. In some respects, PidfdChildWatcher is a "Goldilocks" child watcher implementation. It doesn't require signals or threads, doesn't interfere with any processes launched outside the event loop, and scales linearly with the number of subprocesses launched by the event loop. The main disadvantage is that pidfds are specific to Linux, and only work on recent (5.3+) kernels. """ def __enter__(self): return self def __exit__(self, exc_type, exc_value, exc_traceback): pass def is_active(self): return True def close(self): pass def attach_loop(self, loop): pass def add_child_handler(self, pid, callback, *args): loop = events.get_running_loop() pidfd = os.pidfd_open(pid) loop._add_reader(pidfd, self._do_wait, pid, pidfd, callback, args) def _do_wait(self, pid, pidfd, callback, args): loop = events.get_running_loop() loop._remove_reader(pidfd) try: _, status = os.waitpid(pid, 0) except ChildProcessError: # The child process is already reaped # (may happen if waitpid() is called elsewhere). returncode = 255 logger.warning( "child process pid %d exit status already read: " " will report returncode 255", pid) else: returncode = waitstatus_to_exitcode(status) os.close(pidfd) callback(pid, returncode, *args) def remove_child_handler(self, pid): # asyncio never calls remove_child_handler() !!! # The method is no-op but is implemented because # abstract base classes require it. return True class BaseChildWatcher(AbstractChildWatcher): def __init__(self): self._loop = None self._callbacks = {} def close(self): self.attach_loop(None) def is_active(self): return self._loop is not None and self._loop.is_running() def _do_waitpid(self, expected_pid): raise NotImplementedError() def _do_waitpid_all(self): raise NotImplementedError() def attach_loop(self, loop): assert loop is None or isinstance(loop, events.AbstractEventLoop) if self._loop is not None and loop is None and self._callbacks: warnings.warn( 'A loop is being detached ' 'from a child watcher with pending handlers', RuntimeWarning) if self._loop is not None: self._loop.remove_signal_handler(signal.SIGCHLD) self._loop = loop if loop is not None: loop.add_signal_handler(signal.SIGCHLD, self._sig_chld) # Prevent a race condition in case a child terminated # during the switch. self._do_waitpid_all() def _sig_chld(self): try: self._do_waitpid_all() except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: # self._loop should always be available here # as '_sig_chld' is added as a signal handler # in 'attach_loop' self._loop.call_exception_handler({ 'message': 'Unknown exception in SIGCHLD handler', 'exception': exc, }) class SafeChildWatcher(BaseChildWatcher): """'Safe' child watcher implementation. This implementation avoids disrupting other code spawning processes by polling explicitly each process in the SIGCHLD handler instead of calling os.waitpid(-1). This is a safe solution but it has a significant overhead when handling a big number of children (O(n) each time SIGCHLD is raised) """ def __init__(self): super().__init__() warnings._deprecated("SafeChildWatcher", "{name!r} is deprecated as of Python 3.12 and will be " "removed in Python {remove}.", remove=(3, 14)) def close(self): self._callbacks.clear() super().close() def __enter__(self): return self def __exit__(self, a, b, c): pass def add_child_handler(self, pid, callback, *args): self._callbacks[pid] = (callback, args) # Prevent a race condition in case the child is already terminated. self._do_waitpid(pid) def remove_child_handler(self, pid): try: del self._callbacks[pid] return True except KeyError: return False def _do_waitpid_all(self): for pid in list(self._callbacks): self._do_waitpid(pid) def _do_waitpid(self, expected_pid): assert expected_pid > 0 try: pid, status = os.waitpid(expected_pid, os.WNOHANG) except ChildProcessError: # The child process is already reaped # (may happen if waitpid() is called elsewhere). pid = expected_pid returncode = 255 logger.warning( "Unknown child process pid %d, will report returncode 255", pid) else: if pid == 0: # The child process is still alive. return returncode = waitstatus_to_exitcode(status) if self._loop.get_debug(): logger.debug('process %s exited with returncode %s', expected_pid, returncode) try: callback, args = self._callbacks.pop(pid) except KeyError: # pragma: no cover # May happen if .remove_child_handler() is called # after os.waitpid() returns. if self._loop.get_debug(): logger.warning("Child watcher got an unexpected pid: %r", pid, exc_info=True) else: callback(pid, returncode, *args) class FastChildWatcher(BaseChildWatcher): """'Fast' child watcher implementation. This implementation reaps every terminated processes by calling os.waitpid(-1) directly, possibly breaking other code spawning processes and waiting for their termination. There is no noticeable overhead when handling a big number of children (O(1) each time a child terminates). """ def __init__(self): super().__init__() self._lock = threading.Lock() self._zombies = {} self._forks = 0 warnings._deprecated("FastChildWatcher", "{name!r} is deprecated as of Python 3.12 and will be " "removed in Python {remove}.", remove=(3, 14)) def close(self): self._callbacks.clear() self._zombies.clear() super().close() def __enter__(self): with self._lock: self._forks += 1 return self def __exit__(self, a, b, c): with self._lock: self._forks -= 1 if self._forks or not self._zombies: return collateral_victims = str(self._zombies) self._zombies.clear() logger.warning( "Caught subprocesses termination from unknown pids: %s", collateral_victims) def add_child_handler(self, pid, callback, *args): assert self._forks, "Must use the context manager" with self._lock: try: returncode = self._zombies.pop(pid) except KeyError: # The child is running. self._callbacks[pid] = callback, args return # The child is dead already. We can fire the callback. callback(pid, returncode, *args) def remove_child_handler(self, pid): try: del self._callbacks[pid] return True except KeyError: return False def _do_waitpid_all(self): # Because of signal coalescing, we must keep calling waitpid() as # long as we're able to reap a child. while True: try: pid, status = os.waitpid(-1, os.WNOHANG) except ChildProcessError: # No more child processes exist. return else: if pid == 0: # A child process is still alive. return returncode = waitstatus_to_exitcode(status) with self._lock: try: callback, args = self._callbacks.pop(pid) except KeyError: # unknown child if self._forks: # It may not be registered yet. self._zombies[pid] = returncode if self._loop.get_debug(): logger.debug('unknown process %s exited ' 'with returncode %s', pid, returncode) continue callback = None else: if self._loop.get_debug(): logger.debug('process %s exited with returncode %s', pid, returncode) if callback is None: logger.warning( "Caught subprocess termination from unknown pid: " "%d -> %d", pid, returncode) else: callback(pid, returncode, *args) class MultiLoopChildWatcher(AbstractChildWatcher): """A watcher that doesn't require running loop in the main thread. This implementation registers a SIGCHLD signal handler on instantiation (which may conflict with other code that install own handler for this signal). The solution is safe but it has a significant overhead when handling a big number of processes (*O(n)* each time a SIGCHLD is received). """ # Implementation note: # The class keeps compatibility with AbstractChildWatcher ABC # To achieve this it has empty attach_loop() method # and doesn't accept explicit loop argument # for add_child_handler()/remove_child_handler() # but retrieves the current loop by get_running_loop() def __init__(self): self._callbacks = {} self._saved_sighandler = None warnings._deprecated("MultiLoopChildWatcher", "{name!r} is deprecated as of Python 3.12 and will be " "removed in Python {remove}.", remove=(3, 14)) def is_active(self): return self._saved_sighandler is not None def close(self): self._callbacks.clear() if self._saved_sighandler is None: return handler = signal.getsignal(signal.SIGCHLD) if handler != self._sig_chld: logger.warning("SIGCHLD handler was changed by outside code") else: signal.signal(signal.SIGCHLD, self._saved_sighandler) self._saved_sighandler = None def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): pass def add_child_handler(self, pid, callback, *args): loop = events.get_running_loop() self._callbacks[pid] = (loop, callback, args) # Prevent a race condition in case the child is already terminated. self._do_waitpid(pid) def remove_child_handler(self, pid): try: del self._callbacks[pid] return True except KeyError: return False def attach_loop(self, loop): # Don't save the loop but initialize itself if called first time # The reason to do it here is that attach_loop() is called from # unix policy only for the main thread. # Main thread is required for subscription on SIGCHLD signal if self._saved_sighandler is not None: return self._saved_sighandler = signal.signal(signal.SIGCHLD, self._sig_chld) if self._saved_sighandler is None: logger.warning("Previous SIGCHLD handler was set by non-Python code, " "restore to default handler on watcher close.") self._saved_sighandler = signal.SIG_DFL # Set SA_RESTART to limit EINTR occurrences. signal.siginterrupt(signal.SIGCHLD, False) def _do_waitpid_all(self): for pid in list(self._callbacks): self._do_waitpid(pid) def _do_waitpid(self, expected_pid): assert expected_pid > 0 try: pid, status = os.waitpid(expected_pid, os.WNOHANG) except ChildProcessError: # The child process is already reaped # (may happen if waitpid() is called elsewhere). pid = expected_pid returncode = 255 logger.warning( "Unknown child process pid %d, will report returncode 255", pid) debug_log = False else: if pid == 0: # The child process is still alive. return returncode = waitstatus_to_exitcode(status) debug_log = True try: loop, callback, args = self._callbacks.pop(pid) except KeyError: # pragma: no cover # May happen if .remove_child_handler() is called # after os.waitpid() returns. logger.warning("Child watcher got an unexpected pid: %r", pid, exc_info=True) else: if loop.is_closed(): logger.warning("Loop %r that handles pid %r is closed", loop, pid) else: if debug_log and loop.get_debug(): logger.debug('process %s exited with returncode %s', expected_pid, returncode) loop.call_soon_threadsafe(callback, pid, returncode, *args) def _sig_chld(self, signum, frame): try: self._do_waitpid_all() except (SystemExit, KeyboardInterrupt): raise except BaseException: logger.warning('Unknown exception in SIGCHLD handler', exc_info=True) class ThreadedChildWatcher(AbstractChildWatcher): """Threaded child watcher implementation. The watcher uses a thread per process for waiting for the process finish. It doesn't require subscription on POSIX signal but a thread creation is not free. The watcher has O(1) complexity, its performance doesn't depend on amount of spawn processes. """ def __init__(self): self._pid_counter = itertools.count(0) self._threads = {} def is_active(self): return True def close(self): pass def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): pass def __del__(self, _warn=warnings.warn): threads = [thread for thread in list(self._threads.values()) if thread.is_alive()] if threads: _warn(f"{self.__class__} has registered but not finished child processes", ResourceWarning, source=self) def add_child_handler(self, pid, callback, *args): loop = events.get_running_loop() thread = threading.Thread(target=self._do_waitpid, name=f"asyncio-waitpid-{next(self._pid_counter)}", args=(loop, pid, callback, args), daemon=True) self._threads[pid] = thread thread.start() def remove_child_handler(self, pid): # asyncio never calls remove_child_handler() !!! # The method is no-op but is implemented because # abstract base classes require it. return True def attach_loop(self, loop): pass def _do_waitpid(self, loop, expected_pid, callback, args): assert expected_pid > 0 try: pid, status = os.waitpid(expected_pid, 0) except ChildProcessError: # The child process is already reaped # (may happen if waitpid() is called elsewhere). pid = expected_pid returncode = 255 logger.warning( "Unknown child process pid %d, will report returncode 255", pid) else: returncode = waitstatus_to_exitcode(status) if loop.get_debug(): logger.debug('process %s exited with returncode %s', expected_pid, returncode) if loop.is_closed(): logger.warning("Loop %r that handles pid %r is closed", loop, pid) else: loop.call_soon_threadsafe(callback, pid, returncode, *args) self._threads.pop(expected_pid) def can_use_pidfd(): if not hasattr(os, 'pidfd_open'): return False try: pid = os.getpid() os.close(os.pidfd_open(pid, 0)) except OSError: # blocked by security policy like SECCOMP return False return True class _UnixDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy): """UNIX event loop policy with a watcher for child processes.""" _loop_factory = _UnixSelectorEventLoop def __init__(self): super().__init__() self._watcher = None def _init_watcher(self): with events._lock: if self._watcher is None: # pragma: no branch if can_use_pidfd(): self._watcher = PidfdChildWatcher() else: self._watcher = ThreadedChildWatcher() def set_event_loop(self, loop): """Set the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. """ super().set_event_loop(loop) if (self._watcher is not None and threading.current_thread() is threading.main_thread()): self._watcher.attach_loop(loop) def get_child_watcher(self): """Get the watcher for child processes. If not yet set, a ThreadedChildWatcher object is automatically created. """ if self._watcher is None: self._init_watcher() warnings._deprecated("get_child_watcher", "{name!r} is deprecated as of Python 3.12 and will be " "removed in Python {remove}.", remove=(3, 14)) return self._watcher def set_child_watcher(self, watcher): """Set the watcher for child processes.""" assert watcher is None or isinstance(watcher, AbstractChildWatcher) if self._watcher is not None: self._watcher.close() self._watcher = watcher warnings._deprecated("set_child_watcher", "{name!r} is deprecated as of Python 3.12 and will be " "removed in Python {remove}.", remove=(3, 14)) SelectorEventLoop = _UnixSelectorEventLoop DefaultEventLoopPolicy = _UnixDefaultEventLoopPolicy windows_events.py000064400000077513151706172570010224 0ustar00"""Selector and proactor event loops for Windows.""" import sys if sys.platform != 'win32': # pragma: no cover raise ImportError('win32 only') import _overlapped import _winapi import errno from functools import partial import math import msvcrt import socket import struct import time import weakref from . import events from . import base_subprocess from . import futures from . import exceptions from . import proactor_events from . import selector_events from . import tasks from . import windows_utils from .log import logger __all__ = ( 'SelectorEventLoop', 'ProactorEventLoop', 'IocpProactor', 'DefaultEventLoopPolicy', 'WindowsSelectorEventLoopPolicy', 'WindowsProactorEventLoopPolicy', ) NULL = _winapi.NULL INFINITE = _winapi.INFINITE ERROR_CONNECTION_REFUSED = 1225 ERROR_CONNECTION_ABORTED = 1236 # Initial delay in seconds for connect_pipe() before retrying to connect CONNECT_PIPE_INIT_DELAY = 0.001 # Maximum delay in seconds for connect_pipe() before retrying to connect CONNECT_PIPE_MAX_DELAY = 0.100 class _OverlappedFuture(futures.Future): """Subclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. """ def __init__(self, ov, *, loop=None): super().__init__(loop=loop) if self._source_traceback: del self._source_traceback[-1] self._ov = ov def _repr_info(self): info = super()._repr_info() if self._ov is not None: state = 'pending' if self._ov.pending else 'completed' info.insert(1, f'overlapped=<{state}, {self._ov.address:#x}>') return info def _cancel_overlapped(self): if self._ov is None: return try: self._ov.cancel() except OSError as exc: context = { 'message': 'Cancelling an overlapped future failed', 'exception': exc, 'future': self, } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) self._ov = None def cancel(self, msg=None): self._cancel_overlapped() return super().cancel(msg=msg) def set_exception(self, exception): super().set_exception(exception) self._cancel_overlapped() def set_result(self, result): super().set_result(result) self._ov = None class _BaseWaitHandleFuture(futures.Future): """Subclass of Future which represents a wait handle.""" def __init__(self, ov, handle, wait_handle, *, loop=None): super().__init__(loop=loop) if self._source_traceback: del self._source_traceback[-1] # Keep a reference to the Overlapped object to keep it alive until the # wait is unregistered self._ov = ov self._handle = handle self._wait_handle = wait_handle # Should we call UnregisterWaitEx() if the wait completes # or is cancelled? self._registered = True def _poll(self): # non-blocking wait: use a timeout of 0 millisecond return (_winapi.WaitForSingleObject(self._handle, 0) == _winapi.WAIT_OBJECT_0) def _repr_info(self): info = super()._repr_info() info.append(f'handle={self._handle:#x}') if self._handle is not None: state = 'signaled' if self._poll() else 'waiting' info.append(state) if self._wait_handle is not None: info.append(f'wait_handle={self._wait_handle:#x}') return info def _unregister_wait_cb(self, fut): # The wait was unregistered: it's not safe to destroy the Overlapped # object self._ov = None def _unregister_wait(self): if not self._registered: return self._registered = False wait_handle = self._wait_handle self._wait_handle = None try: _overlapped.UnregisterWait(wait_handle) except OSError as exc: if exc.winerror != _overlapped.ERROR_IO_PENDING: context = { 'message': 'Failed to unregister the wait handle', 'exception': exc, 'future': self, } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) return # ERROR_IO_PENDING means that the unregister is pending self._unregister_wait_cb(None) def cancel(self, msg=None): self._unregister_wait() return super().cancel(msg=msg) def set_exception(self, exception): self._unregister_wait() super().set_exception(exception) def set_result(self, result): self._unregister_wait() super().set_result(result) class _WaitCancelFuture(_BaseWaitHandleFuture): """Subclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. """ def __init__(self, ov, event, wait_handle, *, loop=None): super().__init__(ov, event, wait_handle, loop=loop) self._done_callback = None def cancel(self): raise RuntimeError("_WaitCancelFuture must not be cancelled") def set_result(self, result): super().set_result(result) if self._done_callback is not None: self._done_callback(self) def set_exception(self, exception): super().set_exception(exception) if self._done_callback is not None: self._done_callback(self) class _WaitHandleFuture(_BaseWaitHandleFuture): def __init__(self, ov, handle, wait_handle, proactor, *, loop=None): super().__init__(ov, handle, wait_handle, loop=loop) self._proactor = proactor self._unregister_proactor = True self._event = _overlapped.CreateEvent(None, True, False, None) self._event_fut = None def _unregister_wait_cb(self, fut): if self._event is not None: _winapi.CloseHandle(self._event) self._event = None self._event_fut = None # If the wait was cancelled, the wait may never be signalled, so # it's required to unregister it. Otherwise, IocpProactor.close() will # wait forever for an event which will never come. # # If the IocpProactor already received the event, it's safe to call # _unregister() because we kept a reference to the Overlapped object # which is used as a unique key. self._proactor._unregister(self._ov) self._proactor = None super()._unregister_wait_cb(fut) def _unregister_wait(self): if not self._registered: return self._registered = False wait_handle = self._wait_handle self._wait_handle = None try: _overlapped.UnregisterWaitEx(wait_handle, self._event) except OSError as exc: if exc.winerror != _overlapped.ERROR_IO_PENDING: context = { 'message': 'Failed to unregister the wait handle', 'exception': exc, 'future': self, } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) return # ERROR_IO_PENDING is not an error, the wait was unregistered self._event_fut = self._proactor._wait_cancel(self._event, self._unregister_wait_cb) class PipeServer(object): """Class representing a pipe server. This is much like a bound, listening socket. """ def __init__(self, address): self._address = address self._free_instances = weakref.WeakSet() # initialize the pipe attribute before calling _server_pipe_handle() # because this function can raise an exception and the destructor calls # the close() method self._pipe = None self._accept_pipe_future = None self._pipe = self._server_pipe_handle(True) def _get_unconnected_pipe(self): # Create new instance and return previous one. This ensures # that (until the server is closed) there is always at least # one pipe handle for address. Therefore if a client attempt # to connect it will not fail with FileNotFoundError. tmp, self._pipe = self._pipe, self._server_pipe_handle(False) return tmp def _server_pipe_handle(self, first): # Return a wrapper for a new pipe handle. if self.closed(): return None flags = _winapi.PIPE_ACCESS_DUPLEX | _winapi.FILE_FLAG_OVERLAPPED if first: flags |= _winapi.FILE_FLAG_FIRST_PIPE_INSTANCE h = _winapi.CreateNamedPipe( self._address, flags, _winapi.PIPE_TYPE_MESSAGE | _winapi.PIPE_READMODE_MESSAGE | _winapi.PIPE_WAIT, _winapi.PIPE_UNLIMITED_INSTANCES, windows_utils.BUFSIZE, windows_utils.BUFSIZE, _winapi.NMPWAIT_WAIT_FOREVER, _winapi.NULL) pipe = windows_utils.PipeHandle(h) self._free_instances.add(pipe) return pipe def closed(self): return (self._address is None) def close(self): if self._accept_pipe_future is not None: self._accept_pipe_future.cancel() self._accept_pipe_future = None # Close all instances which have not been connected to by a client. if self._address is not None: for pipe in self._free_instances: pipe.close() self._pipe = None self._address = None self._free_instances.clear() __del__ = close class _WindowsSelectorEventLoop(selector_events.BaseSelectorEventLoop): """Windows version of selector event loop.""" class ProactorEventLoop(proactor_events.BaseProactorEventLoop): """Windows version of proactor event loop using IOCP.""" def __init__(self, proactor=None): if proactor is None: proactor = IocpProactor() super().__init__(proactor) def run_forever(self): try: assert self._self_reading_future is None self.call_soon(self._loop_self_reading) super().run_forever() finally: if self._self_reading_future is not None: ov = self._self_reading_future._ov self._self_reading_future.cancel() # self_reading_future always uses IOCP, so even though it's # been cancelled, we need to make sure that the IOCP message # is received so that the kernel is not holding on to the # memory, possibly causing memory corruption later. Only # unregister it if IO is complete in all respects. Otherwise # we need another _poll() later to complete the IO. if ov is not None and not ov.pending: self._proactor._unregister(ov) self._self_reading_future = None async def create_pipe_connection(self, protocol_factory, address): f = self._proactor.connect_pipe(address) pipe = await f protocol = protocol_factory() trans = self._make_duplex_pipe_transport(pipe, protocol, extra={'addr': address}) return trans, protocol async def start_serving_pipe(self, protocol_factory, address): server = PipeServer(address) def loop_accept_pipe(f=None): pipe = None try: if f: pipe = f.result() server._free_instances.discard(pipe) if server.closed(): # A client connected before the server was closed: # drop the client (close the pipe) and exit pipe.close() return protocol = protocol_factory() self._make_duplex_pipe_transport( pipe, protocol, extra={'addr': address}) pipe = server._get_unconnected_pipe() if pipe is None: return f = self._proactor.accept_pipe(pipe) except BrokenPipeError: if pipe and pipe.fileno() != -1: pipe.close() self.call_soon(loop_accept_pipe) except OSError as exc: if pipe and pipe.fileno() != -1: self.call_exception_handler({ 'message': 'Pipe accept failed', 'exception': exc, 'pipe': pipe, }) pipe.close() elif self._debug: logger.warning("Accept pipe failed on pipe %r", pipe, exc_info=True) self.call_soon(loop_accept_pipe) except exceptions.CancelledError: if pipe: pipe.close() else: server._accept_pipe_future = f f.add_done_callback(loop_accept_pipe) self.call_soon(loop_accept_pipe) return [server] async def _make_subprocess_transport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, extra=None, **kwargs): waiter = self.create_future() transp = _WindowsSubprocessTransport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, waiter=waiter, extra=extra, **kwargs) try: await waiter except (SystemExit, KeyboardInterrupt): raise except BaseException: transp.close() await transp._wait() raise return transp class IocpProactor: """Proactor implementation using IOCP.""" def __init__(self, concurrency=INFINITE): self._loop = None self._results = [] self._iocp = _overlapped.CreateIoCompletionPort( _overlapped.INVALID_HANDLE_VALUE, NULL, 0, concurrency) self._cache = {} self._registered = weakref.WeakSet() self._unregistered = [] self._stopped_serving = weakref.WeakSet() def _check_closed(self): if self._iocp is None: raise RuntimeError('IocpProactor is closed') def __repr__(self): info = ['overlapped#=%s' % len(self._cache), 'result#=%s' % len(self._results)] if self._iocp is None: info.append('closed') return '<%s %s>' % (self.__class__.__name__, " ".join(info)) def set_loop(self, loop): self._loop = loop def select(self, timeout=None): if not self._results: self._poll(timeout) tmp = self._results self._results = [] try: return tmp finally: # Needed to break cycles when an exception occurs. tmp = None def _result(self, value): fut = self._loop.create_future() fut.set_result(value) return fut @staticmethod def finish_socket_func(trans, key, ov): try: return ov.getresult() except OSError as exc: if exc.winerror in (_overlapped.ERROR_NETNAME_DELETED, _overlapped.ERROR_OPERATION_ABORTED): raise ConnectionResetError(*exc.args) else: raise @classmethod def _finish_recvfrom(cls, trans, key, ov, *, empty_result): try: return cls.finish_socket_func(trans, key, ov) except OSError as exc: # WSARecvFrom will report ERROR_PORT_UNREACHABLE when the same # socket is used to send to an address that is not listening. if exc.winerror == _overlapped.ERROR_PORT_UNREACHABLE: return empty_result, None else: raise def recv(self, conn, nbytes, flags=0): self._register_with_iocp(conn) ov = _overlapped.Overlapped(NULL) try: if isinstance(conn, socket.socket): ov.WSARecv(conn.fileno(), nbytes, flags) else: ov.ReadFile(conn.fileno(), nbytes) except BrokenPipeError: return self._result(b'') return self._register(ov, conn, self.finish_socket_func) def recv_into(self, conn, buf, flags=0): self._register_with_iocp(conn) ov = _overlapped.Overlapped(NULL) try: if isinstance(conn, socket.socket): ov.WSARecvInto(conn.fileno(), buf, flags) else: ov.ReadFileInto(conn.fileno(), buf) except BrokenPipeError: return self._result(0) return self._register(ov, conn, self.finish_socket_func) def recvfrom(self, conn, nbytes, flags=0): self._register_with_iocp(conn) ov = _overlapped.Overlapped(NULL) try: ov.WSARecvFrom(conn.fileno(), nbytes, flags) except BrokenPipeError: return self._result((b'', None)) return self._register(ov, conn, partial(self._finish_recvfrom, empty_result=b'')) def recvfrom_into(self, conn, buf, flags=0): self._register_with_iocp(conn) ov = _overlapped.Overlapped(NULL) try: ov.WSARecvFromInto(conn.fileno(), buf, flags) except BrokenPipeError: return self._result((0, None)) return self._register(ov, conn, partial(self._finish_recvfrom, empty_result=0)) def sendto(self, conn, buf, flags=0, addr=None): self._register_with_iocp(conn) ov = _overlapped.Overlapped(NULL) ov.WSASendTo(conn.fileno(), buf, flags, addr) return self._register(ov, conn, self.finish_socket_func) def send(self, conn, buf, flags=0): self._register_with_iocp(conn) ov = _overlapped.Overlapped(NULL) if isinstance(conn, socket.socket): ov.WSASend(conn.fileno(), buf, flags) else: ov.WriteFile(conn.fileno(), buf) return self._register(ov, conn, self.finish_socket_func) def accept(self, listener): self._register_with_iocp(listener) conn = self._get_accept_socket(listener.family) ov = _overlapped.Overlapped(NULL) ov.AcceptEx(listener.fileno(), conn.fileno()) def finish_accept(trans, key, ov): ov.getresult() # Use SO_UPDATE_ACCEPT_CONTEXT so getsockname() etc work. buf = struct.pack('@P', listener.fileno()) conn.setsockopt(socket.SOL_SOCKET, _overlapped.SO_UPDATE_ACCEPT_CONTEXT, buf) conn.settimeout(listener.gettimeout()) return conn, conn.getpeername() async def accept_coro(future, conn): # Coroutine closing the accept socket if the future is cancelled try: await future except exceptions.CancelledError: conn.close() raise future = self._register(ov, listener, finish_accept) coro = accept_coro(future, conn) tasks.ensure_future(coro, loop=self._loop) return future def connect(self, conn, address): if conn.type == socket.SOCK_DGRAM: # WSAConnect will complete immediately for UDP sockets so we don't # need to register any IOCP operation _overlapped.WSAConnect(conn.fileno(), address) fut = self._loop.create_future() fut.set_result(None) return fut self._register_with_iocp(conn) # The socket needs to be locally bound before we call ConnectEx(). try: _overlapped.BindLocal(conn.fileno(), conn.family) except OSError as e: if e.winerror != errno.WSAEINVAL: raise # Probably already locally bound; check using getsockname(). if conn.getsockname()[1] == 0: raise ov = _overlapped.Overlapped(NULL) ov.ConnectEx(conn.fileno(), address) def finish_connect(trans, key, ov): ov.getresult() # Use SO_UPDATE_CONNECT_CONTEXT so getsockname() etc work. conn.setsockopt(socket.SOL_SOCKET, _overlapped.SO_UPDATE_CONNECT_CONTEXT, 0) return conn return self._register(ov, conn, finish_connect) def sendfile(self, sock, file, offset, count): self._register_with_iocp(sock) ov = _overlapped.Overlapped(NULL) offset_low = offset & 0xffff_ffff offset_high = (offset >> 32) & 0xffff_ffff ov.TransmitFile(sock.fileno(), msvcrt.get_osfhandle(file.fileno()), offset_low, offset_high, count, 0, 0) return self._register(ov, sock, self.finish_socket_func) def accept_pipe(self, pipe): self._register_with_iocp(pipe) ov = _overlapped.Overlapped(NULL) connected = ov.ConnectNamedPipe(pipe.fileno()) if connected: # ConnectNamePipe() failed with ERROR_PIPE_CONNECTED which means # that the pipe is connected. There is no need to wait for the # completion of the connection. return self._result(pipe) def finish_accept_pipe(trans, key, ov): ov.getresult() return pipe return self._register(ov, pipe, finish_accept_pipe) async def connect_pipe(self, address): delay = CONNECT_PIPE_INIT_DELAY while True: # Unfortunately there is no way to do an overlapped connect to # a pipe. Call CreateFile() in a loop until it doesn't fail with # ERROR_PIPE_BUSY. try: handle = _overlapped.ConnectPipe(address) break except OSError as exc: if exc.winerror != _overlapped.ERROR_PIPE_BUSY: raise # ConnectPipe() failed with ERROR_PIPE_BUSY: retry later delay = min(delay * 2, CONNECT_PIPE_MAX_DELAY) await tasks.sleep(delay) return windows_utils.PipeHandle(handle) def wait_for_handle(self, handle, timeout=None): """Wait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). """ return self._wait_for_handle(handle, timeout, False) def _wait_cancel(self, event, done_callback): fut = self._wait_for_handle(event, None, True) # add_done_callback() cannot be used because the wait may only complete # in IocpProactor.close(), while the event loop is not running. fut._done_callback = done_callback return fut def _wait_for_handle(self, handle, timeout, _is_cancel): self._check_closed() if timeout is None: ms = _winapi.INFINITE else: # RegisterWaitForSingleObject() has a resolution of 1 millisecond, # round away from zero to wait *at least* timeout seconds. ms = math.ceil(timeout * 1e3) # We only create ov so we can use ov.address as a key for the cache. ov = _overlapped.Overlapped(NULL) wait_handle = _overlapped.RegisterWaitWithQueue( handle, self._iocp, ov.address, ms) if _is_cancel: f = _WaitCancelFuture(ov, handle, wait_handle, loop=self._loop) else: f = _WaitHandleFuture(ov, handle, wait_handle, self, loop=self._loop) if f._source_traceback: del f._source_traceback[-1] def finish_wait_for_handle(trans, key, ov): # Note that this second wait means that we should only use # this with handles types where a successful wait has no # effect. So events or processes are all right, but locks # or semaphores are not. Also note if the handle is # signalled and then quickly reset, then we may return # False even though we have not timed out. return f._poll() self._cache[ov.address] = (f, ov, 0, finish_wait_for_handle) return f def _register_with_iocp(self, obj): # To get notifications of finished ops on this objects sent to the # completion port, were must register the handle. if obj not in self._registered: self._registered.add(obj) _overlapped.CreateIoCompletionPort(obj.fileno(), self._iocp, 0, 0) # XXX We could also use SetFileCompletionNotificationModes() # to avoid sending notifications to completion port of ops # that succeed immediately. def _register(self, ov, obj, callback): self._check_closed() # Return a future which will be set with the result of the # operation when it completes. The future's value is actually # the value returned by callback(). f = _OverlappedFuture(ov, loop=self._loop) if f._source_traceback: del f._source_traceback[-1] if not ov.pending: # The operation has completed, so no need to postpone the # work. We cannot take this short cut if we need the # NumberOfBytes, CompletionKey values returned by # PostQueuedCompletionStatus(). try: value = callback(None, None, ov) except OSError as e: f.set_exception(e) else: f.set_result(value) # Even if GetOverlappedResult() was called, we have to wait for the # notification of the completion in GetQueuedCompletionStatus(). # Register the overlapped operation to keep a reference to the # OVERLAPPED object, otherwise the memory is freed and Windows may # read uninitialized memory. # Register the overlapped operation for later. Note that # we only store obj to prevent it from being garbage # collected too early. self._cache[ov.address] = (f, ov, obj, callback) return f def _unregister(self, ov): """Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). """ self._check_closed() self._unregistered.append(ov) def _get_accept_socket(self, family): s = socket.socket(family) s.settimeout(0) return s def _poll(self, timeout=None): if timeout is None: ms = INFINITE elif timeout < 0: raise ValueError("negative timeout") else: # GetQueuedCompletionStatus() has a resolution of 1 millisecond, # round away from zero to wait *at least* timeout seconds. ms = math.ceil(timeout * 1e3) if ms >= INFINITE: raise ValueError("timeout too big") while True: status = _overlapped.GetQueuedCompletionStatus(self._iocp, ms) if status is None: break ms = 0 err, transferred, key, address = status try: f, ov, obj, callback = self._cache.pop(address) except KeyError: if self._loop.get_debug(): self._loop.call_exception_handler({ 'message': ('GetQueuedCompletionStatus() returned an ' 'unexpected event'), 'status': ('err=%s transferred=%s key=%#x address=%#x' % (err, transferred, key, address)), }) # key is either zero, or it is used to return a pipe # handle which should be closed to avoid a leak. if key not in (0, _overlapped.INVALID_HANDLE_VALUE): _winapi.CloseHandle(key) continue if obj in self._stopped_serving: f.cancel() # Don't call the callback if _register() already read the result or # if the overlapped has been cancelled elif not f.done(): try: value = callback(transferred, key, ov) except OSError as e: f.set_exception(e) self._results.append(f) else: f.set_result(value) self._results.append(f) finally: f = None # Remove unregistered futures for ov in self._unregistered: self._cache.pop(ov.address, None) self._unregistered.clear() def _stop_serving(self, obj): # obj is a socket or pipe handle. It will be closed in # BaseProactorEventLoop._stop_serving() which will make any # pending operations fail quickly. self._stopped_serving.add(obj) def close(self): if self._iocp is None: # already closed return # Cancel remaining registered operations. for fut, ov, obj, callback in list(self._cache.values()): if fut.cancelled(): # Nothing to do with cancelled futures pass elif isinstance(fut, _WaitCancelFuture): # _WaitCancelFuture must not be cancelled pass else: try: fut.cancel() except OSError as exc: if self._loop is not None: context = { 'message': 'Cancelling a future failed', 'exception': exc, 'future': fut, } if fut._source_traceback: context['source_traceback'] = fut._source_traceback self._loop.call_exception_handler(context) # Wait until all cancelled overlapped complete: don't exit with running # overlapped to prevent a crash. Display progress every second if the # loop is still running. msg_update = 1.0 start_time = time.monotonic() next_msg = start_time + msg_update while self._cache: if next_msg <= time.monotonic(): logger.debug('%r is running after closing for %.1f seconds', self, time.monotonic() - start_time) next_msg = time.monotonic() + msg_update # handle a few events, or timeout self._poll(msg_update) self._results = [] _winapi.CloseHandle(self._iocp) self._iocp = None def __del__(self): self.close() class _WindowsSubprocessTransport(base_subprocess.BaseSubprocessTransport): def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs): self._proc = windows_utils.Popen( args, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr, bufsize=bufsize, **kwargs) def callback(f): returncode = self._proc.poll() self._process_exited(returncode) f = self._loop._proactor.wait_for_handle(int(self._proc._handle)) f.add_done_callback(callback) SelectorEventLoop = _WindowsSelectorEventLoop class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): _loop_factory = SelectorEventLoop class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): _loop_factory = ProactorEventLoop DefaultEventLoopPolicy = WindowsProactorEventLoopPolicy windows_utils.py000064400000011704151706172570010046 0ustar00"""Various Windows specific bits and pieces.""" import sys if sys.platform != 'win32': # pragma: no cover raise ImportError('win32 only') import _winapi import itertools import msvcrt import os import subprocess import tempfile import warnings __all__ = 'pipe', 'Popen', 'PIPE', 'PipeHandle' # Constants/globals BUFSIZE = 8192 PIPE = subprocess.PIPE STDOUT = subprocess.STDOUT _mmap_counter = itertools.count() # Replacement for os.pipe() using handles instead of fds def pipe(*, duplex=False, overlapped=(True, True), bufsize=BUFSIZE): """Like os.pipe() but with overlapped support and using handles not fds.""" address = tempfile.mktemp( prefix=r'\\.\pipe\python-pipe-{:d}-{:d}-'.format( os.getpid(), next(_mmap_counter))) if duplex: openmode = _winapi.PIPE_ACCESS_DUPLEX access = _winapi.GENERIC_READ | _winapi.GENERIC_WRITE obsize, ibsize = bufsize, bufsize else: openmode = _winapi.PIPE_ACCESS_INBOUND access = _winapi.GENERIC_WRITE obsize, ibsize = 0, bufsize openmode |= _winapi.FILE_FLAG_FIRST_PIPE_INSTANCE if overlapped[0]: openmode |= _winapi.FILE_FLAG_OVERLAPPED if overlapped[1]: flags_and_attribs = _winapi.FILE_FLAG_OVERLAPPED else: flags_and_attribs = 0 h1 = h2 = None try: h1 = _winapi.CreateNamedPipe( address, openmode, _winapi.PIPE_WAIT, 1, obsize, ibsize, _winapi.NMPWAIT_WAIT_FOREVER, _winapi.NULL) h2 = _winapi.CreateFile( address, access, 0, _winapi.NULL, _winapi.OPEN_EXISTING, flags_and_attribs, _winapi.NULL) ov = _winapi.ConnectNamedPipe(h1, overlapped=True) ov.GetOverlappedResult(True) return h1, h2 except: if h1 is not None: _winapi.CloseHandle(h1) if h2 is not None: _winapi.CloseHandle(h2) raise # Wrapper for a pipe handle class PipeHandle: """Wrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. """ def __init__(self, handle): self._handle = handle def __repr__(self): if self._handle is not None: handle = f'handle={self._handle!r}' else: handle = 'closed' return f'<{self.__class__.__name__} {handle}>' @property def handle(self): return self._handle def fileno(self): if self._handle is None: raise ValueError("I/O operation on closed pipe") return self._handle def close(self, *, CloseHandle=_winapi.CloseHandle): if self._handle is not None: CloseHandle(self._handle) self._handle = None def __del__(self, _warn=warnings.warn): if self._handle is not None: _warn(f"unclosed {self!r}", ResourceWarning, source=self) self.close() def __enter__(self): return self def __exit__(self, t, v, tb): self.close() # Replacement for subprocess.Popen using overlapped pipe handles class Popen(subprocess.Popen): """Replacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. """ def __init__(self, args, stdin=None, stdout=None, stderr=None, **kwds): assert not kwds.get('universal_newlines') assert kwds.get('bufsize', 0) == 0 stdin_rfd = stdout_wfd = stderr_wfd = None stdin_wh = stdout_rh = stderr_rh = None if stdin == PIPE: stdin_rh, stdin_wh = pipe(overlapped=(False, True), duplex=True) stdin_rfd = msvcrt.open_osfhandle(stdin_rh, os.O_RDONLY) else: stdin_rfd = stdin if stdout == PIPE: stdout_rh, stdout_wh = pipe(overlapped=(True, False)) stdout_wfd = msvcrt.open_osfhandle(stdout_wh, 0) else: stdout_wfd = stdout if stderr == PIPE: stderr_rh, stderr_wh = pipe(overlapped=(True, False)) stderr_wfd = msvcrt.open_osfhandle(stderr_wh, 0) elif stderr == STDOUT: stderr_wfd = stdout_wfd else: stderr_wfd = stderr try: super().__init__(args, stdin=stdin_rfd, stdout=stdout_wfd, stderr=stderr_wfd, **kwds) except: for h in (stdin_wh, stdout_rh, stderr_rh): if h is not None: _winapi.CloseHandle(h) raise else: if stdin_wh is not None: self.stdin = PipeHandle(stdin_wh) if stdout_rh is not None: self.stdout = PipeHandle(stdout_rh) if stderr_rh is not None: self.stderr = PipeHandle(stderr_rh) finally: if stdin == PIPE: os.close(stdin_rfd) if stdout == PIPE: os.close(stdout_wfd) if stderr == PIPE: os.close(stderr_wfd)
/home/emeraadmin/www/Service/../node_modules/path-root/../jquery/../../src/../4d695/asyncio.tar