Your IP : 18.118.208.127


Current Path : /opt/alt/python310/lib64/python3.10/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/asyncio/__pycache__/windows_events.cpython-310.opt-2.pyc

o

6��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^eZdZ	dd��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/python310/lib64/python3.10/asyncio/windows_events.pyr6s
z_OverlappedFuture.__init__csHt���}|jdur"|jjrdnd}|�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��Wn&ty4}zd||d�}|jr$|j|d<|j�|�WYd}~nd}~wwd|_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_overlappedc�|��t�j|d�S�N)�msg)r6rr0�rr9rr r!r0S�z_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_resultr<)
�__name__�
__module__�__qualname__rr%r6r0r=r?�
__classcell__r r rr!r0srcsneZdZ	dd��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!rcs
z_BaseWaitHandleFuture.__init__cCst�|jd�tjkS�Nr)�_winapiZWaitForSingleObjectrGZ
WAIT_OBJECT_0�rr r r!�_pollqs�z_BaseWaitHandleFuture._pollcsdt���}|�d|jd���|jdur!|��rdnd}|�|�|jdur0|�d|jd���|S)Nzhandle=r#ZsignaledZwaitingzwait_handle=)rr%�appendrGrOrHr(rr r!r%vs



z _BaseWaitHandleFuture._repr_infocCs
d|_dSr<)r�r�futr r r!�_unregister_wait_cb�s
z)_BaseWaitHandleFuture._unregister_wait_cbc
Cs�|jsdSd|_|j}d|_zt�|�Wn3tyH}z'|jtjkr>d||d�}|jr1|j|d<|j�	|�WYd}~dSWYd}~nd}~ww|�
d�dS�NFz$Failed to unregister the wait handler+r/)rIrH�_overlappedZUnregisterWaitr1�winerror�ERROR_IO_PENDINGrr2r3rS�rrKr4r5r r r!�_unregister_wait�s*�
���
z&_BaseWaitHandleFuture._unregister_waitcr7r8)rYrr0r:rr r!r0�r;z_BaseWaitHandleFuture.cancelc�|��t��|�dSr<)rYrr=r>rr r!r=��z#_BaseWaitHandleFuture.set_exceptioncrZr<)rYrr?r@rr r!r?�r[z _BaseWaitHandleFuture.set_resultr<)rBrCrDrrOr%rSrYr0r=r?rEr r rr!rF`s
rFcsDeZdZ	dd��fdd�
Zdd�Z�fdd�Z�fd	d
�Z�ZS)�_WaitCancelFutureNrcst�j||||d�d|_dS)Nr)rr�_done_callback)rr�eventrKrrr r!r�s
z_WaitCancelFuture.__init__cCstd��)Nz'_WaitCancelFuture must not be cancelled)�RuntimeErrorrNr r r!r0�sz_WaitCancelFuture.cancelc�(t��|�|jdur|�|�dSdSr<)rr?r]r@rr r!r?��
�z_WaitCancelFuture.set_resultcr`r<)rr=r]r>rr r!r=�raz_WaitCancelFuture.set_exception)rBrCrDrr0r?r=rEr r rr!r\�sr\cs6eZdZdd��fdd�
Z�fdd�Zdd�Z�ZS)	�_WaitHandleFutureNrcs<t�j||||d�||_d|_t�dddd�|_d|_dS)NrTF)rr�	_proactorZ_unregister_proactorrUZCreateEvent�_event�
_event_fut)rrrJrK�proactorrrr r!r�s

z_WaitHandleFuture.__init__csF|jdurt�|j�d|_d|_|j�|j�d|_t��|�dSr<)	rdrM�CloseHandlererc�_unregisterrrrSrQrr r!rS�s
	z%_WaitHandleFuture._unregister_wait_cbc
Cs�|jsdSd|_|j}d|_z	t�||j�Wn3tyJ}z'|jtjkr@d||d�}|jr3|j|d<|j	�
|�WYd}~dSWYd}~nd}~ww|j�|j|j
�|_dSrT)rIrHrUZUnregisterWaitExrdr1rVrWrr2r3rc�_wait_cancelrSrerXr r r!rY�s.�
���


�z"_WaitHandleFuture._unregister_wait)rBrCrDrrSrYrEr r rr!rb�srbc@s:eZdZ	dd�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)rprr)r�tmpr r r!�_get_unconnected_pipesz PipeServer._get_unconnected_pipec
Csr|��rdStjtjB}|r|tjO}t�|j|tjtjBtj	Btj
tjtjtj
tj�}t�|�}|j�|�|Sr<)�closedrMZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperlZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ	PIPE_WAITZPIPE_UNLIMITED_INSTANCESr
ZBUFSIZEZNMPWAIT_WAIT_FOREVER�NULL�
PipeHandlero�add)r�first�flags�h�piper r r!rr
s"

��
zPipeServer._server_pipe_handlecCs
|jduSr<)rlrNr r r!rv�
zPipeServer.closedcCsV|jdur
|j��d|_|jdur)|jD]}|��qd|_d|_|j��dSdSr<)rqr0rlro�closerp�clear)rr}r r r!r"s




�zPipeServer.closeN)	rBrCrDrrurrrvr�__del__r r r r!rj�s
rjc@seZdZdS)�_WindowsSelectorEventLoopN)rBrCrDr r r r!r�1sr�csHeZdZ	d�fdd�	Z�fdd�Zdd�Zdd	�Z	dd
d�Z�ZS)
r
Ncs|durt�}t��|�dSr<)rrr)rrfrr r!r8szProactorEventLoop.__init__c	s�z.|�|j�t���W|jdur-|jj}|j��|dur(|js(|j�	|�d|_dSdS|jdurM|jj}|j��|durJ|jsJ|j�	|�d|_wr<)
�	call_soonZ_loop_self_readingr�run_foreverZ_self_reading_futurerr0r"rcrh�rrrr r!r�=s


�
zProactorEventLoop.run_foreverc�s:�|j�|�}|IdH}|�}|j||d|id�}||fS)N�addr��extra)rc�connect_pipe�_make_duplex_pipe_transport)r�protocol_factoryr'�fr}�protocol�transr r r!�create_pipe_connectionPs�
�z(ProactorEventLoop.create_pipe_connectionc�s0�t���d�����fdd�	������gS)Nc
sTd}z7|r'|��}�j�|����r|��WdS��}�j||d�id����}|dur2WdS�j�|�}Wnft	yT|rL|�
�dkrL|������YdSty�}z-|rq|�
�dkrq��
d||d��|��n�jr|tjd|dd�����WYd}~dSd}~wtjy�|r�|��YdSYdSw|�_|���dS)	Nr�r�rzPipe accept failed)r,r-r}zAccept pipe failed on pipe %rT)�exc_info)rAro�discardrvrr�rurc�accept_pipe�BrokenPipeError�filenor�r1r3Z_debugrZwarningr�CancelledErrorrq�add_done_callback)r�r}r�r4�r'�loop_accept_piper�rZserverr r!r�[sR
��
����z>ProactorEventLoop.start_serving_pipe.<locals>.loop_accept_piper<)rjr�)rr�r'r r�r!�start_serving_pipeXs
�
-z$ProactorEventLoop.start_serving_pipec		�sx�|��}
t||||||||f|
|d�|	��}z|
IdHW|Sttfy)�ty;|��|��IdH�w)N)�waiterr�)�
create_future�_WindowsSubprocessTransport�
SystemExit�KeyboardInterrupt�
BaseExceptionrZ_wait)rr��args�shell�stdin�stdout�stderr�bufsizer��kwargsr�Ztranspr r r!�_make_subprocess_transport�s&�
�����z,ProactorEventLoop._make_subprocess_transportr<)	rBrCrDrr�r�r�r�rEr r rr!r
5s5�r
c@s�eZdZ	d: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#�Zd;d$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd;d2d3�Zd4d5�Zd6d7�Zd8d9�Zd
S)>rrcCsDd|_g|_t�tjtd|�|_i|_t�	�|_
g|_t�	�|_dSrL)
r2�_resultsrU�CreateIoCompletionPort�INVALID_HANDLE_VALUErw�_iocp�_cachermrnrI�
_unregistered�_stopped_serving)rZconcurrencyr r r!r�s
�
zIocpProactor.__init__cCs|jdur	td��dS)NzIocpProactor is closed)r�r_rNr r r!�
_check_closed�s
�zIocpProactor._check_closedcCsFdt|j�dt|j�g}|jdur|�d�d|jjd�|�fS)Nzoverlapped#=%sz
result#=%srvz<%s %s>� )�lenr�r�r�rPrrB�join)rr)r r r!�__repr__�s�

zIocpProactor.__repr__cCs
||_dSr<)r2)rrr r r!�set_loop�r~zIocpProactor.set_loopNcCs.|js|�|�|j}g|_z|Wd}Sd}wr<)r�rO)r�timeoutrtr r r!�select�s
zIocpProactor.selectcCs|j��}|�|�|Sr<)r2r�r?)r�valuerRr r r!�_result��

zIocpProactor._resultrcC�||�|�t�t�}zt|tj�r|�|��||�n|�|��|�Wnt	y2|�
d�YSwdd�}|�|||�S)N�c
S�Bz|��WSty }z|jtjtjfvrt|j���d}~wwr<��	getresultr1rVrUZERROR_NETNAME_DELETEDZERROR_OPERATION_ABORTED�ConnectionResetErrorr��r��keyrr4r r r!�finish_recv��
�
��z&IocpProactor.recv.<locals>.finish_recv)�_register_with_iocprU�
Overlappedrw�
isinstance�socketZWSARecvr�ZReadFiler�r��	_register�r�conn�nbytesr{rr�r r r!�recv��

��
zIocpProactor.recvcCr�)Nrc
Sr�r<r�r�r r r!r��r�z+IocpProactor.recv_into.<locals>.finish_recv)r�rUr�rwr�r�ZWSARecvIntor�ZReadFileIntor�r�r�)rr��bufr{rr�r r r!�	recv_into�r�zIocpProactor.recv_intocCs^|�|�t�t�}z|�|��||�Wnty#|�d�YSwdd�}|�|||�S)N)r�Nc
Sr�r<r�r�r r r!r�r�z*IocpProactor.recvfrom.<locals>.finish_recv)	r�rUr�rwZWSARecvFromr�r�r�r�r�r r r!�recvfrom�s

�
zIocpProactor.recvfromcCs>|�|�t�t�}|�|��|||�dd�}|�|||�S)Nc
Sr�r<r�r�r r r!�finish_sendr�z(IocpProactor.sendto.<locals>.finish_send)r�rUr�rwZ	WSASendTor�r�)rr�r�r{r�rr�r r r!�sendtos



zIocpProactor.sendtocCsZ|�|�t�t�}t|tj�r|�|��||�n|�|��|�dd�}|�	|||�S)Nc
Sr�r<r�r�r r r!r�&r�z&IocpProactor.send.<locals>.finish_send)
r�rUr�rwr�r�ZWSASendr�Z	WriteFiler�)rr�r�r{rr�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_SOCKETrUZSO_UPDATE_ACCEPT_CONTEXT�
settimeoutZ
gettimeoutZgetpeername)r�r�rr��r��listenerr r!�
finish_accept8s�z*IocpProactor.accept.<locals>.finish_acceptc�s.�z|IdHWdStjy|���wr<)rr�r)r.r�r r r!�accept_coroAs��z(IocpProactor.accept.<locals>.accept_coror)r��_get_accept_socket�familyrUr�rwZAcceptExr�r�r	Z
ensure_futurer2)rr�rr�r�r.�coror r�r!�accept2s

	
zIocpProactor.acceptc
s��jtjkrt����|�|j��}|�d�|S|�	��zt�
����j�Wn"tyL}z|j
tjkr9����ddkrB�WYd}~nd}~wwt�t�}|����|��fdd�}|�|�|�S)Nrrcs|����tjtjd��SrL)r�r�r�r�rUZSO_UPDATE_CONNECT_CONTEXT�r�r�r�r�r r!�finish_connectds
�z,IocpProactor.connect.<locals>.finish_connect)�typer�Z
SOCK_DGRAMrUZ
WSAConnectr�r2r�r?r�Z	BindLocalr�r1rV�errnoZ	WSAEINVALZgetsocknamer�rwZ	ConnectExr�)rr�r'rR�err�r r�r!�connectNs(


���
zIocpProactor.connectc		Csb|�|�t�t�}|d@}|d?d@}|�|��t�|���|||dd�dd�}|�|||�S)Nr� rc
Sr�r<r�r�r r r!�finish_sendfilewr�z.IocpProactor.sendfile.<locals>.finish_sendfile)	r�rUr�rwZTransmitFiler��msvcrtZ
get_osfhandler�)	rZsock�file�offset�countrZ
offset_lowZoffset_highr�r r r!�sendfilems


�	zIocpProactor.sendfilecsJ|���t�t�}|�����}|r|���S�fdd�}|�|�|�S)Ncs|���Sr<)r�r��r}r r!�finish_accept_pipe�sz4IocpProactor.accept_pipe.<locals>.finish_accept_pipe)r�rUr�rwZConnectNamedPiper�r�r�)rr}rZ	connectedr�r r�r!r��s


zIocpProactor.accept_pipec
�st�t}	zt�|�}Wn)ty$}z
|jtjkr�WYd}~nd}~wwt|dt�}t�	|�IdHqt
�|�S)NT�)�CONNECT_PIPE_INIT_DELAYrUZConnectPiper1rVZERROR_PIPE_BUSY�min�CONNECT_PIPE_MAX_DELAYr	�sleepr
rx)rr'ZdelayrJr4r r r!r��s �
����
zIocpProactor.connect_pipecCs	|�||d�Srs)�_wait_for_handle)rrJr�r r r!�wait_for_handle�szIocpProactor.wait_for_handlecCs|�|dd�}||_|Srk)r�r])rr^Z
done_callbackrRr r r!ri�szIocpProactor._wait_cancelcs�|��|durtj}nt�|d�}t�t�}t�||j	|j
|�}|r.t||||jd��n
t
|||||jd���jr?�jd=�fdd�}�|d|f|j|j
<�S)N�@�@rrcs���Sr<)rOr��r�r r!�finish_wait_for_handle�sz=IocpProactor._wait_for_handle.<locals>.finish_wait_for_handler)r�rM�INFINITE�math�ceilrUr�rwZRegisterWaitWithQueuer�r'r\r2rbrr�)rrJr�Z
_is_cancel�msrrKr�r r�r!r��s$
�
�	zIocpProactor._wait_for_handlecCs4||jvr|j�|�t�|��|jdd�dSdSrL)rIryrUr�r�r��r�objr r r!r��s
�z IocpProactor._register_with_iocpc
Cs�|��t||jd�}|jr|jd=|js:z|dd|�}Wnty4}z|�|�WYd}~n
d}~ww|�|�||||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�rPr�r r r!rhszIocpProactor._unregistercCst�|�}|�d�|SrL)r�r�)rr��sr r r!r�r�zIocpProactor._get_accept_socketcCs�|durt}n|dkrtd��t�|d�}|tkrtd��	t�|j|�}|dur+n�d}|\}}}}z|j�|�\}}	}
}Wn)t	yh|j
��rZ|j
�dd||||fd��|dtj
fvrft�|�Yqw|
|jvrs|��n=|��s�z5z||||	�}Wnty�}
z|�|
�|j�|�WYd}
~
nd}
~
ww|�|�|j�|�Wd}nd}wq|jD]
}	|j�|	jd�q�|j��dS)	Nrznegative timeoutr�ztimeout too bigTz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r,�status)r��
ValueErrorr�r�rUZGetQueuedCompletionStatusr�r��pop�KeyErrorr2Z	get_debugr3r�rMrgr�r0Zdoner1r=r�rPr?r�r'r�)rr�r�r�errZtransferredr�r'r�rr�rr�r�r r r!rOsZ

��	
�


��
��
)zIocpProactor._pollcCs|j�|�dSr<)r�ryr�r r r!�
_stop_servingIszIocpProactor._stop_servingcCs|jdurdSt|j���D]D\}\}}}}|��rqt|t�r!qz|��WqtyR}z|j	durHd||d�}|j
rB|j
|d<|j	�|�WYd}~qd}~wwd}t�
�}	|	|}
|jr|
t�
�krwt�d|t�
�|	�t�
�|}
|�|�|js`g|_t�|j�d|_dS)NzCancelling a future failedr+r/g�?z,%r is running after closing for %.1f seconds)r��listr��itemsZ	cancelledr�r\r0r1r2rr3�time�	monotonicr�debugrOr�rMrg)rr'rRrr�rr4r5Z
msg_updateZ
start_timeZnext_msgr r r!rOsD


�
���
�	
zIocpProactor.closecCs|��dSr<)rrNr r r!r�~szIocpProactor.__del__)rr<)r)rN)rBrCrDrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rir�r�r�rhr�rOrrr�r r r r!r�s:








"
 

9/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��
returncoderNr r!r�s
z4_WindowsSubprocessTransport._start.<locals>.callback)	r
�Popenr
r2rcr��intrGr�)
rr�r�r�r�r�r�r�rr�r rNr!�_start�s���z"_WindowsSubprocessTransport._startN)rBrCrDrr r r r!r��sr�c@�eZdZeZdS)rN)rBrCrDr�
_loop_factoryr r r r!r��rc@r)rN)rBrCrDr
rr r r r!r�rr)1�sys�platform�ImportErrorrUrMr�r�r�r�r�r
rm�rrrrrrr	r
�logr�__all__rwr�ZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDr�r�ZFuturerrFr\rb�objectrjZBaseSelectorEventLoopr�ZBaseProactorEventLoopr
rZBaseSubprocessTransportr�rZBaseDefaultEventLoopPolicyrrrr r r r!�<module>sZ
0J4;jf

?>