AlkantarClanX12

Your IP : 18.116.14.12


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

a

R�f�{�@sgd�ZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZm
Z
ddlmZejZz$ddlZddlmZmZmZmZWn"ey�ejdkr��dZYn0d	Zd
Ze��ZdZdgZeed�r�dZedg7Zejdk�rd
Zed
g7Zefdd�Z dd�Z!dd�Z"dd�Z#dd�Z$Gdd�d�Z%e�rbGdd�de%�Z&Gdd�de%�Z'Gdd�de(�Z)dPd d!�Z*ejdk�r�dQd#d$�Z+n
dRd%d$�Z+Gd&d'�d'e(�Z,d(d)�Z-ejdk�r�Gd*d+�d+e(�Z.d,d-�Z/d.Z0d/Z1d0Z2d1Z3d2d3�Z4d4d5�Z5Gd6d7�d7e(�Z6d8d9�Z7d:d;�Z8Gd<d=�d=e)�Z9d>d?�Z:ejdk�rnd@dA�Z;ej<ej=hZ>dSdBdC�Z?n,ddl@Z@ee@dD��r�e@jAZBne@jCZBdTdEdC�Z?ejdk�r�dFdG�ZDdHdI�ZEe�Fe'eD�dJdK�ZGdLdM�ZHe�Fe&eG�ndNdG�ZDdOdI�ZEe�Fe'eD�dS)U)�Client�Listener�Pipe�wait�N�)�util)�AuthenticationError�BufferTooShort)�	reduction)�
WAIT_OBJECT_0�WAIT_ABANDONED_0�WAIT_TIMEOUT�INFINITE�win32i g4@�AF_INET�AF_UNIX�AF_PIPEcCst��|S�N��time�	monotonic)�timeout�r�?/opt/alt/python39/lib64/python3.9/multiprocessing/connection.py�
_init_timeout;srcCst��|kSrr)�trrr�_check_timeout>srcCsX|dkrdS|dkr&tjdt��d�S|dkrLtjdt��tt�fdd�Std	��dS)
Nr)Z	localhostrrz	listener-)�prefix�dirrz\\.\pipe\pyc-%d-%d-�zunrecognized family)	�tempfileZmktemprZget_temp_dir�os�getpid�next�
_mmap_counter�
ValueError��familyrrr�arbitrary_addressEs��r(cCsJtjdkr|dkrtd|��tjdkrF|dkrFtt|�sFtd|��dS)NrrzFamily %s is not recognized.r)�sys�platformr%�hasattr�socketr&rrr�_validate_familySs

r-cCsTt|�tkrdSt|�tur*|�d�r*dSt|�tus@t�|�rDdStd|��dS)Nrz\\rrzaddress type of %r unrecognized)�type�tuple�str�
startswithr�is_abstract_socket_namespacer%)�addressrrr�address_type_sr4c@s�eZdZdZd+dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	e
dd��Ze
dd��Ze
dd��Z
dd�Zdd�Zd,dd�Zdd�Zd-dd�Zd.d d!�Zd"d#�Zd/d%d&�Zd'd(�Zd)d*�ZdS)0�_ConnectionBaseNTcCs>|��}|dkrtd��|s(|s(td��||_||_||_dS)Nrzinvalid handlez6at least one of `readable` and `writable` must be True)�	__index__r%�_handle�	_readable�	_writable)�self�handle�readable�writablerrr�__init__us�z_ConnectionBase.__init__cCs|jdur|��dSr�r7�_close�r:rrr�__del__�s
z_ConnectionBase.__del__cCs|jdurtd��dS)Nzhandle is closed)r7�OSErrorrArrr�
_check_closed�s
z_ConnectionBase._check_closedcCs|jstd��dS)Nzconnection is write-only)r8rCrArrr�_check_readable�sz_ConnectionBase._check_readablecCs|jstd��dS)Nzconnection is read-only)r9rCrArrr�_check_writable�sz_ConnectionBase._check_writablecCs"|jrd|_n|��td��dS)NFzbad message length)r9r8�closerCrArrr�_bad_message_length�sz#_ConnectionBase._bad_message_lengthcCs
|jduSr�r7rArrr�closed�sz_ConnectionBase.closedcCs|jSr)r8rArrrr<�sz_ConnectionBase.readablecCs|jSr)r9rArrrr=�sz_ConnectionBase.writablecCs|��|jSr)rDr7rArrr�fileno�sz_ConnectionBase.filenocCs*|jdur&z|��Wd|_nd|_0dSrr?rArrrrG�s

z_ConnectionBase.closercCs�|��|��t|�}|jdkr.tt|��}t|�}|dkrFtd��||krVtd��|durh||}n&|dkrztd��n|||kr�td��|�||||��dS)Nrrzoffset is negativezbuffer length < offsetzsize is negativezbuffer length < offset + size)rDrF�
memoryview�itemsize�bytes�lenr%�_send_bytes)r:�buf�offset�size�m�nrrr�
send_bytes�s"


z_ConnectionBase.send_bytescCs$|��|��|�t�|��dSr)rDrFrP�_ForkingPickler�dumps�r:�objrrr�send�sz_ConnectionBase.sendcCsJ|��|��|dur(|dkr(td��|�|�}|durB|��|��S)Nrznegative maxlength)rDrEr%�_recv_bytesrH�getvalue)r:Z	maxlengthrQrrr�
recv_bytes�s
z_ConnectionBase.recv_bytescCs�|��|��t|���}|j}|t|�}|dkr>td��n||krNtd��|��}|��}|||krvt|�	���|�
d�|�||||||��|Wd�S1s�0YdS)Nrznegative offsetzoffset too large)rDrErLrMrOr%r\�tellr	r]�seek�readinto)r:rQrRrTrMZbytesize�resultrSrrr�recv_bytes_into�s$



�z_ConnectionBase.recv_bytes_intocCs&|��|��|��}t�|���Sr)rDrEr\rW�loads�	getbuffer)r:rQrrr�recv�sz_ConnectionBase.recv�cCs|��|��|�|�Sr)rDrE�_poll�r:rrrr�poll�sz_ConnectionBase.pollcCs|SrrrArrr�	__enter__sz_ConnectionBase.__enter__cCs|��dSr�rG�r:�exc_type�	exc_valueZexc_tbrrr�__exit__sz_ConnectionBase.__exit__)TT)rN)N)r)rg)�__name__�
__module__�__qualname__r7r>rBrDrErFrH�propertyrJr<r=rKrGrVr[r^rcrfrjrkrprrrrr5rs.








r5c@s@eZdZdZejfdd�Zdd�Zd
dd�Zd	d
�Z	dd�Z
dS)�PipeConnectionFcCs||j�dSrrI)r:Z_CloseHandlerrrr@szPipeConnection._closec	Csvtj|j|dd�\}}zJz |tjkr6t�|jgdt�}Wn|���Yn0W|�d�\}}n|�d�\}}0dS)NT��
overlappedF)	�_winapiZ	WriteFiler7�ERROR_IO_PENDING�WaitForMultipleObjects�eventr�cancel�GetOverlappedResult)r:rQ�ov�err�waitresZnwrittenrrrrPs

�
 zPipeConnection._send_bytesNc	
Cs�|jrd|_t��S|dur dnt|d�}�z
tj|j|dd�\}}z�z |tjkrdt�|j	gdt
�}Wn|���Yn0W|�d�\}}|dkr�t��}|�
|���|WS|tjkr�|�||�WSnh|�d�\}}|dk�rt��}|�
|���|YWS|tjk�r2|�||�YWS0Wn<t�yr}z"|jtjk�r\t�n�WYd}~n
d}~00td��dS)NF�Trvrz.shouldn't get here; expected KeyboardInterrupt)�_got_empty_message�io�BytesIO�minrx�ReadFiler7ryrzr{rr|r}�writereZERROR_MORE_DATA�_get_more_datarC�winerror�ERROR_BROKEN_PIPE�EOFError�RuntimeError)	r:�maxsizeZbsizer~rr�Znread�f�errrr\&sH
�


�

�
 zPipeConnection._recv_bytescCs.|jst�|j�ddkrdStt|g|��S)NrT)r�rx�
PeekNamedPiper7�boolrrirrrrhFs
�zPipeConnection._pollcCs�|��}t��}|�|�t�|j�d}|durJt|�||krJ|��tj	|j|dd�\}}|�
d�\}}|�|���|S)NrTrv)rer�r�r�rxr�r7rOrHr�r})r:r~r�rQr��leftrZrbytesrrrr�Ls
zPipeConnection._get_more_data)N)rqrrrsr�rx�CloseHandler@rPr\rhr�rrrrrus
 ruc@sxeZdZer(ejfdd�ZejZej	Z
nejfdd�Zej
ZejZ
efdd�Ze
fdd�Zdd	�Zddd�Zd
d�Zd
S)�
ConnectioncCs||j�dSrrI�r:r@rrrr@cszConnection._closecCs||j�dSrrIr�rrrr@hscCs8t|�}||j|�}||8}|dkr&q4||d�}qdS�Nr)rOr7)r:rQr��	remainingrUrrr�_sendmszConnection._sendcCsbt��}|j}|}|dkr^|||�}t|�}|dkrJ||krBt�ntd��|�|�||8}q|S)Nrzgot end of file during message)r�r�r7rOr�rCr�)r:rS�readrQr;r��chunkrUrrr�_recvvs


zConnection._recvcCs�t|�}|dkrHt�dd�}t�d|�}|�|�|�|�|�|�n8t�d|�}|dkrr|�|�|�|�n|�||�dS)Ni����!i����!Qi@)rO�structZpackr�)r:rQrUZ
pre_header�headerrrrrP�s


zConnection._send_bytesNcCs^|�d�}t�d|���\}|dkr@|�d�}t�d|���\}|durT||krTdS|�|�S)N�r�r��r�)r�r�Zunpackr])r:r�rQrSrrrr\�s

zConnection._recv_bytescCst|g|�}t|�Sr)rr�)r:r�rrrrrh�szConnection._poll)N)rqrrrsrx�_multiprocessingZclosesocketr@r[Z_writerfZ_readr!rGr�r�r�r�rPr\rhrrrrr�\s	

r�c@sNeZdZddd�Zdd�Zdd�Zed	d
��Zedd��Zd
d�Z	dd�Z
dS)rNrcCsp|p|rt|�pt}|pt|�}t|�|dkr>t||�|_nt|||�|_|durft|t�sft	d��||_
dS�Nrzauthkey should be a byte string)r4�default_familyr(r-�PipeListener�	_listener�SocketListener�
isinstancerN�	TypeError�_authkey)r:r3r'�backlog�authkeyrrrr>�s�zListener.__init__cCs>|jdurtd��|j��}|jr:t||j�t||j�|S)Nzlistener is closed)r�rC�acceptr��deliver_challenge�answer_challenge)r:�crrrr��s

zListener.acceptcCs |j}|durd|_|��dSr)r�rG)r:ZlistenerrrrrG�szListener.closecCs|jjSr)r��_addressrArrrr3�szListener.addresscCs|jjSr)r��_last_acceptedrArrr�
last_accepted�szListener.last_acceptedcCs|SrrrArrrrk�szListener.__enter__cCs|��dSrrlrmrrrrp�szListener.__exit__)NNrN)rqrrrsr>r�rGrtr3r�rkrprrrrr�s
	

rcCsh|p
t|�}t|�|dkr&t|�}nt|�}|durHt|t�sHtd��|durdt||�t||�|Sr�)	r4r-�
PipeClient�SocketClientr�rNr�r�r�)r3r'r�r�rrrr�s


rTcCsj|r>t��\}}|�d�|�d�t|���}t|���}n$t��\}}t|dd�}t|dd�}||fS)NTF�r=�r<)r,Z
socketpair�setblockingr��detachr!�pipe)�duplex�s1�s2�c1�c2Zfd1Zfd2rrrrs

rc

Cs�td�}|r*tj}tjtjB}tt}}ntj}tj}dt}}t�||tjBtj	Btj
tjBtjBd||tj
tj�}t�||dtjtjtjtj�}t�|tjdd�tj|dd�}|�d�\}	}
t||d�}t||d�}||fS)NrrrTrvr�r�)r(rx�PIPE_ACCESS_DUPLEX�GENERIC_READ�
GENERIC_WRITE�BUFSIZEZPIPE_ACCESS_INBOUND�CreateNamedPipe�FILE_FLAG_OVERLAPPED�FILE_FLAG_FIRST_PIPE_INSTANCE�PIPE_TYPE_MESSAGE�PIPE_READMODE_MESSAGE�	PIPE_WAIT�NMPWAIT_WAIT_FOREVER�NULL�
CreateFile�
OPEN_EXISTING�SetNamedPipeHandleState�ConnectNamedPiper}ru)
r�r3Zopenmode�accessZobsizeZibsizeZh1Zh2rw�_rr�r�rrrrs<

�
�
�	�
�c@s&eZdZd	dd�Zdd�Zdd�ZdS)
r�rcCs�t�tt|��|_zRtjdkr2|j�tjtjd�|j�d�|j�	|�|j�
|�|j��|_Wnt
y�|j���Yn0||_d|_|dkr�t�|�s�tj|tj|fdd�|_nd|_dS)N�posixrTrr��argsZexitpriority)r,�getattr�_socketr!�nameZ
setsockoptZ
SOL_SOCKETZSO_REUSEADDRr�ZbindZlistenZgetsocknamer�rCrGZ_familyr�rr2�Finalize�unlink�_unlink)r:r3r'r�rrrr>Gs(

�
�
zSocketListener.__init__cCs&|j��\}|_|�d�t|���S�NT)r�r�r�r�r�r��r:�srrrr�`s
zSocketListener.acceptcCsJz(|j��W|j}|durFd|_|�n|j}|durDd|_|�0dSr)r�rGr�)r:r�rrrrGes�zSocketListener.closeN)r)rqrrrsr>r�rGrrrrr�Cs
r�cCs\t|�}t�tt|���0}|�d�|�|�t|���Wd�S1sN0YdSr�)r4r,r�r�Zconnectr�r�)r3r'r�rrrr�os


r�c@s4eZdZddd�Zddd�Zdd�Zed	d
��ZdS)
r�NcCsL||_|jdd�g|_d|_t�d|j�tj|tj|j|jfdd�|_	dS)NT)�firstz listener created with address=%rrr�)
r��_new_handle�
_handle_queuer�r�	sub_debugr�r��_finalize_pipe_listenerrG)r:r3r�rrrr>�s�zPipeListener.__init__Fc
CsHtjtjB}|r|tjO}t�|j|tjtjBtjBtj	t
t
tjtj�Sr)
rxr�r�r�r�r�r�r�r�ZPIPE_UNLIMITED_INSTANCESr�r�r�)r:r��flagsrrrr��s

��zPipeListener._new_handlec
Cs�|j�|���|j�d�}ztj|dd�}Wn2ty`}z|jtjkrL�WYd}~nfd}~00zJzt�	|j
gdt�}Wn |��t�
|��Yn0W|�d�\}}n|�d�\}}0t|�S)NrTrvF)r��appendr��poprxr�rCr�Z
ERROR_NO_DATArzr{rr|r�r}ru)r:r;r~r��resr�rrrrr��s(
�

�zPipeListener.acceptcCs$t�d|�|D]}t�|�qdS)Nz closing listener with address=%r)rr�rxr�)Zqueuer3r;rrrr��sz$PipeListener._finalize_pipe_listener)N)F)rqrrrsr>r�r��staticmethodr�rrrrr�s


r�c
Cs�t�}z6t�|d�t�|tjtjBdtjtjtjtj�}Wq�t	y|}z(|j
tjtjfvsft
|�rh�WYd}~qd}~00q�q�t�|tjdd�t|�S)N��r)rrxZ
WaitNamedPiper�r�r�r�r�r�rCr�ZERROR_SEM_TIMEOUTZERROR_PIPE_BUSYrr�r�ru)r3r�hr�rrrr��s*
���
�r��s#CHALLENGE#s	#WELCOME#s	#FAILURE#cCs�ddl}t|t�s$td�t|����t�t�}|�	t
|�|�||d���}|�
d�}||krl|�	t�n|�	t�td��dS)Nr� Authkey must be bytes, not {0!s}�md5�zdigest received was wrong)�hmacr�rNr%�formatr.r!�urandom�MESSAGE_LENGTHrV�	CHALLENGE�new�digestr^�WELCOME�FAILUREr�Z
connectionr�r��messager�Zresponserrrr��s
�


r�cCsxddl}t|t�s$td�t|����|�d�}|tt�d�}|�	||d��
�}|�|�|�d�}|tkrtt
d��dS)Nrr�r�r�zdigest sent was rejected)r�r�rNr%r�r.r^rOr�r�r�rVr�rr�rrrr��s
�


r�c@s$eZdZdd�Zdd�Zdd�ZdS)�ConnectionWrappercCs6||_||_||_dD]}t||�}t|||�qdS)N)rKrGrjr^rV)�_conn�_dumps�_loadsr��setattr)r:�connrXrd�attrrZrrrr>�s
zConnectionWrapper.__init__cCs|�|�}|j�|�dSr)r�r�rV)r:rZr�rrrr[s
zConnectionWrapper.sendcCs|j��}|�|�Sr)r�r^r�r�rrrrfs
zConnectionWrapper.recvN)rqrrrsr>r[rfrrrrr��sr�cCst�|fdddd��d�S)Nr�utf-8)�	xmlrpclibrX�encode)rZrrr�
_xml_dumpssrcCst�|�d��\\}}|S)Nr)rrd�decode)r�rZ�methodrrr�
_xml_loadssrc@seZdZdd�ZdS)�XmlListenercCs"ddlmat�|�}t|tt�Sr�)�
xmlrpc.client�clientrrr�r�rrrYrrrr�s
zXmlListener.acceptN)rqrrrsr�rrrrr	sr	cOs"ddlmatt|i|��tt�Sr�)r
rrr�rrr)r��kwdsrrr�	XmlClientsr
cCs�t|�}g}|r�t�|d|�}|tkr*q�n\t|krFtt|�krTnn
|t8}n2t|krptt|�kr~nn
|t8}ntd��|�||�||dd�}d}q|S)NFzShould not get hererr)	�listrxrzr
rrOrr�r�)Zhandlesr�L�readyr�rrr�_exhaustive_wait%s 
 
rc
s
|durt}n|dkrd}nt|dd�}t|�}i�g}t��t�}�z�|D�](}zt|d�}Wnty�|�|��<YqP0zt�|�dd�\}}Wn:t	y�}z"d|j
}}|tvr‚WYd}~n
d}~00|tjkr�|�
|�|�|j<qP|�rlt��dd�dk�rlz|�d�\}	}Wn,t	�yR}z|j
}WYd}~n
d}~00|�slt|d	��rld|_��|�d}qPt���|�}W|D]}|���q�|D]�}z|�d�\}	}Wn8t	�y�}z|j
}|tv�rނWYd}~n
d}~00|tjk�r��|j}��|�|dk�r�t|d	��r�d|_�q�n�|D]}|���q:|D]�}z|�d�\}	}Wn8t	�y�}z|j
}|tv�r��WYd}~n
d}~00|tjk�rN�|j}��|�|dk�rNt|d	��rNd|_�qN0���fd
d�|D���fdd
�|D�S)Nrr�g�?rKT�)�rFr�c3s|]}�|VqdSrr)�.0r�)�waithandle_to_objrr�	<genexpr>��zwait.<locals>.<genexpr>csg|]}|�vr|�qSrr)r�o)�
ready_objectsrr�
<listcomp>�r�wait.<locals>.<listcomp>)r�intr�setr��AttributeErrorr6rxr�rCr��
_ready_errorsryr�r{r)Zgetwindowsversionr}r+r��addr�keysr|ZERROR_OPERATION_ABORTED�update)
�object_listrZov_listZ
ready_handlesrrKr~rr�r�r)rrrr;s�







�



r�PollSelectorcCs�t���}|D]}|�|tj�q|dur4t��|}|�|�}|r^dd�|D�Wd�S|dur4|t��}|dkr4|Wd�Sq4Wd�n1s�0YdS)NcSsg|]\}}|j�qSr)Zfileobj)r�keyZeventsrrrr�rrr)�
_WaitSelector�register�	selectorsZ
EVENT_READrrZselect)r#rZselectorrZZdeadlinerrrrr�s
cCsf|��}t�|tjtj��8}ddlm}|�|�}t||j	|j
ffWd�S1sX0YdS)Nr)�resource_sharer)rKr,ZfromfdrZSOCK_STREAMrr)Z	DupSocket�rebuild_connectionr<r=)rr;r�r)�dsrrr�reduce_connection�s

r,cCs|��}t|��||�Sr�r�r�)r+r<r=Zsockrrrr*�sr*cCsB|jrtjnd|jrtjndB}t�|��|�}t||j|jffSr�)	r<rxZFILE_GENERIC_READr=ZFILE_GENERIC_WRITEr
Z	DupHandlerK�rebuild_pipe_connection)rr��dhrrr�reduce_pipe_connection�s
�r0cCs|��}t|||�Sr)r�ru)r/r<r=r;rrrr.�sr.cCs t�|���}t||j|jffSr)r
ZDupFdrKr*r<r=)r�dfrrrr,�scCs|��}t|||�Srr-)r1r<r=�fdrrrr*�s)NN)T)T)N)N)I�__all__r�r!r)r,r�rr �	itertoolsr�rrrr	�contextr
ZForkingPicklerrWrxrrr
r�ImportErrorr*r�ZCONNECTION_TIMEOUT�countr$r�Zfamiliesr+rrr(r-r4r5rur��objectrrrr�r�r�r�r�r�r�r�r�r�r�rrr	r
rr�ZERROR_NETNAME_DELETEDrrr(r$r&ZSelectSelectorr,r*r'r0r.rrrr�<module>
s�




PT=

,,8	P