AlkantarClanX12

Your IP : 3.142.40.195


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

U

&�.ep|�@sddddgZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZm
Z
dd	lmZejZz$ddlZdd
lmZmZmZmZWn$ek
r�ejdkr‚dZYnXdZd
ZdZe��ZdZdgZe ed��rdZedg7Zejdk�rdZedg7Zefdd�Z!dd�Z"dd�Z#dd�Z$dd�Z%Gdd�d�Z&e�rnGdd�de&�Z'Gd d!�d!e&�Z(Gd"d�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.�Z0d/Z1d0Z2d1Z3d2Z4d3d4�Z5d5d6�Z6Gd7d8�d8e)�Z7d9d:�Z8d;d<�Z9Gd=d>�d>e*�Z:d?d@�Z;ejdk�rzdAdB�Z<ej=ej>hZ?dSdCd�Z@n,ddlAZAe eAdD��r�eAjBZCneAjDZCdTdEd�Z@ejdk�r�dFdG�ZEdHdI�ZFe�Ge(eE�dJdK�ZHdLdM�ZIe�Ge'eH�ndNdG�ZEdOdI�ZFe�Ge(eE�dS)U�Client�Listener�Pipe�wait�N�)�util)�AuthenticationError�BufferTooShort)�	reduction)�
WAIT_OBJECT_0�WAIT_ABANDONED_0�WAIT_TIMEOUT�INFINITE�win32i g4@Zsha256�AF_INET�AF_UNIX�AF_PIPEcCst��|S�N��time�	monotonic)�timeout�r�2/usr/lib64/python3.8/multiprocessing/connection.py�
_init_timeout?srcCst��|kSrr)�trrr�_check_timeoutBsrcCsX|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_addressIs��r(cCsJtjdkr|dkrtd|��tjdkrF|dkrFtt|�sFtd|��dS)NrrzFamily %s is not recognized.r)�sys�platformr%�hasattr�socketr&rrr�_validate_familyWs

r-cCsTt|�tkrdSt|�tkr*|�d�r*dSt|�tks@t�|�rDdStd|��dS)Nrz\\rrzaddress type of %r unrecognized)�type�tuple�str�
startswithr�is_abstract_socket_namespacer%)�addressrrr�address_typecs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__ys�z_ConnectionBase.__init__cCs|jdk	r|��dSr�r7�_close�r:rrr�__del__�s
z_ConnectionBase.__del__cCs|jdkrtd��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
|jdkSr�r7rArrr�closed�sz_ConnectionBase.closedcCs|jSr)r8rArrrr<�sz_ConnectionBase.readablecCs|jSr)r9rArrrr=�sz_ConnectionBase.writablecCs|��|jSr)rDr7rArrr�fileno�sz_ConnectionBase.filenocCs$|jdk	r z|��W5d|_XdSrr?rArrrrG�s
z_ConnectionBase.closercCs�|��|��t|�}|jdkr.tt|��}t|�}|dkrFtd��||krVtd��|dkrh||}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|��|��|dk	r(|dkr(td��|�|�}|dkrB|��|��S)Nrznegative maxlength)rDrEr%�_recv_bytesrH�getvalue)r:Z	maxlengthrQrrr�
recv_bytes�s
z_ConnectionBase.recv_bytesc
Cs�|��|��t|���}|j}|t|�}|dkr>td��n||krNtd��|��}|��}|||krvt|�	���|�
d�|�||||||��|W5QR�SQRXdS)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�pollsz_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^rcrfrjrkrprrrrr5vs.








r5c@s@eZdZdZejfdd�Zdd�Zd
dd�Zd	d
�Z	dd�Z
dS)�PipeConnectionFcCs||j�dSrrI)r:Z_CloseHandlerrrr@szPipeConnection._closec	Cshtj|j|dd�\}}z<z |tjkr6t�|jgdt�}Wn|���YnXW5|�d�\}}XdS)NT��
overlappedF)	�_winapiZ	WriteFiler7�GetOverlappedResult�ERROR_IO_PENDING�WaitForMultipleObjects�eventr�cancel)r:rQ�ov�errZnwritten�waitresrrrrPs
�zPipeConnection._send_bytesNc	Cs&|jrd|_t��S|dkr dnt|d�}z�tj|j|dd�\}}dz<z |tjkrdt�
|jgdt�}Wn|���YnXW5|�d�\}}|dkr�t��}|�|�	��|�WS|tj
kr�|�||��WSXWn:tk
�r}z|jtjk�rt�n�W5d}~XYnXtd��dS)NF�Trvrz.shouldn't get here; expected KeyboardInterrupt)�_got_empty_message�io�BytesIO�minrx�ReadFiler7ry�writereZERROR_MORE_DATA�_get_more_datarzr{r|rr}rC�winerror�ERROR_BROKEN_PIPE�EOFError�RuntimeError)	r:�maxsizeZbsizer~rZnread�fr��errrr\*s>
�

�
zPipeConnection._recv_bytescCs.|jst�|j�ddkrdStt|g|��S)NrT)r�rx�
PeekNamedPiper7�boolrrirrrrhJs
�zPipeConnection._pollcCs�|��}t��}|�|�t�|j�d}|dk	rJt|�||krJ|��tj	|j|dd�\}}|�
d�\}}|�|���|S)NrTrv)rer�r�r�rxr�r7rOrHr�ry)r:r~r�rQr��leftrZrbytesrrrr�Ps
zPipeConnection._get_more_data)N)rqrrrsr�rx�CloseHandler@rPr\rhr�rrrrrus
 ruc@sxeZdZer(ejfdd�ZejZej	Z
nejfdd�Zej
ZejZ
efdd�Ze
fdd�Zdd	�Zddd�Zd
d�Zd
S)�
ConnectioncCs||j�dSrrI�r:r@rrrr@gszConnection._closecCs||j�dSrrIr�rrrr@lscCs8t|�}||j|�}||8}|dkr&q4||d�}qdS�Nr)rOr7)r:rQr��	remainingrUrrr�_sendqs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�_recvzs


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|���\}|dk	rT||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|||�|_|dk	rft|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>|jdkrtd��|j��}|jr:t||j�t||j�|S)Nzlistener is closed)r�rC�acceptr��deliver_challenge�answer_challenge)r:�crrrr��s

zListener.acceptcCs |j}|dk	rd|_|��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
	

cCsh|p
t|�}t|�|dkr&t|�}nt|�}|dk	rHt|t�sHtd��|dk	rdt||�t||�|Sr�)	r4r-�
PipeClient�SocketClientr�rNr�r�r�)r3r'r�r�rrrr�s


TcCsj|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

c

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�ConnectNamedPiperyru)
r�r3Zopenmode�accessZobsizeZibsizeZh1Zh2rw�_rr�r�rrrrsT
�
��	��c@s&eZdZd	dd�Zdd�Zdd�ZdS)
r�rcCs�t�tt|��|_zRtjdkr2|j�tjtjd�|j�d�|j�	|�|j�
|�|j��|_Wn t
k
r�|j���YnX||_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>Ks0

�
�
zSocketListener.__init__cCs&|j��\}|_|�d�t|���S�NT)r�r�r�r�r�r��r:�srrrr�ds
zSocketListener.acceptcCs0z|j��W5|j}|dk	r*d|_|�XdSr)r�r�rG)r:r�rrrrGiszSocketListener.closeN)r)rqrrrsr>r�rGrrrrr�Gs
r�c
CsPt|�}t�tt|���.}|�d�|�|�t|���W5QR�SQRXdSr�)r4r,r�r�Zconnectr�r�)r3r'r�rrrr�ss


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�}Wn0tk
r^}z|jtjkrN�W5d}~XYnPXz<zt�
|jgdt�}Wn |�
�t�|��YnXW5|�	d�\}}Xt|�S)NrTrvF)r��appendr��poprxr�rCr�Z
ERROR_NO_DATAryr{r|rr}r�ru)r:r;r~r�r�r�resrrrr��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	k
rz}z |j
tjtjfksht
|�rj�W5d}~XYqXq�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��s8
����r��s#CHALLENGE#s	#WELCOME#s	#FAILURE#cCs�ddl}t|t�s$td�t|����t�t�}|�	t
|�|�||t��
�}|�d�}||krl|�	t�n|�	t�td��dS)Nr� Authkey must be bytes, not {0!s}�zdigest received was wrong)�hmacr�rNr%�formatr.r!�urandom�MESSAGE_LENGTHrV�	CHALLENGE�new�HMAC_DIGEST_NAME�digestr^�WELCOME�FAILUREr�Z
connectionr�r��messager�Zresponserrrr��s
�


r�cCsxddl}t|t�s$td�t|����|�d�}|tt�d�}|�	||t
���}|�|�|�d�}|t
krttd��dS)Nrr�r�zdigest sent was rejected)r�r�rNr%r�r.r^rOr�r�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�rrrrfs
zConnectionWrapper.recvN)rqrrrsr>r[rfrrrrr�sr�cCst�|fdddd��d�S)Nr�utf-8)�	xmlrpclibrX�encode)rZrrr�
_xml_dumpssrcCst�|�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	cOsddlmatt||�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)	�listrxr{r
rrOrr�r�)Zhandlesr�L�readyr�rrr�_exhaustive_wait)s 
 
rc
s^|dkrt}n|dkrd}nt|dd�}t|�}i�g}t��t�}�z@|D�]&}zt|d�}	Wn tk
r�|�|��<YqPXzt	�|	�dd�\}}Wn8tk
r�}zd|j}}|tkrƂW5d}~XYnX|t	jkr�|�|�|�|j<qP|�rjt��dd�dk�rjz|�d	�\}}Wn*tk
�rP}z
|j}W5d}~XYnX|�sjt
|d��rjd|_��|�d}qPt���|�}W5|D]}|���q�|D]�}z|�d�\}}Wn6tk
�r�}z|j}|tk�r�W5d}~XYnX|t	j
k�r��|j}��|�|dk�r�t
|d��r�d|_�q�X���fd
d�|D���fdd
�|D�S)Nrr�g�?Tr�rK�)�rFc3s|]}�|VqdSrr)�.0r�)�waithandle_to_objrr�	<genexpr>�szwait.<locals>.<genexpr>csg|]}|�kr|�qSrr)r�o)�
ready_objectsrr�
<listcomp>�s�wait.<locals>.<listcomp>)r�intr�setr}ryrCr��
_ready_errorsrxZERROR_OPERATION_ABORTEDr|�addr+r�r��AttributeErrorr6r�rzr�r)Zgetwindowsversionr�keys�update)
�object_listrZov_listZ
ready_handlesr~r�rr�rrKr)rrrr?sh







�PollSelectorc
Cs�t���}|D]}|�|tj�q|dk	r4t��|}|�|�}|r\dd�|D�W5QR�S|dk	r4|t��}|dkr4|W5QR�Sq4W5QRXdS)NcSsg|]\}}|j�qSr)Zfileobj)r�keyZeventsrrrr�srr)�
_WaitSelector�register�	selectorsZ
EVENT_READrrZselect)r"rZselectorrZZdeadlinerrrrr�s
c
CsZ|��}t�|tjtj��6}ddlm}|�|�}t||j	|j
ffW5QR�SQRXdS)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
�r/cCs|��}t|||�Sr)r�ru)r.r<r=r;rrrr-�sr-cCs t�|���}t||j|jffSr)r
ZDupFdrKr)r<r=)r�dfrrrr+�scCs|��}t|||�Srr,)r0r<r=�fdrrrr)�s)NN)T)T)N)N)J�__all__r�r!r)r,r�rr �	itertoolsr�rrrr	�contextr
ZForkingPicklerrWrxrrr
r�ImportErrorr*r�ZCONNECTION_TIMEOUTr��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&r/r-rrrr�<module>
s�



PT=

,,8	P