AlkantarClanX12

Your IP : 18.119.133.138


Current Path : /opt/alt/python39/lib64/python3.9/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/asyncio/__pycache__/windows_events.cpython-39.opt-2.pyc

a

R�f��@s�ddlZejdkred��ddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZdZdZdZdZdZdZdZGdd�dej�ZGdd�dej�Z Gdd�de �Z!Gdd�de �Z"Gdd�de#�Z$Gdd�dej%�Z&Gd d!�d!ej'�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/Z0dS)*�NZwin32z
win32 only�)�events)�base_subprocess)�futures)�
exceptions)�proactor_events)�selector_events)�tasks)�
windows_utils)�logger)�SelectorEventLoop�ProactorEventLoop�IocpProactor�DefaultEventLoopPolicy�WindowsSelectorEventLoopPolicy�WindowsProactorEventLoopPolicy���i�i�g����MbP?g�������?cs\eZdZdd��fdd�
Z�fdd�Zdd�Zd�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__��;/opt/alt/python39/lib64/python3.9/asyncio/windows_events.pyr6sz_OverlappedFuture.__init__csHt���}|jdurD|jjr dnd}|�dd|�d|jjd�d��|S)N�pendingZ	completedrzoverlapped=<z, �#x�>)r�
_repr_inforr"�insert�address�r�info�staterr r!r%<s


 z_OverlappedFuture._repr_infoc
Cst|jdurdSz|j��WnLtyh}z4d||d�}|jrH|j|d<|j�|�WYd}~n
d}~00d|_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_overlappedCs
�
"z$_OverlappedFuture._cancel_overlappedcs|��t�j|d�S�N)�msg)r6rr0�rr8rr r!r0Ssz_OverlappedFuture.cancelcst��|�|��dS�N)r�
set_exceptionr6�rr-rr r!r;Wsz_OverlappedFuture.set_exceptioncst��|�d|_dSr:)r�
set_resultr�r�resultrr r!r=[sz_OverlappedFuture.set_result)N)
�__name__�
__module__�__qualname__rr%r6r0r;r=�
__classcell__r r rr!r0srcsleZdZdd��fdd�
Zdd�Z�fdd�Zd	d
�Zdd�Zd�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!rcsz_BaseWaitHandleFuture.__init__cCst�|jd�tjkS�Nr)�_winapiZWaitForSingleObjectrEZ
WAIT_OBJECT_0�rr r r!�_pollqs�z_BaseWaitHandleFuture._pollcsdt���}|�d|jd���|jdurB|��r4dnd}|�|�|jdur`|�d|jd���|S)Nzhandle=r#ZsignaledZwaitingzwait_handle=)rr%�appendrErMrFr(rr r!r%vs



z _BaseWaitHandleFuture._repr_infocCs
d|_dSr:)r�r�futr r r!�_unregister_wait_cb�sz)_BaseWaitHandleFuture._unregister_wait_cbc
Cs�|js
dSd|_|j}d|_zt�|�Wnfty�}zN|jtjkr|d||d�}|jrb|j|d<|j�	|�WYd}~dSWYd}~n
d}~00|�
d�dS�NFz$Failed to unregister the wait handler+r/)rGrF�_overlappedZUnregisterWaitr1�winerror�ERROR_IO_PENDINGrr2r3rQ�rrIr4r5r r r!�_unregister_wait�s$�
$z&_BaseWaitHandleFuture._unregister_waitcs|��t�j|d�Sr7)rWrr0r9rr r!r0�sz_BaseWaitHandleFuture.cancelcs|��t��|�dSr:)rWrr;r<rr r!r;�sz#_BaseWaitHandleFuture.set_exceptioncs|��t��|�dSr:)rWrr=r>rr r!r=�sz _BaseWaitHandleFuture.set_result)N)r@rArBrrMr%rQrWr0r;r=rCr r rr!rD`s
rDcsBeZdZdd��fdd�
Zdd�Z�fdd�Z�fd	d
�Z�ZS)�_WaitCancelFutureNrcst�j||||d�d|_dS)Nr)rr�_done_callback)rr�eventrIrrr r!r�sz_WaitCancelFuture.__init__cCstd��dS)Nz'_WaitCancelFuture must not be cancelled)�RuntimeErrorrLr r r!r0�sz_WaitCancelFuture.cancelcs$t��|�|jdur |�|�dSr:)rr=rYr>rr r!r=�s
z_WaitCancelFuture.set_resultcs$t��|�|jdur |�|�dSr:)rr;rYr<rr r!r;�s
z_WaitCancelFuture.set_exception)r@rArBrr0r=r;rCr r rr!rX�srXcs6eZdZdd��fdd�
Z�fdd�Zdd�Z�ZS)	�_WaitHandleFutureNrcs<t�j||||d�||_d|_t�dddd�|_d|_dS)NrTF)rr�	_proactorZ_unregister_proactorrSZCreateEvent�_event�
_event_fut)rrrHrI�proactorrrr r!r�s
z_WaitHandleFuture.__init__csF|jdur"t�|j�d|_d|_|j�|j�d|_t��|�dSr:)	r^rK�CloseHandler_r]�_unregisterrrrQrOrr r!rQ�s
	z%_WaitHandleFuture._unregister_wait_cbc
Cs�|js
dSd|_|j}d|_zt�||j�Wnfty�}zN|jtjkr�d||d�}|jrf|j|d<|j	�
|�WYd}~dSWYd}~n
d}~00|j�|j|j
�|_dSrR)rGrFrSZUnregisterWaitExr^r1rTrUrr2r3r]�_wait_cancelrQr_rVr r r!rW�s(�
$
�z"_WaitHandleFuture._unregister_wait)r@rArBrrQrWrCr r rr!r\�sr\c@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)rjrl)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�|�|Sr:)�closedrKZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperfZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ	PIPE_WAITZPIPE_UNLIMITED_INSTANCESr
ZBUFSIZEZNMPWAIT_WAIT_FOREVER�NULL�
PipeHandleri�add)r�first�flags�h�piper r r!rl
s"

��
zPipeServer._server_pipe_handlecCs
|jduSr:)rfrLr r r!rpszPipeServer.closedcCsR|jdur|j��d|_|jdurN|jD]}|��q*d|_d|_|j��dSr:)rkr0rfri�closerj�clear)rrwr r r!rx"s




zPipeServer.closeN)	r@rArBrrorlrprx�__del__r r r r!rd�s
rdc@seZdZdS)�_WindowsSelectorEventLoopN)r@rArBr r r r!r{1sr{csDeZdZd�fdd�	Z�fdd�Zdd�Zdd	�Zd
d
d�Z�ZS)r
Ncs|durt�}t��|�dSr:)rrr)rr`rr r!r8szProactorEventLoop.__init__c	s�zV|�|j�t���W|jdur�|jj}|j��|durP|jsP|j�	|�d|_n>|jdur�|jj}|j��|dur�|js�|j�	|�d|_0dSr:)
�	call_soonZ_loop_self_readingr�run_foreverZ_self_reading_futurerr0r"r]rb�rrrr r!r}=s

�

zProactorEventLoop.run_foreverc�s8|j�|�}|IdH}|�}|j||d|id�}||fS)N�addr��extra)r]�connect_pipe�_make_duplex_pipe_transport)r�protocol_factoryr'�frw�protocol�transr r r!�create_pipe_connectionPs
�z(ProactorEventLoop.create_pipe_connectionc�s.t���d�����fdd�	������gS)Nc
sd}zn|rN|��}�j�|����r4|��WdS��}�j||d�id����}|durdWdS�j�|�}Wn�t	y�}zN|r�|�
�dkr���d||d��|��n�jr�t
jd|dd�WYd}~n8d}~0tjy�|r�|��Yn0|�_|���dS)	Nrr�rzPipe accept failed)r,r-rwzAccept pipe failed on pipe %rT)�exc_info)r?ri�discardrprxr�ror]�accept_piper1�filenor3Z_debugrZwarningr�CancelledErrorrk�add_done_callback)r�rwr�r4�r'�loop_accept_piper�rZserverr r!r�[sB
��
�z>ProactorEventLoop.start_serving_pipe.<locals>.loop_accept_pipe)N)rdr|)rr�r'r r�r!�start_serving_pipeXs(
z$ProactorEventLoop.start_serving_pipec		�s�|��}
t||||||||f|
|d�|	��}z|
IdHWn@ttfyR�Yn*tyz|��|��IdH�Yn0|S)N)�waiterr�)�
create_future�_WindowsSubprocessTransport�
SystemExit�KeyboardInterrupt�
BaseExceptionrxZ_wait)rr��args�shell�stdin�stdout�stderr�bufsizer��kwargsr�Ztranspr r r!�_make_subprocess_transport�s"
���z,ProactorEventLoop._make_subprocess_transport)N)N)	r@rArBrr}r�r�r�rCr r rr!r
5s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�	�|_dSrJ)
r2�_resultsrS�CreateIoCompletionPort�INVALID_HANDLE_VALUErq�_iocp�_cachergrhrG�
_unregistered�_stopped_serving)rZconcurrencyr r r!r�s
�
zIocpProactor.__init__cCs|jdurtd��dS)NzIocpProactor is closed)r�r[rLr r r!�
_check_closed�s
zIocpProactor._check_closedcCsFdt|j�dt|j�g}|jdur0|�d�d|jjd�|�fS)Nzoverlapped#=%sz
result#=%srpz<%s %s>� )�lenr�r�r�rNrr@�join)rr)r r r!�__repr__�s�

zIocpProactor.__repr__cCs
||_dSr:)r2)rrr r r!�set_loop�szIocpProactor.set_loopNcCs |js|�|�|j}g|_|Sr:)r�rM)r�timeoutrnr r r!�select�s

zIocpProactor.selectcCs|j��}|�|�|Sr:)r2r�r=)r�valuerPr r r!�_result�s

zIocpProactor._resultrcCs||�|�t�t�}z4t|tj�r6|�|��||�n|�|��|�Wnt	yd|�
d�YS0dd�}|�|||�S)N�c
SsTz
|��WStyN}z,|jtjtjfvr8t|j��n�WYd}~n
d}~00dSr:��	getresultr1rTrSZERROR_NETNAME_DELETEDZERROR_OPERATION_ABORTED�ConnectionResetErrorr��r��keyrr4r r r!�finish_recv�s
�z&IocpProactor.recv.<locals>.finish_recv)�_register_with_iocprS�
Overlappedrq�
isinstance�socketZWSARecvr�ZReadFile�BrokenPipeErrorr��	_register�r�conn�nbytesrurr�r r r!�recv�s


zIocpProactor.recvcCs||�|�t�t�}z4t|tj�r6|�|��||�n|�|��|�Wnt	yd|�
d�YS0dd�}|�|||�S)Nrc
SsTz
|��WStyN}z,|jtjtjfvr8t|j��n�WYd}~n
d}~00dSr:r�r�r r r!r��s
�z+IocpProactor.recv_into.<locals>.finish_recv)r�rSr�rqr�r�ZWSARecvIntor�ZReadFileIntor�r�r�)rr��bufrurr�r r r!�	recv_into�s


zIocpProactor.recv_intocCs^|�|�t�t�}z|�|��||�WntyF|�d�YS0dd�}|�|||�S)N)r�Nc
SsTz
|��WStyN}z,|jtjtjfvr8t|j��n�WYd}~n
d}~00dSr:r�r�r r r!r��s
�z*IocpProactor.recvfrom.<locals>.finish_recv)	r�rSr�rqZWSARecvFromr�r�r�r�r�r r r!�recvfrom�s


zIocpProactor.recvfromcCs>|�|�t�t�}|�|��|||�dd�}|�|||�S)Nc
SsTz
|��WStyN}z,|jtjtjfvr8t|j��n�WYd}~n
d}~00dSr:r�r�r r r!�finish_send	s
�z(IocpProactor.sendto.<locals>.finish_send)r�rSr�rqZ	WSASendTor�r�)rr�r�rurrr�r r r!�sendtos



zIocpProactor.sendtocCsZ|�|�t�t�}t|tj�r4|�|��||�n|�|��|�dd�}|�	|||�S)Nc
SsTz
|��WStyN}z,|jtjtjfvr8t|j��n�WYd}~n
d}~00dSr:r�r�r r r!r�s
�z&IocpProactor.send.<locals>.finish_send)
r�rSr�rqr�r�ZWSASendr�Z	WriteFiler�)rr�r�rurr�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_SOCKETrSZSO_UPDATE_ACCEPT_CONTEXT�
settimeoutZ
gettimeoutZgetpeername)r�r�rr��r��listenerr r!�
finish_accept/s�z*IocpProactor.accept.<locals>.finish_acceptc�s2z|IdHWntjy,|���Yn0dSr:)rr�rx)r.r�r r r!�accept_coro8s
z(IocpProactor.accept.<locals>.accept_coror)r��_get_accept_socket�familyrSr�rqZAcceptExr�r�r	Z
ensure_futurer2)rr�rr�r�r.�coror r�r!�accept)s

	
zIocpProactor.acceptc
s��jtjkr4t����|�|j��}|�d�|S|�	��zt�
����j�WnDty�}z,|j
tjkrr����ddkr��WYd}~n
d}~00t�t�}|����|��fdd�}|�|�|�S)Nrrcs|����tjtjd��SrJ)r�r�r�r�rSZSO_UPDATE_CONNECT_CONTEXT�r�r�r�r�r r!�finish_connect[s
�z,IocpProactor.connect.<locals>.finish_connect)�typer�Z
SOCK_DGRAMrSZ
WSAConnectr�r2r�r=r�Z	BindLocalr�r1rT�errnoZ	WSAEINVALZgetsocknamer�rqZ	ConnectExr�)rr�r'rP�err�r r�r!�connectEs"



zIocpProactor.connectc		Csb|�|�t�t�}|d@}|d?d@}|�|��t�|���|||dd�dd�}|�|||�S)Nr� rc
SsTz
|��WStyN}z,|jtjtjfvr8t|j��n�WYd}~n
d}~00dSr:r�r�r r r!�finish_sendfilens
�z.IocpProactor.sendfile.<locals>.finish_sendfile)	r�rSr�rqZTransmitFiler��msvcrtZ
get_osfhandler�)	rZsock�file�offset�countrZ
offset_lowZoffset_highr�r r r!�sendfileds


�	zIocpProactor.sendfilecsJ|���t�t�}|�����}|r0|���S�fdd�}|�|�|�S)Ncs|���Sr:)r�r��rwr r!�finish_accept_pipe�sz4IocpProactor.accept_pipe.<locals>.finish_accept_pipe)r�rSr�rqZConnectNamedPiper�r�r�)rrwrZ	connectedr�r r�r!r�ys


zIocpProactor.accept_pipec
�stt}zt�|�}WqjWn2tyH}z|jtjkr4�WYd}~n
d}~00t|dt�}t�	|�IdHqt
�|�S)N�)�CONNECT_PIPE_INIT_DELAYrSZConnectPiper1rTZERROR_PIPE_BUSY�min�CONNECT_PIPE_MAX_DELAYr	�sleepr
rr)rr'ZdelayrHr4r r r!r��s
zIocpProactor.connect_pipecCs|�||d�Srm)�_wait_for_handle)rrHr�r r r!�wait_for_handle�szIocpProactor.wait_for_handlecCs|�|dd�}||_|Sre)r�rY)rrZZ
done_callbackrPr r r!rc�szIocpProactor._wait_cancelcs�|��|durtj}nt�|d�}t�t�}t�||j	|j
|�}|r\t||||jd��nt
|||||jd���jr~�jd=�fdd�}�|d|f|j|j
<�S)N�@�@rrcs���Sr:)rMr��r�r r!�finish_wait_for_handle�sz=IocpProactor._wait_for_handle.<locals>.finish_wait_for_handler)r�rK�INFINITE�math�ceilrSr�rqZRegisterWaitWithQueuer�r'rXr2r\rr�)rrHr�Z
_is_cancel�msrrIr�r r�r!r��s$
�
�	zIocpProactor._wait_for_handlecCs0||jvr,|j�|�t�|��|jdd�dSrJ)rGrsrSr�r�r��r�objr r r!r��s
z IocpProactor._register_with_iocpc
Cs�|��t||jd�}|jr$|jd=|jstz|dd|�}Wn.tyh}z|�|�WYd}~nd}~00|�|�||||f|j|j	<|Sr)
r�rr2rr"r1r;r=r�r')rrr��callbackr�r�r�r r r!r��s 

zIocpProactor._registercCs|��|j�|�dSr:)r�r�rNr~r r r!rb�szIocpProactor._unregistercCst�|�}|�d�|SrJ)r�r�)rr��sr r r!r�s

zIocpProactor._get_accept_socketcCs�|durt}n0|dkr td��nt�|d�}|tkr>td��t�|j|�}|durX�qZd}|\}}}}z|j�|�\}}	}
}WnVt	y�|j
��r�|j
�dd||||fd��|dtj
fvr�t�|�Yq>Yn0|
|jvr�|��q>|��s>z||||	�}Wn<t�y@}
z"|�|
�|j�|�WYd}
~
q>d}
~
00|�|�|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�rSZGetQueuedCompletionStatusr�r��pop�KeyErrorr2Z	get_debugr3r�rKrar�r0Zdoner1r;r�rNr=r�r'ry)rr�r�r��errZtransferredr�r'r�rr�r�r�r�r r r!rMsL


��	




"

zIocpProactor._pollcCs|j�|�dSr:)r�rsr�r r r!�
_stop_serving>szIocpProactor._stop_servingcCs|jdurdSt|j���D]�\}\}}}}|��r6qt|t�rBqz|��Wqty�}z>|j	dur�d||d�}|j
r�|j
|d<|j	�|�WYd}~qd}~00qd}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�rXr0r1r2rr3�time�	monotonicr�debugrMr�rKra)rr'rPrr�r�r4r5Z
msg_updateZ
start_timeZnext_msgr r r!rxDs>


�
$�zIocpProactor.closecCs|��dSr:)rxrLr r r!rzsszIocpProactor.__del__)r)N)r)r)r)rN)r)N)N)r@rArBrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rcr�r�r�rbr�rMr�rxrzr 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��}��|�dSr:)�_procZpollZ_process_exited)r��
returncoderLr r!r�~s
z4_WindowsSubprocessTransport._start.<locals>.callback)	r
�Popenrr2r]r��intrEr�)
rr�r�r�r�r�r�r�r�r�r rLr!�_startys���z"_WindowsSubprocessTransport._startN)r@rArBrr r r r!r�wsr�c@seZdZeZdS)rN)r@rArBr�
_loop_factoryr r r r!r�src@seZdZeZdS)rN)r@rArBr
rr r r r!r�sr)1�sys�platform�ImportErrorrSrKr�r�r�r�r�r�rg�rrrrrrr	r
�logr�__all__rqr�ZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDr�r�ZFuturerrDrXr\�objectrdZBaseSelectorEventLoopr{ZBaseProactorEventLoopr
rZBaseSubprocessTransportr�rZBaseDefaultEventLoopPolicyrrrr r r r!�<module>sV
0J4;e`