AlkantarClanX12

Your IP : 3.137.198.143


Current Path : /opt/alt/python37/lib64/python3.7/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/asyncio/__pycache__/windows_events.cpython-37.opt-2.pyc

B

YI~dv�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	mZddl	m
Z
ddl	mZddl	mZdd	l	mZdd
lmZdZdZdZd
ZdZdZdZGdd�dej�ZGdd�dej�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�dej!�Z"Gdd�de
j#�Z$Gdd �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)�proactor_events)�selector_events)�tasks)�
windows_utils)�logger)�SelectorEventLoop�ProactorEventLoop�IocpProactor�DefaultEventLoopPolicy�WindowsSelectorEventLoopPolicy�WindowsProactorEventLoopPolicyl��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)N)r���)�super�__init__�_source_traceback�_ov)�self�ovr)�	__class__��;/opt/alt/python37/lib64/python3.7/asyncio/windows_events.pyr0sz_OverlappedFuture.__init__csHt���}|jdk	rD|jjr dnd}|�dd|�d|jjd�d��|S)N�pendingZ	completedrzoverlapped=<z, z#x�>)r�
_repr_inforr�insert�address)r�info�state)rrrr6s


 z_OverlappedFuture._repr_infoc
Csr|jdkrdSy|j��WnJtk
rf}z,d||d�}|jrJ|j|d<|j�|�Wdd}~XYnXd|_dS)Nz&Cancelling an overlapped future failed)�message�	exception�future�source_traceback)r�cancel�OSErrorr�_loop�call_exception_handler)r�exc�contextrrr�_cancel_overlapped=s

z$_OverlappedFuture._cancel_overlappedcs|��t���S)N)r.rr()r)rrrr(Msz_OverlappedFuture.cancelcst��|�|��dS)N)r�
set_exceptionr.)rr%)rrrr/Qsz_OverlappedFuture.set_exceptioncst��|�d|_dS)N)r�
set_resultr)r�result)rrrr0Usz_OverlappedFuture.set_result)
�__name__�
__module__�__qualname__rrr.r(r/r0�
__classcell__rr)rrr*srcsjeZdZdd��fdd�
Zdd�Z�fdd�Zd	d
�Zdd�Z�fd
d�Z�fdd�Z	�fdd�Z
�ZS)�_BaseWaitHandleFutureN)rcs8t�j|d�|jr|jd=||_||_||_d|_dS)N)rrT)rrrr�_handle�_wait_handle�_registered)rr�handle�wait_handler)rrrr]sz_BaseWaitHandleFuture.__init__cCst�|jd�tjkS)Nr)�_winapiZWaitForSingleObjectr7Z
WAIT_OBJECT_0)rrrr�_pollksz_BaseWaitHandleFuture._pollcsdt���}|�d|jd���|jdk	rB|��r4dnd}|�|�|jdk	r`|�d|jd���|S)Nzhandle=z#xZsignaledZwaitingzwait_handle=)rr�appendr7r=r8)rr"r#)rrrrps



z _BaseWaitHandleFuture._repr_infocCs
d|_dS)N)r)r�futrrr�_unregister_wait_cbzsz)_BaseWaitHandleFuture._unregister_wait_cbc
Cs�|js
dSd|_|j}d|_yt�|�WnZtk
r�}z<|jtjkrtd||d�}|jrd|j|d<|j�	|�dSWdd}~XYnX|�
d�dS)NFz$Failed to unregister the wait handle)r$r%r&r')r9r8�_overlappedZUnregisterWaitr)�winerror�ERROR_IO_PENDINGrr*r+r@)rr;r,r-rrr�_unregister_waits"
z&_BaseWaitHandleFuture._unregister_waitcs|��t���S)N)rDrr()r)rrrr(�sz_BaseWaitHandleFuture.cancelcs|��t��|�dS)N)rDrr/)rr%)rrrr/�sz#_BaseWaitHandleFuture.set_exceptioncs|��t��|�dS)N)rDrr0)rr1)rrrr0�sz _BaseWaitHandleFuture.set_result)r2r3r4rr=rr@rDr(r/r0r5rr)rrr6Zs
r6csBeZdZdd��fdd�
Zdd�Z�fdd�Z�fd	d
�Z�ZS)�_WaitCancelFutureN)rcst�j||||d�d|_dS)N)r)rr�_done_callback)rr�eventr;r)rrrr�sz_WaitCancelFuture.__init__cCstd��dS)Nz'_WaitCancelFuture must not be cancelled)�RuntimeError)rrrrr(�sz_WaitCancelFuture.cancelcs$t��|�|jdk	r |�|�dS)N)rr0rF)rr1)rrrr0�s
z_WaitCancelFuture.set_resultcs$t��|�|jdk	r |�|�dS)N)rr/rF)rr%)rrrr/�s
z_WaitCancelFuture.set_exception)r2r3r4rr(r0r/r5rr)rrrE�srEcs6eZdZdd��fdd�
Z�fdd�Zdd�Z�ZS)	�_WaitHandleFutureN)rcs<t�j||||d�||_d|_t�dddd�|_d|_dS)N)rTF)rr�	_proactorZ_unregister_proactorrAZCreateEvent�_event�
_event_fut)rrr:r;�proactorr)rrrr�s
z_WaitHandleFuture.__init__csF|jdk	r"t�|j�d|_d|_|j�|j�d|_t��|�dS)N)	rKr<�CloseHandlerLrJ�_unregisterrrr@)rr?)rrrr@�s
	z%_WaitHandleFuture._unregister_wait_cbc
Cs�|js
dSd|_|j}d|_yt�||j�WnZtk
r�}z<|jtjkrxd||d�}|jrh|j|d<|j	�
|�dSWdd}~XYnX|j�|j|j
�|_dS)NFz$Failed to unregister the wait handle)r$r%r&r')r9r8rAZUnregisterWaitExrKr)rBrCrr*r+rJ�_wait_cancelr@rL)rr;r,r-rrrrD�s$

z"_WaitHandleFuture._unregister_wait)r2r3r4rr@rDr5rr)rrrI�srIc@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!rrrr�s

zPipeServer.__init__cCs|j|�d�}|_|S)NF)rVrX)r�tmprrr�_get_unconnected_pipe�sz PipeServer._get_unconnected_pipec
Csr|��rdStjtjB}|r&|tjO}t�|j|tjtjBtj	Btj
tjtjtj
tj�}t�|�}|j�|�|S)N)�closedr<ZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperRZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ	PIPE_WAITZPIPE_UNLIMITED_INSTANCESr	ZBUFSIZEZNMPWAIT_WAIT_FOREVER�NULL�
PipeHandlerU�add)r�first�flags�h�piperrrrXs


zPipeServer._server_pipe_handlecCs
|jdkS)N)rR)rrrrr[szPipeServer.closedcCsV|jdk	r|j��d|_|jdk	rRx|jD]}|��q,Wd|_d|_|j��dS)N)rWr(rRrU�closerV�clear)rrbrrrrcs


zPipeServer.closeN)	r2r3r4rrZrXr[rc�__del__rrrrrQ�s
rQc@seZdZdS)�_WindowsSelectorEventLoopN)r2r3r4rrrrrf+srfcs8eZdZd
�fdd�	Zdd�Zdd�Zddd	�Z�ZS)rNcs|dkrt�}t��|�dS)N)r
rr)rrM)rrrr2szProactorEventLoop.__init__c�s8|j�|�}|IdH}|�}|j||d|id�}||fS)N�addr)�extra)rJ�connect_pipe�_make_duplex_pipe_transport)r�protocol_factoryr!�frb�protocol�transrrr�create_pipe_connection7s
z(ProactorEventLoop.create_pipe_connectionc�s.t���d�����fdd�	������gS)Nc
sd}yj|rL|��}�j�|����r2|��dS��}�j||d�id����}|dkr`dS�j�|�}Wn�t	k
r�}zF|r�|�
�dkr���d||d��|��n�jr�t
jd|dd�Wdd}~XYn2tjk
r�|r�|��YnX|�_|���dS)	Nrg)rhrzPipe accept failed)r$r%rbzAccept pipe failed on pipe %rT)�exc_info)r1rU�discardr[rcrjrZrJ�accept_piper)�filenor+Z_debugr
Zwarningr�CancelledErrorrW�add_done_callback)rlrbrmr,)r!�loop_accept_piperkr�serverrrrvBs<

z>ProactorEventLoop.start_serving_pipe.<locals>.loop_accept_pipe)N)rQZ	call_soon)rrkr!r)r!rvrkrrwr�start_serving_pipe?s(
z$ProactorEventLoop.start_serving_pipec		�sl|��}
t||||||||f|
|d�|	��}y|
IdHWn,tk
rf|��|��IdH�YnX|S)N)�waiterrh)�
create_future�_WindowsSubprocessTransport�	ExceptionrcZ_wait)rrm�args�shell�stdin�stdout�stderr�bufsizerh�kwargsryZtransprrr�_make_subprocess_transportms

z,ProactorEventLoop._make_subprocess_transport)N)N)r2r3r4rrorxr�r5rr)rrr/s0rc@s�eZdZd6dd�Zdd�Zdd�Zdd	�Zd7dd�Zd
d�Zd8dd�Z	d9dd�Z
d:dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd;d d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd<d.d/�Zd0d1�Zd2d3�Zd4d5�Zd
S)=r
���cCsDd|_g|_t�tjtd|�|_i|_t�	�|_
g|_t�	�|_dS)Nr)
r*�_resultsrA�CreateIoCompletionPort�INVALID_HANDLE_VALUEr\�_iocp�_cacherSrTr9�
_unregistered�_stopped_serving)rZconcurrencyrrrr�s
zIocpProactor.__init__cCs|jdkrtd��dS)NzIocpProactor is closed)r�rH)rrrr�
_check_closed�s
zIocpProactor._check_closedcCsFdt|j�dt|j�g}|jdkr0|�d�d|jjd�|�fS)Nzoverlapped#=%sz
result#=%sr[z<%s %s>� )�lenr�r�r�r>rr2�join)rr"rrr�__repr__�s


zIocpProactor.__repr__cCs
||_dS)N)r*)rrrrr�set_loop�szIocpProactor.set_loopNcCs |js|�|�|j}g|_|S)N)r�r=)r�timeoutrYrrr�select�s

zIocpProactor.selectcCs|j��}|�|�|S)N)r*rzr0)r�valuer?rrr�_result�s

zIocpProactor._resultrcCsz|�|�t�t�}y4t|tj�r6|�|��||�n|�|��|�Wnt	k
rb|�
d�SXdd�}|�|||�S)N�c
SsPy|��Stk
rJ}z$|jtjtjfkr8t|j��n�Wdd}~XYnXdS)N)�	getresultr)rBrA�ERROR_NETNAME_DELETED�ERROR_OPERATION_ABORTED�ConnectionResetErrorr})rn�keyrr,rrr�finish_recv�s
z&IocpProactor.recv.<locals>.finish_recv)�_register_with_iocprA�
Overlappedr\�
isinstance�socketZWSARecvrsZReadFile�BrokenPipeErrorr��	_register)r�conn�nbytesr`rr�rrr�recv�s


zIocpProactor.recvcCsz|�|�t�t�}y4t|tj�r6|�|��||�n|�|��|�Wnt	k
rb|�
d�SXdd�}|�|||�S)Nr�c
SsPy|��Stk
rJ}z$|jtjtjfkr8t|j��n�Wdd}~XYnXdS)N)r�r)rBrAr�r�r�r})rnr�rr,rrrr��s
z+IocpProactor.recv_into.<locals>.finish_recv)r�rAr�r\r�r�ZWSARecvIntorsZReadFileIntor�r�r�)rr��bufr`rr�rrr�	recv_into�s


zIocpProactor.recv_intocCsZ|�|�t�t�}t|tj�r4|�|��||�n|�|��|�dd�}|�	|||�S)Nc
SsPy|��Stk
rJ}z$|jtjtjfkr8t|j��n�Wdd}~XYnXdS)N)r�r)rBrAr�r�r�r})rnr�rr,rrr�finish_send�s
z&IocpProactor.send.<locals>.finish_send)
r�rAr�r\r�r�ZWSASendrsZ	WriteFiler�)rr�r�r`rr�rrr�send�s


zIocpProactor.sendcsv|���|��j��t�t�}|����������fdd�}dd�}|�|�|�}||��}t	j
||jd�|S)NcsD|��t�d����}��tjtj|���	��
������fS)Nz@P)r��struct�packrs�
setsockoptr��
SOL_SOCKETrAZSO_UPDATE_ACCEPT_CONTEXT�
settimeoutZ
gettimeoutZgetpeername)rnr�rr�)r��listenerrr�
finish_accept�s
z*IocpProactor.accept.<locals>.finish_acceptc�s4y|IdHWn tjk
r.|���YnXdS)N)rrtrc)r&r�rrr�accept_coro�s
z(IocpProactor.accept.<locals>.accept_coro)r)r��_get_accept_socket�familyrAr�r\ZAcceptExrsr�rZ
ensure_futurer*)rr�rr�r�r&�coror)r�r�r�accept�s

	
zIocpProactor.acceptc
s�|���yt�����j�WnBtk
rb}z$|jtjkr@���	�ddkrR�Wdd}~XYnXt�
t�}|����|��fdd�}|�
|�|�S)Nrrcs|����tjtjd��S)Nr)r�r�r�r�rAZSO_UPDATE_CONNECT_CONTEXT)rnr�r)r�rr�finish_connects
z,IocpProactor.connect.<locals>.finish_connect)r�rAZ	BindLocalrsr�r)rB�errnoZ	WSAEINVALZgetsocknamer�r\Z	ConnectExr�)rr�r!�err�r)r�r�connects

zIocpProactor.connectc		Csb|�|�t�t�}|d@}|d?d@}|�|��t�|���|||dd�dd�}|�|||�S)Nl��� rc
SsPy|��Stk
rJ}z$|jtjtjfkr8t|j��n�Wdd}~XYnXdS)N)r�r)rBrAr�r�r�r})rnr�rr,rrr�finish_sendfile%s
z.IocpProactor.sendfile.<locals>.finish_sendfile)	r�rAr�r\ZTransmitFilers�msvcrtZ
get_osfhandler�)	rZsock�file�offset�countrZ
offset_lowZoffset_highr�rrr�sendfiles



	zIocpProactor.sendfilecsJ|���t�t�}|�����}|r0|���S�fdd�}|�|�|�S)Ncs|���S)N)r�)rnr�r)rbrr�finish_accept_pipe;sz4IocpProactor.accept_pipe.<locals>.finish_accept_pipe)r�rAr�r\ZConnectNamedPipersr�r�)rrbrZ	connectedr�r)rbrrr0s


zIocpProactor.accept_pipec
�szt}xjyt�|�}PWn0tk
rF}z|jtjkr6�Wdd}~XYnXt|dt�}tj	||j
d�IdHqWt�|�S)N�)r)
�CONNECT_PIPE_INIT_DELAYrAZConnectPiper)rBZERROR_PIPE_BUSY�min�CONNECT_PIPE_MAX_DELAYrZsleepr*r	r])rr!Zdelayr:r,rrrriAs
zIocpProactor.connect_pipecCs|�||d�S)NF)�_wait_for_handle)rr:r�rrr�wait_for_handleTszIocpProactor.wait_for_handlecCs|�|dd�}||_|S)NT)r�rF)rrGZ
done_callbackr?rrrrP\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)Ng@�@)rrcs���S)N)r=)rnr�r)rlrr�finish_wait_for_handleysz=IocpProactor._wait_for_handle.<locals>.finish_wait_for_handler)r�r<�INFINITE�math�ceilrAr�r\ZRegisterWaitWithQueuer�r!rEr*rIrr�)rr:r�Z
_is_cancel�msrr;r�r)rlrr�cs 


	zIocpProactor._wait_for_handlecCs0||jkr,|j�|�t�|��|jdd�dS)Nr)r9r^rAr�rsr�)r�objrrrr��s
z IocpProactor._register_with_iocpc
Cs�|��t||jd�}|jr$|jd=|jsry|dd|�}Wn,tk
rf}z|�|�Wdd}~XYnX|�|�||||f|j|j	<|S)N)rr)
r�rr*rrr)r/r0r�r!)rrr��callbackrlr�r�rrrr��s

zIocpProactor._registercCs|��|j�|�dS)N)r�r�r>)rrrrrrO�szIocpProactor._unregistercCst�|�}|�d�|S)Nr)r�r�)rr��srrrr��s

zIocpProactor._get_accept_socketcCs�|dkrt}n0|dkr td��nt�|d�}|tkr>td���xt�|j|�}|dkrZPd}|\}}}}y|j�|�\}}	}
}WnVt	k
r�|j
��r�|j
�dd||||fd��|dtj
fkr�t�|�wBYnX|
|jkr�|��qB|��sBy||||	�}Wn:tk
�r@}
z|�|
�|j�|�Wdd}
~
XYqBX|�|�|j�|�qBWx |jD]}	|j�|	jd��qdW|j��dS)Nrznegative timeoutg@�@ztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r$�status)r��
ValueErrorr�r�rAZGetQueuedCompletionStatusr�r��pop�KeyErrorr*Z	get_debugr+r�r<rNr�r(Zdoner)r/r�r>r0r�r!rd)rr�r�r��errZtransferredr�r!rlrr�r�r�r�rrrr=�sJ






zIocpProactor._pollcCs|j�|�dS)N)r�r^)rr�rrr�
_stop_serving�szIocpProactor._stop_servingcCs |jdkrdSx�t|j���D]�\}\}}}}|��r8qt|t�rDqy|��Wqtk
r�}z6|j	dk	r�d||d�}|j
r�|j
|d<|j	�|�Wdd}~XYqXqWd}t�
�}	|	|}
xD|j�r|
t�
�kr�t�d|t�
�|	�t�
�|}
|�|�q�Wg|_t�|j�d|_dS)NzCancelling a future failed)r$r%r&r'g�?z,%r is running after closing for %.1f seconds)r��listr��itemsZ	cancelledr�rEr(r)r*rr+�timeZ	monotonicr
�debugr=r�r<rN)rr!r?rr�r�r,r-Z
msg_updateZ
start_timeZnext_msgrrrrc�s:
 


"
zIocpProactor.closecCs|��dS)N)rc)rrrrre*szIocpProactor.__del__)r�)N)r)r)r)N)N)r2r3r4rr�r�r�r�r�r�r�r�r�r�r�rrrir�rPr�r�r�rOr�r=r�rcrerrrrr
s2






"
 

7/r
c@seZdZdd�ZdS)r{c
sPtj|f|||||d�|���_�fdd�}�jj�t�jj��}	|	�|�dS)N)r~rr�r�r�cs�j��}��|�dS)N)�_procZpollZ_process_exited)rl�
returncode)rrrr�5s
z4_WindowsSubprocessTransport._start.<locals>.callback)	r	�Popenr�r*rJr��intr7ru)
rr}r~rr�r�r�r�r�rlr)rr�_start0sz"_WindowsSubprocessTransport._startN)r2r3r4r�rrrrr{.sr{c@seZdZeZdS)rN)r2r3r4r�
_loop_factoryrrrrr@src@seZdZeZdS)rN)r2r3r4rr�rrrrrDsr)-rAr<r�r�r�r�r�r�rS�rrrrrrr	�logr
�__all__r\r�ZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDr�r�ZFuturerr6rErI�objectrQZBaseSelectorEventLooprfZBaseProactorEventLooprr
ZBaseSubprocessTransportr{rZBaseDefaultEventLoopPolicyrrrrrrr�<module>sN0J4;P2