Your IP : 13.58.110.182


Current Path : /lib64/python3.8/asyncio/__pycache__/
Upload File :
Current File : //lib64/python3.8/asyncio/__pycache__/windows_events.cpython-38.opt-2.pyc

U

e5di��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	mZddl	m
Z
ddl	mZddl	mZdd	l	mZdd
l	mZddlmZdZdZd
ZdZdZdZdZGdd�dej�ZGdd�dej�ZGdd�de�ZGdd�de�ZGdd�de �Z!Gdd�dej"�Z#Gdd�dej$�Z%Gd d!�d!�Z&Gd"d#�d#ej'�Z(e#Z)Gd$d%�d%e
j*�Z+Gd&d'�d'e
j*�Z,e,Z-dS)(�N�)�events)�base_subprocess)�futures)�
exceptions)�proactor_events)�selector_events)�tasks)�
windows_utils)�logger)�SelectorEventLoop�ProactorEventLoop�IocpProactor�DefaultEventLoopPolicy�WindowsSelectorEventLoopPolicy�WindowsProactorEventLoopPolicy���i�i�g����MbP?g�������?csZeZdZdd��fdd�
Z�fdd�Zdd�Z�fd	d
�Z�fdd�Z�fd
d�Z�Z	S)�_OverlappedFutureN��loopcs&t�j|d�|jr|jd=||_dS�Nr���)�super�__init__�_source_traceback�_ov)�self�ovr��	__class__��./usr/lib64/python3.8/asyncio/windows_events.pyr1sz_OverlappedFuture.__init__csHt���}|jdk	rD|jjr dnd}|�dd|�d|jjd�d��|S)N�pendingZ	completedrzoverlapped=<z, �#x�>)r�
_repr_inforr"�insert�address�r�info�staterr r!r%7s


 z_OverlappedFuture._repr_infoc
Csr|jdkrdSz|j��WnJtk
rf}z,d||d�}|jrJ|j|d<|j�|�W5d}~XYnXd|_dS)Nz&Cancelling an overlapped future failed��message�	exception�future�source_traceback)r�cancel�OSErrorr�_loop�call_exception_handler)r�exc�contextr r r!�_cancel_overlapped>s
�
z$_OverlappedFuture._cancel_overlappedcs|��t���S�N)r6rr0�rrr r!r0Nsz_OverlappedFuture.cancelcst��|�|��dSr7)r�
set_exceptionr6�rr-rr r!r9Rsz_OverlappedFuture.set_exceptioncst��|�d|_dSr7)r�
set_resultr�r�resultrr r!r;Vsz_OverlappedFuture.set_result)
�__name__�
__module__�__qualname__rr%r6r0r9r;�
__classcell__r r rr!r+srcsjeZdZdd��fdd�
Zdd�Z�fdd�Zd	d
�Zdd�Z�fd
d�Z�fdd�Z	�fdd�Z
�ZS)�_BaseWaitHandleFutureNrcs8t�j|d�|jr|jd=||_||_||_d|_dS)NrrT)rrrr�_handle�_wait_handle�_registered)rr�handle�wait_handlerrr r!r^sz_BaseWaitHandleFuture.__init__cCst�|jd�tjkS�Nr)�_winapiZWaitForSingleObjectrCZ
WAIT_OBJECT_0r8r r r!�_pollls�z_BaseWaitHandleFuture._pollcsdt���}|�d|jd���|jdk	rB|��r4dnd}|�|�|jdk	r`|�d|jd���|S)Nzhandle=r#ZsignaledZwaitingzwait_handle=)rr%�appendrCrJrDr(rr r!r%qs



z _BaseWaitHandleFuture._repr_infocCs
d|_dSr7)r�r�futr r r!�_unregister_wait_cb{sz)_BaseWaitHandleFuture._unregister_wait_cbc
Cs�|js
dSd|_|j}d|_zt�|�Wn`tk
r�}zB|jtjkrzd||d�}|jrd|j|d<|j�	|�WY�dSW5d}~XYnX|�
d�dS�NFz$Failed to unregister the wait handler+r/)rErD�_overlappedZUnregisterWaitr1�winerror�ERROR_IO_PENDINGrr2r3rN�rrGr4r5r r r!�_unregister_wait�s$�
z&_BaseWaitHandleFuture._unregister_waitcs|��t���Sr7)rTrr0r8rr r!r0�sz_BaseWaitHandleFuture.cancelcs|��t��|�dSr7)rTrr9r:rr r!r9�sz#_BaseWaitHandleFuture.set_exceptioncs|��t��|�dSr7)rTrr;r<rr r!r;�sz _BaseWaitHandleFuture.set_result)r>r?r@rrJr%rNrTr0r9r;rAr r rr!rB[s
rBcsBeZdZdd��fdd�
Zdd�Z�fdd�Z�fd	d
�Z�ZS)�_WaitCancelFutureNrcst�j||||d�d|_dS)Nr)rr�_done_callback)rr�eventrGrrr r!r�sz_WaitCancelFuture.__init__cCstd��dS)Nz'_WaitCancelFuture must not be cancelled)�RuntimeErrorr8r r r!r0�sz_WaitCancelFuture.cancelcs$t��|�|jdk	r |�|�dSr7)rr;rVr<rr r!r;�s
z_WaitCancelFuture.set_resultcs$t��|�|jdk	r |�|�dSr7)rr9rVr:rr r!r9�s
z_WaitCancelFuture.set_exception)r>r?r@rr0r;r9rAr r rr!rU�srUcs6eZdZdd��fdd�
Z�fdd�Zdd�Z�ZS)	�_WaitHandleFutureNrcs<t�j||||d�||_d|_t�dddd�|_d|_dS)NrTF)rr�	_proactorZ_unregister_proactorrPZCreateEvent�_event�
_event_fut)rrrFrG�proactorrrr r!r�s
z_WaitHandleFuture.__init__csF|jdk	r"t�|j�d|_d|_|j�|j�d|_t��|�dSr7)	r[rI�CloseHandler\rZ�_unregisterrrrNrLrr r!rN�s
	z%_WaitHandleFuture._unregister_wait_cbc
Cs�|js
dSd|_|j}d|_zt�||j�Wn`tk
r�}zB|jtjkr~d||d�}|jrh|j|d<|j	�
|�WY�dSW5d}~XYnX|j�|j|j
�|_dSrO)rErDrPZUnregisterWaitExr[r1rQrRrr2r3rZ�_wait_cancelrNr\rSr r r!rT�s(�

�z"_WaitHandleFuture._unregister_wait)r>r?r@rrNrTrAr r rr!rY�srYc@s8eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZeZdS)�
PipeServercCs,||_t��|_d|_d|_|�d�|_dS�NT)�_address�weakref�WeakSet�_free_instances�_pipe�_accept_pipe_future�_server_pipe_handle)rr'r r r!r�s

zPipeServer.__init__cCs|j|�d�}|_|S�NF)rgri)r�tmpr r r!�_get_unconnected_pipesz PipeServer._get_unconnected_pipec
Csr|��rdStjtjB}|r&|tjO}t�|j|tjtjBtj	Btj
tjtjtj
tj�}t�|�}|j�|�|Sr7)�closedrIZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPipercZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ	PIPE_WAITZPIPE_UNLIMITED_INSTANCESr
ZBUFSIZEZNMPWAIT_WAIT_FOREVER�NULL�
PipeHandlerf�add)r�first�flags�h�piper r r!ris(

��
zPipeServer._server_pipe_handlecCs
|jdkSr7)rcr8r r r!rmszPipeServer.closedcCsR|jdk	r|j��d|_|jdk	rN|jD]}|��q*d|_d|_|j��dSr7)rhr0rcrf�closerg�clear)rrtr r r!rus




zPipeServer.closeN)	r>r?r@rrlrirmru�__del__r r r r!ra�s
rac@seZdZdS)�_WindowsSelectorEventLoopN)r>r?r@r r r r!rx,srxcsDeZdZd�fdd�	Z�fdd�Zdd�Zdd	�Zd
d
d�Z�ZS)r
Ncs|dkrt�}t��|�dSr7)rrr)rr]rr r!r3szProactorEventLoop.__init__c	sXz|�|j�t���W5|jdk	rR|jj}|j��|dk	rL|j�|�d|_XdSr7)	Z_self_reading_futurerr0rZr_�	call_soonZ_loop_self_readingr�run_forever�rrrr r!rz8s

zProactorEventLoop.run_foreverc�s8|j�|�}|IdH}|�}|j||d|id�}||fS)N�addr��extra)rZ�connect_pipe�_make_duplex_pipe_transport)r�protocol_factoryr'�frt�protocol�transr r r!�create_pipe_connectionKs
�z(ProactorEventLoop.create_pipe_connectionc�s.t���d�����fdd�	������gS)Nc
sd}zn|rN|��}�j�|����r4|��WdS��}�j||d�id����}|dkrdWdS�j�|�}Wn�t	k
r�}zF|r�|�
�dkr���d||d��|��n�jr�t
jd|dd�W5d}~XYn2tjk
r�|r�|��YnX|�_|���dS)	Nr|r}rzPipe accept failed)r,r-rtzAccept pipe failed on pipe %rT)�exc_info)r=rf�discardrmrur�rlrZ�accept_piper1�filenor3Z_debugrZwarningr�CancelledErrorrh�add_done_callback)r�rtr�r4�r'�loop_accept_piper�rZserverr r!r�VsH��
�z>ProactorEventLoop.start_serving_pipe.<locals>.loop_accept_pipe)N)rary)rr�r'r r�r!�start_serving_pipeSs(
z$ProactorEventLoop.start_serving_pipec		�s�|��}
t||||||||f|
|d�|	��}z|
IdHWnDttfk
rT�Yn,tk
r~|��|��IdH�YnX|S)N)�waiterr~)�
create_future�_WindowsSubprocessTransport�
SystemExit�KeyboardInterrupt�
BaseExceptionruZ_wait)rr��args�shell�stdin�stdout�stderr�bufsizer~�kwargsr�Ztranspr r r!�_make_subprocess_transport�s*
���z,ProactorEventLoop._make_subprocess_transport)N)N)	r>r?r@rrzr�r�r�rAr r rr!r
0s0�r
c@s�eZdZd:dd�Zdd�Zdd�Zdd	�Zd;dd�Zd
d�Zd<dd�Z	d=dd�Z
d>dd�Zd?dd�Zd@dd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�ZdAd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�ZdBd2d3�Zd4d5�Zd6d7�Zd8d9�Zd
S)CrrcCsDd|_g|_t�tjtd|�|_i|_t�	�|_
g|_t�	�|_dSrH)
r2�_resultsrP�CreateIoCompletionPort�INVALID_HANDLE_VALUErn�_iocp�_cacherdrerE�
_unregistered�_stopped_serving)rZconcurrencyr r r!r�s�
zIocpProactor.__init__cCs|jdkrtd��dS)NzIocpProactor is closed)r�rXr8r r r!�
_check_closed�s
zIocpProactor._check_closedcCsFdt|j�dt|j�g}|jdkr0|�d�d|jjd�|�fS)Nzoverlapped#=%sz
result#=%srmz<%s %s>� )�lenr�r�r�rKrr>�join)rr)r r r!�__repr__�s�

zIocpProactor.__repr__cCs
||_dSr7)r2)rrr r r!�set_loop�szIocpProactor.set_loopNcCs |js|�|�|j}g|_|Sr7)r�rJ)r�timeoutrkr r r!�select�s

zIocpProactor.selectcCs|j��}|�|�|Sr7)r2r�r;)r�valuerMr r r!�_result�s

zIocpProactor._resultrcCs~|�|�t�t�}z4t|tj�r6|�|��||�n|�|��|�Wnt	k
rf|�
d�YSXdd�}|�|||�S)N�c
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7��	getresultr1rQrPZERROR_NETNAME_DELETEDZERROR_OPERATION_ABORTED�ConnectionResetErrorr��r��keyrr4r r r!�finish_recv�s
�z&IocpProactor.recv.<locals>.finish_recv)�_register_with_iocprP�
Overlappedrn�
isinstance�socketZWSARecvr�ZReadFile�BrokenPipeErrorr��	_register�r�conn�nbytesrrrr�r r r!�recv�s


zIocpProactor.recvcCs~|�|�t�t�}z4t|tj�r6|�|��||�n|�|��|�Wnt	k
rf|�
d�YSXdd�}|�|||�S)Nrc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!r��s
�z+IocpProactor.recv_into.<locals>.finish_recv)r�rPr�rnr�r�ZWSARecvIntor�ZReadFileIntor�r�r�)rr��bufrrrr�r r r!�	recv_into�s


zIocpProactor.recv_intocCs`|�|�t�t�}z|�|��||�Wntk
rH|�d�YSXdd�}|�|||�S)N)r�Nc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!r��s
�z*IocpProactor.recvfrom.<locals>.finish_recv)	r�rPr�rnZWSARecvFromr�r�r�r�r�r r r!�recvfrom�s


zIocpProactor.recvfromcCs>|�|�t�t�}|�|��|||�dd�}|�|||�S)Nc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!�finish_sends
�z(IocpProactor.sendto.<locals>.finish_send)r�rPr�rnZ	WSASendTor�r�)rr�r�rrr|rr�r r r!�sendto�s



zIocpProactor.sendtocCsZ|�|�t�t�}t|tj�r4|�|��||�n|�|��|�dd�}|�	|||�S)Nc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!r�s
�z&IocpProactor.send.<locals>.finish_send)
r�rPr�rnr�r�ZWSASendr�Z	WriteFiler�)rr�r�rrrr�r r r!�sends


zIocpProactor.sendcsv|���|��j��t�t�}|����������fdd�}dd�}|�|�|�}||��}t	j
||jd�|S)NcsD|��t�d����}��tjtj|���	��
������fS)Nz@P)r��structZpackr��
setsockoptr��
SOL_SOCKETrPZSO_UPDATE_ACCEPT_CONTEXT�
settimeoutZ
gettimeoutZgetpeername)r�r�rr��r��listenerr r!�
finish_accept*s�z*IocpProactor.accept.<locals>.finish_acceptc�s4z|IdHWn tjk
r.|���YnXdSr7)rr�ru)r.r�r r r!�accept_coro3s
z(IocpProactor.accept.<locals>.accept_coror)r��_get_accept_socket�familyrPr�rnZAcceptExr�r�r	Z
ensure_futurer2)rr�rr�r�r.�coror r�r!�accept$s

	
zIocpProactor.acceptc
s��jtjkr4t����|�|j��}|�d�|S|�	��zt�
����j�WnBtk
r�}z$|j
tjkrt����ddkr��W5d}~XYnXt�t�}|����|��fdd�}|�|�|�S)Nrrcs|����tjtjd��SrH)r�r�r�r�rPZSO_UPDATE_CONNECT_CONTEXT�r�r�r�r�r r!�finish_connectVs�z,IocpProactor.connect.<locals>.finish_connect)�typer�Z
SOCK_DGRAMrPZ
WSAConnectr�r2r�r;r�Z	BindLocalr�r1rQ�errnoZ	WSAEINVALZgetsocknamer�rnZ	ConnectExr�)rr�r'rM�err�r r�r!�connect@s"



zIocpProactor.connectc		Csb|�|�t�t�}|d@}|d?d@}|�|��t�|���|||dd�dd�}|�|||�S)Nr� rc
SsRz
|��WStk
rL}z$|jtjtjfkr:t|j��n�W5d}~XYnXdSr7r�r�r r r!�finish_sendfileis
�z.IocpProactor.sendfile.<locals>.finish_sendfile)	r�rPr�rnZTransmitFiler��msvcrtZ
get_osfhandler�)	rZsock�file�offset�countrZ
offset_lowZoffset_highr�r r r!�sendfile_s


�	zIocpProactor.sendfilecsJ|���t�t�}|�����}|r0|���S�fdd�}|�|�|�S)Ncs|���Sr7)r�r��rtr r!�finish_accept_pipesz4IocpProactor.accept_pipe.<locals>.finish_accept_pipe)r�rPr�rnZConnectNamedPiper�r�r�)rrtrZ	connectedr�r r�r!r�ts


zIocpProactor.accept_pipec
�srt}zt�|�}WqhWn0tk
rF}z|jtjkr6�W5d}~XYnXt|dt�}t�	|�IdHqt
�|�S)N�)�CONNECT_PIPE_INIT_DELAYrPZConnectPiper1rQZERROR_PIPE_BUSY�min�CONNECT_PIPE_MAX_DELAYr	�sleepr
ro)rr'ZdelayrFr4r r r!r�s
zIocpProactor.connect_pipecCs|�||d�Srj)�_wait_for_handle)rrFr�r r r!�wait_for_handle�szIocpProactor.wait_for_handlecCs|�|dd�}||_|Srb)r�rV)rrWZ
done_callbackrMr r r!r`�szIocpProactor._wait_cancelcs�|��|dkrtj}nt�|d�}t�t�}t�||j	|j
|�}|r\t||||jd��nt
|||||jd���jr~�jd=�fdd�}�|d|f|j|j
<�S)N�@�@rrcs���Sr7)rJr��r�r r!�finish_wait_for_handle�sz=IocpProactor._wait_for_handle.<locals>.finish_wait_for_handler)r�rI�INFINITE�math�ceilrPr�rnZRegisterWaitWithQueuer�r'rUr2rYrr�)rrFr�Z
_is_cancel�msrrGr�r r�r!r��s*
�
�	zIocpProactor._wait_for_handlecCs0||jkr,|j�|�t�|��|jdd�dSrH)rErprPr�r�r��r�objr r r!r��s
z IocpProactor._register_with_iocpc
Cs�|��t||jd�}|jr$|jd=|jsrz|dd|�}Wn,tk
rf}z|�|�W5d}~XYnX|�|�||||f|j|j	<|Sr)
r�rr2rr"r1r9r;r�r')rrr��callbackr�r�r�r r r!r��s

zIocpProactor._registercCs|��|j�|�dSr7)r�r�rKr{r r r!r_�szIocpProactor._unregistercCst�|�}|�d�|SrH)r�r�)rr��sr r r!r��s

zIocpProactor._get_accept_socketcCs�|dkrt}n0|dkr td��nt�|d�}|tkr>td��t�|j|�}|dkrX�qZd}|\}}}}z|j�|�\}}	}
}WnXt	k
r�|j
��r�|j
�dd||||fd��|dtj
fkr�t�|�Yq>YnX|
|jkr�|��q>|��s>z||||	�}Wn:tk
�r@}
z|�|
�|j�|�W5d}
~
XYq>X|�|�|j�|�q>|jD]}	|j�|	jd��q`|j��dS)Nrznegative timeoutr�ztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r,�status)r��
ValueErrorr�r�rPZGetQueuedCompletionStatusr�r��pop�KeyErrorr2Z	get_debugr3r�rIr^r�r0Zdoner1r9r�rKr;r�r'rv)rr�r�r��errZtransferredr�r'r�rr�r�r�r�r r r!rJsL


��	






zIocpProactor._pollcCs|j�|�dSr7)r�rpr�r r r!�
_stop_serving9szIocpProactor._stop_servingcCs|jdkrdSt|j���D]�\}\}}}}|��r6qt|t�rBqz|��Wqtk
r�}z6|j	dk	r�d||d�}|j
r�|j
|d<|j	�|�W5d}~XYqXqd}t�
�}	|	|}
|jr�|
t�
�kr�t�d|t�
�|	�t�
�|}
|�|�q�g|_t�|j�d|_dS)NzCancelling a future failedr+r/g�?z,%r is running after closing for %.1f seconds)r��listr��itemsZ	cancelledr�rUr0r1r2rr3�time�	monotonicr�debugrJr�rIr^)rr'rMrr�r�r4r5Z
msg_updateZ
start_timeZnext_msgr r r!ru?s@


�
 
�zIocpProactor.closecCs|��dSr7)rur8r r r!rwnszIocpProactor.__del__)r)N)r)r)r)rN)r)N)N)r>r?r@rr�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r`r�r�r�r_r�rJr�rurwr r r r!r�s6








"
 

7/rc@seZdZdd�ZdS)r�c
sPtj|f|||||d�|���_�fdd�}�jj�t�jj��}	|	�|�dS)N)r�r�r�r�r�cs�j��}��|�dSr7)�_procZpollZ_process_exited)r��
returncoder8r r!r�ys
z4_WindowsSubprocessTransport._start.<locals>.callback)	r
�Popenr�r2rZr��intrCr�)
rr�r�r�r�r�r�r�r�r�r r8r!�_startts���z"_WindowsSubprocessTransport._startN)r>r?r@rr r r r!r�rsr�c@seZdZeZdS)rN)r>r?r@r�
_loop_factoryr r r r!r�src@seZdZeZdS)rN)r>r?r@r
rr r r r!r�sr).rPrIr�r�r�r�r�r�rd�rrrrrrr	r
�logr�__all__rnr�ZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDr�r�ZFuturerrBrUrY�objectraZBaseSelectorEventLooprxZBaseProactorEventLoopr
rZBaseSubprocessTransportr�rZBaseDefaultEventLoopPolicyrrrr r r r!�<module>sP0J4;e`

?>