AlkantarClanX12

Your IP : 18.227.52.248


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.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	��d
S)z?
    Return an arbitrary free address for the given family
    r)Z	localhostrrz	listener-)�prefix�dirrz\\.\pipe\pyc-%d-%d-�zunrecognized familyN)	�tempfileZmktemprZget_temp_dir�os�getpid�next�
_mmap_counter�
ValueError��familyrrr�arbitrary_addressEs��r(cCsJtjdkr|dkrtd|��tjdkrF|dkrFtt|�sFtd|��dS)zD
    Checks if the family is valid for the current environment.
    rrzFamily %s is not recognized.rN)�sys�platformr%�hasattr�socketr&rrr�_validate_familySs

r-cCsTt|�tkrdSt|�tur*|�d�r*dSt|�tus@t�|�rDdStd|��dS)z]
    Return the types of the address

    This can be 'AF_INET', 'AF_UNIX', or 'AF_PIPE'
    rz\\rrzaddress type of %r unrecognizedN)�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
|jduS)z True if the connection is closedN�r7rArrr�closed�sz_ConnectionBase.closedcCs|jS)z"True if the connection is readable)r8rArrrr<�sz_ConnectionBase.readablecCs|jS)z"True if the connection is writable)r9rArrrr=�sz_ConnectionBase.writablecCs|��|jS)z+File descriptor or handle of the connection)rDr7rArrr�fileno�sz_ConnectionBase.filenocCs*|jdur&z|��Wd|_nd|_0dS)zClose the connectionNr?rArrrrG�s

z_ConnectionBase.closercCs�|��|��t|�}|jdkr.tt|��}t|�}|dkrFtd��||krVtd��|durh||}n&|dkrztd��n|||kr�td��|�||||��dS)z,Send the bytes data from a bytes-like objectrrzoffset is negativezbuffer length < offsetNzsize 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�|��dS)zSend a (picklable) objectN)rDrFrP�_ForkingPickler�dumps�r:�objrrr�send�sz_ConnectionBase.sendcCsJ|��|��|dur(|dkr(td��|�|�}|durB|��|��S)z7
        Receive bytes data as a bytes object.
        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)zq
        Receive bytes data into a writeable bytes-like object.
        Return the number of bytes read.
        rznegative offsetzoffset too largeN)rDrErLrMrOr%r\�tellr	r]�seek�readinto)r:rQrRrTrMZbytesize�resultrSrrr�recv_bytes_into�s$



�z_ConnectionBase.recv_bytes_intocCs&|��|��|��}t�|���S)zReceive a (picklable) object)rDrEr\rW�loads�	getbuffer)r:rQrrr�recv�sz_ConnectionBase.recv�cCs|��|��|�|�S)z/Whether there is any input available to be read)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@sDeZdZdZdZejfdd�Zdd�Zddd	�Z	d
d�Z
dd
�ZdS)�PipeConnectionz�
        Connection class based on a Windows named pipe.
        Overlapped I/O is used, so the handles must have been created
        with FILE_FLAG_OVERLAPPED.
        FcCs||j�dSrrI)r:Z_CloseHandlerrrr@szPipeConnection._closec	Cs�tj|j|dd�\}}zVz,|tjkrBt�|jgdt�}|tksBJ�Wn|���Yn0W|�	d�\}}n|�	d�\}}0|dks�J�|t
|�ks�J�dS)NT��
overlappedFr)�_winapiZ	WriteFiler7�ERROR_IO_PENDING�WaitForMultipleObjects�eventrr�cancel�GetOverlappedResultrO)r:rQ�ov�err�waitresZnwrittenrrrrPs

�
 zPipeConnection._send_bytesNc	
Cs�|jrd|_t��S|dur dnt|d�}�ztj|j|dd�\}}z�z,|tjkrpt�|j	gdt
�}|tkspJ�Wn|���Yn0W|�
d�\}}|dkr�t��}|�|���|WS|tjkr�|�||�WSnh|�
d�\}}|dk�rt��}|�|���|YWS|tjk�r>|�||�YWS0Wn<t�y~}z"|jtjk�rht�n�WYd}~n
d}~00td��dS)NF�Trvrz.shouldn't get here; expected KeyboardInterrupt)�_got_empty_message�io�BytesIO�minrx�ReadFiler7ryrzr{rrr|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}|dks6J�|durVt|�||krV|��tj	|j|dd�\}}|�
d�\}}|dks�J�||ks�J�|�|���|S)NrrTrv)rer�r�r�rxr�r7rOrHr�r})r:r~r�rQr��leftrZrbytesrrrr�Ls
zPipeConnection._get_more_data)N)rqrrrs�__doc__r�rx�CloseHandler@rPr\rhr�rrrrrus
 ruc@s|eZdZdZer,ejfdd�ZejZ	ej
Znej
fdd�ZejZ	ejZe	fdd�Zefdd�Zd	d
�Zddd
�Zdd�ZdS)�
Connectionzo
    Connection class based on an arbitrary file descriptor (Unix only), or
    a socket handle (Windows).
    cCs||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)rqrrrsr�rx�_multiprocessingZclosesocketr@r[Z_writerfZ_readr!rGr�r�r�r�rPr\rhrrrrr�\s	

r�c@sReZdZdZddd�Zdd�Zdd	�Zed
d��Zedd
��Z	dd�Z
dd�ZdS)rz�
    Returns a listener object.

    This is a wrapper for a bound socket which is 'listening' for
    connections, or for a Windows named pipe.
    NrcCsp|p|rt|�pt}|pt|�}t|�|dkr>t||�|_nt|||�|_|durft|t�sft	d��||_
dS)Nr�authkey 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)zz
        Accept a connection on the bound socket or named pipe of `self`.

        Returns a `Connection` object.
        Nzlistener is closed)r�rC�acceptr��deliver_challenge�answer_challenge)r:�crrrr��s

zListener.acceptcCs |j}|durd|_|��dS)zA
        Close the bound socket or named pipe of `self`.
        N)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>r�rGrtr3r�rkrprrrrr�s
	

rcCsh|p
t|�}t|�|dkr&t|�}nt|�}|durHt|t�sHtd��|durdt||�t||�|S)z=
    Returns a connection to the address of a `Listener`
    rNr�)	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)�L
        Returns pair of connection objects at either end of a pipe
        TF�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�\}	}
|
dks�J�t||d�}t||d�}||fS)	r�rrrNTrvr�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*eZdZdZd
dd�Zdd�Zdd�Zd	S)r�zO
    Representation of a socket which is bound to an address and listening
    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>r�rGrrrrr�Cs
r�cCs\t|�}t�tt|���0}|�d�|�|�t|���Wd�S1sN0YdS)zO
    Return a connection object connected to the socket given by `address`
    TN)r4r,r�r�Zconnectr�r�)r3r'r�rrrr�os


r�c@s8eZdZdZddd�Zd
dd�Zdd	�Zed
d��ZdS)r�z0
        Representation of a named pipe
        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}~n~d}~00zVzt�	|j
gdt�}Wn |��t�
|��Yn0W|�d�\}}|dks�J�n|�d�\}}|dks�J�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�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)zU
        Return a connection object connected to the pipe given by `address`
        ��rN)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�cCs�ddl}t|t�s$td�t|����|�d�}|dtt��tksNJd|��|tt�d�}|�	||d��
�}|�|�|�d�}|tkr�t
d��dS)Nrr�r�zmessage = %rr�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_loadssr	c@seZdZdd�ZdS)�XmlListenercCs"ddlmat�|�}t|tt�Sr�)�
xmlrpc.client�clientrrr�r�rr	rYrrrr�s
zXmlListener.acceptN)rqrrrsr�rrrrr
sr
cOs"ddlmatt|i|��tt�Sr�)rrrr�rrr	)r��kwdsrrr�	XmlClientsrcCs�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���fdd�|D���fd
d�|D�S)��
        Wait till an object in object_list is ready/readable.

        Returns list of those objects in object_list which are ready/readable.
        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)rNcSsg|]\}}|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
�r2cCs|��}t|||�Sr)r�ru)r1r<r=r;rrrr0�sr0cCs t�|���}t||j|jffSr)r
ZDupFdrKr,r<r=)r�dfrrrr.�scCs|��}t|||�Srr/)r3r<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�rr	r
rrr�ZERROR_NETNAME_DELETEDr!rr*r&r(ZSelectSelectorr.r,r)r2r0rrrr�<module>
s�




PT=

,,8	P