Your IP : 18.188.137.209


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

�

c��f�����dZddlZejdkred���ddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddl
mZddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZddlmZdZejZejZdZdZdZdZGd�dej��Z Gd�dej��Z!Gd�de!��Z"Gd�de!��Z#Gd�de$��Z%Gd�dej&��Z'Gd �d!ej(��Z)Gd"�d#��Z*Gd$�d%ej+��Z,e'Z-Gd&�d'ej.��Z/Gd(�d)ej.��Z0e0Z1dS)*z.Selector and proactor event loops for Windows.�N�win32z
win32 only�)�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�x��t���|���|jr|jd=||_dS�Nr���)�super�__init__�_source_traceback�_ov)�self�ovr�	__class__s   ��=/opt/alt/python311/lib64/python3.11/asyncio/windows_events.pyrz_OverlappedFuture.__init__6s?���
�����d��#�#�#��!�	+��&�r�*������c����t�����}|j�8|jjrdnd}|�dd|�d|jjd�d���|S)N�pending�	completedrzoverlapped=<z, �#x�>)r�
_repr_inforr%�insert�address�r�info�stater!s   �r"r)z_OverlappedFuture._repr_info<sh����w�w�!�!�#�#���8��!%��!1�B�I�I�{�E��K�K��I�%�I�I�4�8�3C�I�I�I�I�J�J�J��r#c���|j�dS	|j���nH#t$r;}d||d�}|jr
|j|d<|j�|��Yd}~nd}~wwxYwd|_dS)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_overlappedCs����8���F�
	7��H�O�O�������	7�	7�	7�C� ����G�
�%�
E�.2�.D��*�+��J�-�-�g�6�6�6�6�6�6�6�6�����	7��������s�%�
A*�1A%�%A*c�p��|���t���|���S�N)�msg)r;rr5�rr>r!s  �r"r5z_OverlappedFuture.cancelSs-������!�!�!��w�w�~�~�#�~�&�&�&r#c�r��t���|��|���dS�N)r�
set_exceptionr;�rr2r!s  �r"rBz_OverlappedFuture.set_exceptionWs3���
�����i�(�(�(����!�!�!�!�!r#c�X��t���|��d|_dSrA)r�
set_resultr�r�resultr!s  �r"rEz_OverlappedFuture.set_result[s&���
�����6�"�"�"�����r#rA)�__name__�
__module__�__qualname__�__doc__rr)r;r5rBrE�
__classcell__�r!s@r"rr0s����������
$(���������������� '�'�'�'�'�'�"�"�"�"�"���������r#rc�d��eZdZdZdd��fd�
Zd�Z�fd�Zd�Zd�Zd�fd	�	Z	�fd
�Z
�fd�Z�xZS)
�_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.Nrc���t���|���|jr|jd=||_||_||_d|_dS)NrrT)rrrr�_handle�_wait_handle�_registered)rr �handle�wait_handlerr!s     �r"rz_BaseWaitHandleFuture.__init__cs\���
�����d��#�#�#��!�	+��&�r�*�������'��� ����r#c�R�tj|jd��tjkS�Nr)�_winapi�WaitForSingleObjectrQ�
WAIT_OBJECT_0�rs r"�_pollz_BaseWaitHandleFuture._pollqs$���+�D�L�!�<�<��%�&�	'r#c�6��t�����}|�d|jd����|j�-|���rdnd}|�|��|j�|�d|jd����|S)Nzhandle=r'�signaled�waitingzwait_handle=)rr)�appendrQr\rRr,s   �r"r)z _BaseWaitHandleFuture._repr_infovs�����w�w�!�!�#�#�����/�d�l�/�/�/�0�0�0��<�#�"&�*�*�,�,�=�J�J�I�E��K�K�������(��K�K�=�t�'8�=�=�=�>�>�>��r#c��d|_dSrA)r)r�futs  r"�_unregister_wait_cbz)_BaseWaitHandleFuture._unregister_wait_cb�s������r#c�^�|jsdSd|_|j}d|_	tj|��nc#t$rV}|jtjkr7d||d�}|jr
|j|d<|j�	|��Yd}~dSYd}~nd}~wwxYw|�
d��dS�NFz$Failed to unregister the wait handler0r4)rSrR�_overlapped�UnregisterWaitr6�winerror�ERROR_IO_PENDINGrr7r8rc�rrUr9r:s    r"�_unregister_waitz&_BaseWaitHandleFuture._unregister_wait�s�����	��F� ����'�� ���	��&�{�3�3�3�3���
	�
	�
	��|�{�;�;�;�E�!$�"����
�)�I�26�2H�G�.�/��
�1�1�'�:�:�:�������<�;�;�;�;�����
	����	
� � ��&�&�&�&�&s�5�
B�AB�Bc�p��|���t���|���Sr=)rkrr5r?s  �r"r5z_BaseWaitHandleFuture.cancel�s-����������w�w�~�~�#�~�&�&�&r#c�r��|���t���|��dSrA)rkrrBrCs  �r"rBz#_BaseWaitHandleFuture.set_exception�s3���������
�����i�(�(�(�(�(r#c�r��|���t���|��dSrA)rkrrErFs  �r"rEz _BaseWaitHandleFuture.set_result�s3���������
�����6�"�"�"�"�"r#rA)
rHrIrJrKrr\r)rcrkr5rBrErLrMs@r"rOrO`s��������<�<�8<� � � � � � � �'�'�'�
��������
'�'�'�0'�'�'�'�'�'�)�)�)�)�)�#�#�#�#�#�#�#�#�#r#rOc�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|_dS)Nr)rr�_done_callback)rr �eventrUrr!s     �r"rz_WaitCancelFuture.__init__�s2���
������U�K�d��;�;�;�"����r#c� �td���)Nz'_WaitCancelFuture must not be cancelled)�RuntimeErrorr[s r"r5z_WaitCancelFuture.cancel�s���D�E�E�Er#c���t���|��|j�|�|��dSdSrA)rrErrrFs  �r"rEz_WaitCancelFuture.set_result�sF���
�����6�"�"�"���*�����%�%�%�%�%�+�*r#c���t���|��|j�|�|��dSdSrA)rrBrrrCs  �r"rBz_WaitCancelFuture.set_exception�sF���
�����i�(�(�(���*�����%�%�%�%�%�+�*r#)	rHrIrJrKrr5rErBrLrMs@r"rprp�s����������8<�#�#�#�#�#�#�#�
F�F�F�&�&�&�&�&�
&�&�&�&�&�&�&�&�&r#rpc�4��eZdZdd��fd�
Z�fd�Zd�Z�xZS)�_WaitHandleFutureNrc���t���||||���||_d|_t	jdddd��|_d|_dS)NrTF)rr�	_proactor�_unregister_proactorrf�CreateEvent�_event�
_event_fut)rr rTrU�proactorrr!s      �r"rz_WaitHandleFuture.__init__�sV���
������V�[�t��<�<�<�!���$(��!�!�-�d�D�%��F�F�������r#c����|j�'tj|j��d|_d|_|j�|j��d|_t���|��dSrA)	r~rX�CloseHandlerr{�_unregisterrrrc)rrbr!s  �r"rcz%_WaitHandleFuture._unregister_wait_cb�sk����;�"�����,�,�,��D�K�"�D�O�	
��"�"�4�8�,�,�,����
���#�#�C�(�(�(�(�(r#c��|jsdSd|_|j}d|_	tj||j��nc#t
$rV}|jtjkr7d||d�}|jr
|j|d<|j	�
|��Yd}~dSYd}~nd}~wwxYw|j�|j|j
��|_dSre)rSrRrf�UnregisterWaitExr~r6rhrirr7r8r{�_wait_cancelrcrrjs    r"rkz"_WaitHandleFuture._unregister_wait�s����	��F� ����'�� ���	��(��d�k�B�B�B�B���
	�
	�
	��|�{�;�;�;�E�!$�"����
�)�I�26�2H�G�.�/��
�1�1�'�:�:�:�������<�;�;�;�;�����
	�����.�5�5�d�k�6:�6N�P�P����s�;�
B�AB�B)rHrIrJrrcrkrLrMs@r"ryry�st�������BF��������)�)�)�)�)�$P�P�P�P�P�P�Pr#ryc�4�eZdZdZd�Zd�Zd�Zd�Zd�ZeZ	dS)�
PipeServerzXClass representing a pipe server.

    This is much like a bound, listening socket.
    c��||_tj��|_d|_d|_|�d��|_dS�NT)�_address�weakref�WeakSet�_free_instances�_pipe�_accept_pipe_future�_server_pipe_handle)rr+s  r"rzPipeServer.__init__�sC����
�&��0�0�����
�#'�� ��-�-�d�3�3��
�
�
r#c�J�|j|�d��c}|_|S)NF)r�r�)r�tmps  r"�_get_unconnected_pipez PipeServer._get_unconnected_pipes&��
�*�d�&>�&>�u�&E�&E���T�Z��
r#c
���|���rdStjtjz}|r|tjz}tj|j|tjtjztj	ztj
tjtjtj
tj��}tj|��}|j�|��|SrA)�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_handle
s����;�;�=�=�	��4��*�W�-I�I���	;��W�:�:�E��#��M�5��%��(E�E���
��,��!�=�#8��(�'�,�

8�
8���'��*�*���� � ��&�&�&��r#c��|jduSrA)r�r[s r"r�zPipeServer.closeds���
��%�&r#c���|j� |j���d|_|j�G|jD]}|����d|_d|_|j���dSdSrA)r�r5r�r��closer��clear)rr�s  r"r�zPipeServer.close"s����#�/��$�+�+�-�-�-�'+�D�$��=�$��,�
�
���
�
������D�J� �D�M�� �&�&�(�(�(�(�(�%�$r#N)
rHrIrJrKrr�r�r�r��__del__�r#r"r�r��sj��������4�4�4�������$'�'�'�
)�
)�
)��G�G�Gr#r�c��eZdZdZdS)�_WindowsSelectorEventLoopz'Windows version of selector event loop.N)rHrIrJrKr�r#r"r�r�1s������1�1�1�1r#r�c�D��eZdZdZd�fd�	Z�fd�Zd�Zd�Z	dd�Z�xZ	S)	rz2Windows version of proactor event loop using IOCP.Nc�j��|�t��}t���|��dSrA)rrr)rr�r!s  �r"rzProactorEventLoop.__init__8s0�����#�~�~�H�
������"�"�"�"�"r#c����	|�|j��t�����|j�Q|jj}|j���|�!|js|j�	|��d|_dSdS#|j�O|jj}|j���|�!|js|j�	|��d|_wxYwrA)
�	call_soon�_loop_self_readingr�run_forever�_self_reading_futurerr5r%r{r�)rr r!s  �r"r�zProactorEventLoop.run_forever=s����	1��N�N�4�2�3�3�3��G�G���!�!�!��(�4��.�2���)�0�0�2�2�2��>�"�*�>��N�.�.�r�2�2�2�,0��)�)�)�5�4��t�(�4��.�2���)�0�0�2�2�2��>�"�*�>��N�.�.�r�2�2�2�,0��)�0�0�0�0s�:B�AC/c��K�|j�|��}|�d{V��}|��}|�||d|i���}||fS)N�addr��extra)r{�connect_pipe�_make_duplex_pipe_transport)r�protocol_factoryr+�fr��protocol�transs       r"�create_pipe_connectionz(ProactorEventLoop.create_pipe_connectionPsl�����N�'�'��0�0���w�w�w�w�w�w��#�#�%�%���0�0��x�8>��7H�1�J�J���h��r#c��r�����K�t����d�����fd�	�������gS)Nc���d}	|r||���}�j�|������r|���dS���}��||d�i�������}|�dS�j�|��}|�_	|�
���dS#t$rG|r,|���dkr|�����
���YdSt$r�}|rF|���dkr.��d||d���|���n�jrt#jd|d�����
���Yd}~dSd}~wt&j$r|r|���YdSYdSwxYw)	Nr�r�rzPipe accept failed)r1r2r�zAccept pipe failed on pipe %rT)�exc_info)rGr��discardr�r�r�r�r{�accept_piper��add_done_callback�BrokenPipeError�filenor�r6r8�_debugr
�warningr�CancelledError)	r�r�r�r9r+�loop_accept_piper�r�servers	    �����r"r�z>ProactorEventLoop.start_serving_pipe.<locals>.loop_accept_pipe[sJ����D�)
6��A��8�8�:�:�D��*�2�2�4�8�8�8��}�}�����
�
������/�/�1�1�H��4�4��h�v�w�.?�5�A�A�A��3�3�5�5���<��F��N�.�.�t�4�4��*./��*��#�#�$4�5�5�5�5�5��+#�
1�
1�
1��!�D�K�K�M�M�R�/�/��J�J�L�L�L����/�0�0�0�0�0�0��
1�
1�
1��	8�D�K�K�M�M�R�/�/��/�/�#7�%(� $�1�1����
�J�J�L�L�L�L��[�8��N�#B�#'�$�8�8�8�8����/�0�0�0�0�0�0�0�0�0������,�
!�
!�
!��!��J�J�L�L�L�L�L�L�!�!�!�
!���s2�AC�:C�C�A
G�#	G�,A;F-�-(G�GrA)r�r�)rr�r+r�r�s```@@r"�start_serving_pipez$ProactorEventLoop.start_serving_pipeXsg����������G�$�$��+	6�+	6�+	6�+	6�+	6�+	6�+	6�+	6�+	6�+	6�Z	
���'�(�(�(��x�r#c	
��K�|���}
t||||||||f|
|d�|	��}	|
�d{V��nN#ttf$r�t$r0|���|����d{V���wxYw|S)N)�waiterr�)�
create_future�_WindowsSubprocessTransport�
SystemExit�KeyboardInterrupt�
BaseExceptionr��_wait)rr��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�7�06�7�7��	��L�L�L�L�L�L�L�L���-�.�	�	�	���	�	�	��L�L�N�N�N��,�,�.�.� � � � � � � ��	����
�
s
�8�ABrA)
rHrIrJrKrr�r�r�r�rLrMs@r"rr5s��������<�<�#�#�#�#�#�#�
1�1�1�1�1�&���1�1�1�j04��������r#rc���eZdZdZefd�Zd�Zd�Zd�Zd d�Z	d�Z
d!d
�Zd!d�Zd!d�Z
d!d
�Zd"d�Zd!d�Zd�Zd�Zd�Zd�Zd�Zd d�Zd�Zd�Zd�Zd�Zd�Zd�Zd d�Zd�Zd�Zd�Z dS)#rz#Proactor implementation using IOCP.c���d|_g|_tjtjt
d|��|_i|_tj	��|_
g|_tj	��|_dSrW)
r7�_resultsrf�CreateIoCompletionPort�INVALID_HANDLE_VALUEr��_iocp�_cacher�r�rS�
_unregistered�_stopped_serving)r�concurrencys  r"rzIocpProactor.__init__�sg����
���
� �7��,�d�A�{�D�D��
����"�?�,�,������ '�� 1� 1����r#c�2�|j�td���dS)NzIocpProactor is closed)r�rur[s r"�
_check_closedzIocpProactor._check_closed�s!���:���7�8�8�8��r#c���dt|j��zdt|j��zg}|j�|�d��d|jj�dd�|���d�S)Nzoverlapped#=%sz
result#=%sr��<� r()�lenr�r�r�r`r!rH�join)rr-s  r"�__repr__zIocpProactor.__repr__�sl�� �3�t�{�#3�#3�3��s�4�=�1�1�1�3���:���K�K��!�!�!�� �N�3�3�3�S�X�X�d�^�^�^�^�D�Dr#c��||_dSrA)r7)rrs  r"�set_loopzIocpProactor.set_loop�s
����
�
�
r#Nc�n�|js|�|��|j}g|_	|d}S#d}wxYwrA)r�r\)r�timeoutr�s   r"�selectzIocpProactor.select�sJ���}�	 ��J�J�w�����m����
�	���C�C��$�C�J�J�J�Js�0�4c�b�|j���}|�|��|SrA)r7r�rE)r�valuerbs   r"�_resultzIocpProactor._result�s,���j�&�&�(�(�����u�����
r#rc��|�|��tjt��}	t	|t
j��r*|�|���||��n(|�|���|��n%#t$r|�
d��cYSwxYwd�}|�|||��S)Nr#c��	|���S#t$r3}|jtjtjfvrt
|j���d}~wwxYwrA��	getresultr6rhrf�ERROR_NETNAME_DELETED�ERROR_OPERATION_ABORTED�ConnectionResetErrorr��r��keyr r9s    r"�finish_recvz&IocpProactor.recv.<locals>.finish_recv��f��
��|�|�~�~�%���
�
�
��<�K�$E�$/�$G�$I�I�I�.���9�9������
������
A�.A�A)�_register_with_iocprf�
Overlappedr��
isinstance�socket�WSARecvr��ReadFiler�r��	_register�r�conn�nbytesr�r rs      r"�recvzIocpProactor.recv�s���� � ��&�&�&�
�
#�D�
)�
)��	%��$��
�.�.�
3��
�
�4�;�;�=�=�&�%�8�8�8�8����D�K�K�M�M�6�2�2�2����	%�	%�	%��<�<��$�$�$�$�$�	%����	�	�	��~�~�b�$��4�4�4��A,B�B?�>B?c��|�|��tjt��}	t	|t
j��r*|�|���||��n(|�|���|��n%#t$r|�
d��cYSwxYwd�}|�|||��S)Nrc��	|���S#t$r3}|jtjtjfvrt
|j���d}~wwxYwrAr�rs    r"rz+IocpProactor.recv_into.<locals>.finish_recv�rr)rrfrr�r	r
�WSARecvIntor��ReadFileIntor�r�r
�rr�bufr�r rs      r"�	recv_intozIocpProactor.recv_into�s���� � ��&�&�&�
�
#�D�
)�
)��	#��$��
�.�.�
4����t�{�{�}�}�c�5�9�9�9�9�������
�
�s�3�3�3����	#�	#�	#��<�<��?�?�"�"�"�	#����	�	�	��~�~�b�$��4�4�4rc�2�|�|��tjt��}	|�|���||��n%#t$r|�d��cYSwxYwd�}|�|||��S)N�r#Nc���	|���S#t$rN}|jtjkrYd}~dS|jtjtjfvrt|j���d}~wwxYw)Nr�	r�r6rhrf�ERROR_PORT_UNREACHABLEr�rrr�rs    r"rz*IocpProactor.recvfrom.<locals>.finish_recvs���
��|�|�~�~�%���	
�	
�	
��<�;�#E�E�E�$�9�9�9�9�9��<�K�$E�$/�$G�$I�I�I�.���9�9������	
������
A.�A)�.A)�)A.)	rrfrr��WSARecvFromr�r�r�r
rs      r"�recvfromzIocpProactor.recvfrom�s���� � ��&�&�&�
�
#�D�
)�
)��	-��N�N�4�;�;�=�=�&�%�8�8�8�8���	-�	-�	-��<�<��,�,�,�,�,�	-����	�	�	��~�~�b�$��4�4�4��)A�A<�;A<c�2�|�|��tjt��}	|�|���||��n%#t$r|�d��cYSwxYwd�}|�|||��S)N�rNc���	|���S#t$rN}|jtjkrYd}~dS|jtjtjfvrt|j���d}~wwxYw)Nr$rrs    r"rz/IocpProactor.recvfrom_into.<locals>.finish_recvs���
��|�|�~�~�%���	
�	
�	
��<�;�#E�E�E�"�7�7�7�7�7��<�K�$E�$/�$G�$I�I�I�.���9�9������	
���r)	rrfrr��WSARecvFromIntor�r�r�r
rs      r"�
recvfrom_intozIocpProactor.recvfrom_intos���� � ��&�&�&�
�
#�D�
)�
)��	+����t�{�{�}�}�c�5�9�9�9�9���	+�	+�	+��<�<�	�*�*�*�*�*�	+����	�	�	��~�~�b�$��4�4�4r"c���|�|��tjt��}|�|���|||��d�}|�|||��S)Nc��	|���S#t$r3}|jtjtjfvrt
|j���d}~wwxYwrAr�rs    r"�finish_sendz(IocpProactor.sendto.<locals>.finish_send.rr)rrfrr��	WSASendTor�r
)rrrr�r�r r*s       r"�sendtozIocpProactor.sendto(sm��� � ��&�&�&�
�
#�D�
)�
)��
���T�[�[�]�]�C���5�5�5�	�	�	��~�~�b�$��4�4�4r#c�j�|�|��tjt��}t	|t
j��r*|�|���||��n(|�|���|��d�}|�	|||��S)Nc��	|���S#t$r3}|jtjtjfvrt
|j���d}~wwxYwrAr�rs    r"r*z&IocpProactor.send.<locals>.finish_sendBrr)
rrfrr�r	r
�WSASendr��	WriteFiler
)rrrr�r r*s      r"�sendzIocpProactor.send:s���� � ��&�&�&�
�
#�D�
)�
)���d�F�M�*�*�	-��J�J�t�{�{�}�}�c�5�1�1�1�1��L�L�������,�,�,�	�	�	��~�~�b�$��4�4�4r#c����|����|��j���tjt
��}|�������������fd�}d�}|�|�|��}||���}tj
||j���|S)Nc�J��|���tjd������}��t
jtj|����	��
���������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_acceptTs�����L�L�N�N�N��+�d�H�O�O�$5�$5�6�6�C��O�O�F�-�'�@�#�
G�
G�
G��O�O�H�/�/�1�1�2�2�2���)�)�+�+�+�+r#c��lK�	|�d{V��dS#tj$r|����wxYwrA)rr�r�)r3rs  r"�accept_coroz(IocpProactor.accept.<locals>.accept_coro]sN����
�������������,�
�
�
��
�
�����
���s��%3r)r�_get_accept_socket�familyrfrr��AcceptExr�r
r�
ensure_futurer7)rr<r r=r?r3�corors `     @r"�acceptzIocpProactor.acceptNs������ � ��*�*�*��&�&�x��7�7��
�
#�D�
)�
)��
���H�O�O�%�%�t�{�{�}�}�5�5�5�	,�	,�	,�	,�	,�	,�	�	�	�����H�m�<�<���{�6�4�(�(��
��D�t�z�2�2�2�2��
r#c����jtjkrWtj����|��|j���}|�d��|S|�	���	tj
�����j��nL#t$r?}|j
tjkr�����ddkr�Yd}~nd}~wwxYwtjt$��}|�����|���fd�}|�|�|��S)Nrrc���|�����tjtjd���SrW)r�r6r
r7rf�SO_UPDATE_CONNECT_CONTEXT)r�rr rs   �r"�finish_connectz,IocpProactor.connect.<locals>.finish_connect�s;����L�L�N�N�N��O�O�F�-�'�A�1�
F�
F�
F��Kr#)�typer
�
SOCK_DGRAMrf�
WSAConnectr�r7r�rEr�	BindLocalrAr6rh�errno�	WSAEINVAL�getsocknamerr��	ConnectExr
)rrr+rb�er rIs `     r"�connectzIocpProactor.connectjsS����9��)�)�)�
�"�4�;�;�=�=�'�:�:�:��*�*�*�,�,�C��N�N�4� � � ��J�� � ��&�&�&�	��!�$�+�+�-�-���=�=�=�=���	�	�	��z�U�_�,�,�����!�!�!�$��)�)��*�)�)�)�)�����		�����
#�D�
)�
)��
���T�[�[�]�]�G�,�,�,�	�	�	�	�	��~�~�b�$��7�7�7s�,B1�1
C:�;5C5�5C:c	�N�|�|��tjt��}|dz}|dz	dz}|�|���t
j|�����|||dd��d�}|�|||��S)Nl��� rc��	|���S#t$r3}|jtjtjfvrt
|j���d}~wwxYwrAr�rs    r"�finish_sendfilez.IocpProactor.sendfile.<locals>.finish_sendfile�rr)	rrfrr��TransmitFiler��msvcrt�
get_osfhandler
)	r�sock�file�offset�countr �
offset_low�offset_highrWs	         r"�sendfilezIocpProactor.sendfile�s���� � ��&�&�&�
�
#�D�
)�
)���k�)�
���|�{�2��
������
�
��,�T�[�[�]�]�;�;�"�K��q�!�	%�	%�	%�
	�	�	��~�~�b�$��8�8�8r#c���|����tjt��}|�������}|r|����S�fd�}|�|�|��S)Nc�0��|����SrA)r�)r�rr r�s   �r"�finish_accept_pipez4IocpProactor.accept_pipe.<locals>.finish_accept_pipe�s����L�L�N�N�N��Kr#)rrfrr��ConnectNamedPiper�r�r
)rr�r �	connectedrds `   r"r�zIocpProactor.accept_pipe�s����� � ��&�&�&�
�
#�D�
)�
)���'�'����
�
�6�6�	��	&��<�<��%�%�%�	�	�	�	�	��~�~�b�$�(:�;�;�;r#c��*K�t}		tj|��}n`#t$r }|jtjkr�Yd}~nd}~wwxYwt
|dzt��}tj	|���d{V���vtj|��S)NT�)�CONNECT_PIPE_INIT_DELAYrf�ConnectPiper6rh�ERROR_PIPE_BUSY�min�CONNECT_PIPE_MAX_DELAYr�sleeprr�)rr+�delayrTr9s     r"r�zIocpProactor.connect_pipe�s�����'��
	%�
�$�0��9�9�����
�
�
��<�;�#>�>�>��?�>�>�>�>�����
����
���	�#9�:�:�E��+�e�$�$�$�$�$�$�$�$�$�
	%��'��/�/�/s�!�
A�A�Ac�0�|�||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)rrTr�s   r"�wait_for_handlezIocpProactor.wait_for_handle�s���$�$�V�W�e�<�<�<r#c�B�|�|dd��}||_|Sr�)rqrr)rrs�
done_callbackrbs    r"r�zIocpProactor._wait_cancel�s(���#�#�E�4��6�6��+����
r#c���|���|�
tj}ntj|dz��}tjt��}tj||j	|j
|��}|rt||||j����nt|||||j�����jr�jd=�fd�}�|d|f|j|j
<�S)N�@�@rrc�,������SrA)r\)r�rr r�s   �r"�finish_wait_for_handlez=IocpProactor._wait_for_handle.<locals>.finish_wait_for_handle�s����7�7�9�9�r#r)r�rX�INFINITE�math�ceilrfrr��RegisterWaitWithQueuer�r+rpr7ryrr�)	rrTr��
_is_cancel�msr rUrxr�s	        @r"rqzIocpProactor._wait_for_handle�s�����������?��!�B�B���7�S�=�)�)�B��
#�D�
)�
)��!�7��D�J��
�B�0�0���	3�!�"�f�k��
�K�K�K�A�A�!�"�f�k�4�'+�z�3�3�3�A���	(��#�B�'�	�	�	�	�	�$%�b�!�-C�"D���B�J���r#c��||jvrJ|j�|��tj|���|jdd��dSdSrW)rSr�rfr�r�r��r�objs  r"rz IocpProactor._register_with_iocp�sX���d�&�&�&��� � ��%�%�%��.�s�z�z�|�|�T�Z��A�N�N�N�N�N�'�&r#c�L�|���t||j���}|jr|jd=|jsP	|dd|��}|�|��n,#t$r}|�|��Yd}~nd}~wwxYw||||f|j|j	<|Sr)
r�rr7rr%rEr6rBr�r+)rr r��callbackr�r�rRs       r"r
zIocpProactor._register�s���������

�b�t�z�2�2�2����	(��#�B�'��z�
	$�

$� ���t�R�0�0�����U�#�#�#�#���
#�
#�
#�����"�"�"�"�"�"�"�"�����
#����$%�b�#�x�"8���B�J���s�
A%�%
B�/B	�	Bc�b�|���|j�|��dS)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�r`)rr s  r"r�zIocpProactor._unregisters3��	
��������!�!�"�%�%�%�%�%r#c�X�tj|��}|�d��|SrW)r
r9)rrA�ss   r"r@zIocpProactor._get_accept_socket's%���M�&�!�!��	���Q�����r#c	�$�|�t}nF|dkrtd���tj|dz��}|tkrtd���	t	j|j|��}|��n]d}|\}}}}	|j�|��\}}	}
}nq#t$rd|j
���r$|j
�dd||||fzd���|dtj
fvrtj|��Y��wxYw|
|jvr|���n�|���s�	||||	��}|�|��|j�|��nF#t,$r9}
|�|
��|j�|��Yd}
~
nd}
~
wwxYwd}n#d}wxYw��{|jD]"}	|j�|	jd���#|j���dS)	Nrznegative timeoutrvztimeout too bigTz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r1�status)ry�
ValueErrorrzr{rf�GetQueuedCompletionStatusr�r��pop�KeyErrorr7�	get_debugr8r�rXr�r�r5�donerEr�r`r6rBr�r+r�)rr�r~r��err�transferredrr+r�r r�r�r�rRs              r"r\zIocpProactor._poll,sy���?��B�B�
�q�[�[��/�0�0�0���7�S�=�)�)�B��X�~�~� �!2�3�3�3�&	� �:�4�:�r�J�J�F��~���B�-3�*�C��c�7�
�'+�{���w�'?�'?�$��2�s�H�H���

�

�

��:�'�'�)�)���J�5�5�%7�#N�&)�;��W�%E�$F�7�7�����q�+�"B�C�C�C��'��,�,�,���

�����d�+�+�+����
�
�
�
��V�V�X�X�

�	�$�H�[�#�r�:�:�E�
�L�L��'�'�'��M�(�(��+�+�+�+���,�,�,��O�O�A�&�&�&��M�(�(��+�+�+�+�+�+�+�+�����,�����A�A���A�H�H�H�H�M&	�R�$�	.�	.�B��K�O�O�B�J��-�-�-�-��� � �"�"�"�"�"sC�:B�A+D�D�>
E;�0G�;
F>�/F9�4G�9F>�>G�Gc�:�|j�|��dSrA)r�r�r�s  r"�
_stop_servingzIocpProactor._stop_servinges!��	
��!�!�#�&�&�&�&�&r#c��|j�dSt|j�����D]�\}}}}|���r�t|t��r�2	|����H#t$rB}|j	�1d||d�}|j
r
|j
|d<|j	�|��Yd}~��d}~wwxYwd}tj
��}||z}	|jrs|	tj
��kr@tjd|tj
��|z
��tj
��|z}	|�|��|j�sg|_t%j|j��d|_dS)NzCancelling a future failedr0r4g�?z,%r is running after closing for %.1f seconds)r��listr��values�	cancelledr	rpr5r6r7rr8�time�	monotonicr
�debugr\r�rXr�)
rrbr r�r�r9r:�
msg_update�
start_time�next_msgs
          r"r�zIocpProactor.closeks����:���F�'+�4�;�+=�+=�+?�+?�&@�&@�	C�	C�"�C��S�(��}�}���
C���C�!2�3�3�
C��C��J�J�L�L�L�L���	C�	C�	C��z�-�'C�),�&)�#�#��
�0�P�:=�:O�G�$6�7��
�9�9�'�B�B�B����������	C�����
��^�%�%�
��
�*���k�	#��4�>�+�+�+�+���K�!�4�>�#3�#3�j�#@�B�B�B��>�+�+�j�8��
�J�J�z�"�"�"��k�	#���
���D�J�'�'�'���
�
�
s�#A8�8
C�8B?�?Cc�.�|���dSrA)r�r[s r"r�zIocpProactor.__del__�s���
�
�����r#rA)rr$)!rHrIrJrKryrr�r�r�r�r�rrr!r'r,r1rErSrar�r�rrr�rqrr
r�r@r\r�r�r�r�r#r"rr�s�������-�-�#+�2�2�2�2�9�9�9�E�E�E����	�	�	�	����
5�5�5�5�.5�5�5�5�.5�5�5�5�05�5�5�5�05�5�5�5�$5�5�5�5�(���88�8�8�>9�9�9�*<�<�<�"0�0�0�&=�=�=�=���� � � �DO�O�O����@&�&�&����
7#�7#�7#�7#�r'�'�'�-�-�-�^����r#rc��eZdZd�ZdS)r�c	����tj|f|||||d�|���_�fd�}�jj�t
�jj����}	|	�|��dS)N)r�r�r�r�r�c�d���j���}��|��dSrA)�_proc�poll�_process_exited)r��
returncoders  �r"r�z4_WindowsSubprocessTransport._start.<locals>.callback�s.�������*�*�J�� � ��,�,�,�,�,r#)	r�Popenr�r7r{rr�intrQr�)
rr�r�r�r�r�r�r�r�r�s
`         r"�_startz"_WindowsSubprocessTransport._start�s����"�(��'��U�6�&��'�'�%�'�'��
�	-�	-�	-�	-�	-�
�J� �0�0��T�Z�5G�1H�1H�I�I��	���H�%�%�%�%�%r#N)rHrIrJr�r�r#r"r�r��s#������
&�
&�
&�
&�
&r#r�c��eZdZeZdS)rN)rHrIrJr�
_loop_factoryr�r#r"rr��������%�M�M�Mr#rc��eZdZeZdS)rN)rHrIrJrr�r�r#r"rr�r�r#r)2rK�sys�platform�ImportErrorrfrXrNrzrYr
r4r�r��rrrrr	r
rr�logr
�__all__r�ry�ERROR_CONNECTION_REFUSED�ERROR_CONNECTION_ABORTEDrirm�FuturerrOrpry�objectr��BaseSelectorEventLoopr��BaseProactorEventLooprr�BaseSubprocessTransportr�r�BaseDefaultEventLoopPolicyrrrr�r#r"�<module>r�sx��4�4�
�
�
�
��<�7���
�+�l�
#�
#�#�����������������
�
�
�
�
�
�
�
�
�
�
�
������������������������������������������������������������������|��������� ����-�-�-�-�-���-�-�-�`G#�G#�G#�G#�G#�G�N�G#�G#�G#�T&�&�&�&�&�-�&�&�&�01P�1P�1P�1P�1P�-�1P�1P�1P�h8�8�8�8�8��8�8�8�v2�2�2�2�2�� E�2�2�2�g�g�g�g�g��=�g�g�g�T|�|�|�|�|�|�|�|�~&�&�&�&�&�/�"I�&�&�&�.��&�&�&�&�&�V�%F�&�&�&�&�&�&�&�&�V�%F�&�&�&�8���r#

?>