AlkantarClanX12

Your IP : 18.188.205.95


Current Path : /opt/alt/python37/lib64/python3.7/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/multiprocessing/__pycache__/connection.cpython-37.pyc

B

� fBz�@sddddgZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZm
Z
dd	lmZejZy$ddlZdd
lmZmZmZmZWn$ek
r�ejdkr‚dZYnXdZd
Ze��ZdZdgZeed�r�dZedg7Zejdk�rdZedg7Zefdd�Z dd�Z!dd�Z"dd�Z#dd�Z$Gdd�d�Z%e�rhGdd�de%�Z&Gdd �d e%�Z'Gd!d�de(�Z)dOd"d�Z*ejdk�r�dPd$d�Z+n
dQd%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�rtd@dA�Z;ej<ej=hZ>dRdBd�Z?n,ddl@Z@ee@dC��r�e@jAZBne@jCZBdSdDd�Z?ejdk�r�dEdF�ZDdGdH�ZEe�Fe'eD�dIdJ�ZGdKdL�ZHe�Fe&eG�ndMdF�ZDdNdH�ZEe�Fe'eD�dS)T�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/python37/lib64/python3.7/multiprocessing/connection.py�
_init_timeout;srcCst��|kS)N)rr)�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_addressEsr%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�socket)r$rrr�_validate_familySs

r*cCsTt|�tkrdSt|�tkr*|�d�r*dSt|�tks@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r1c@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__usz_ConnectionBase.__init__cCs|jdk	r|��dS)N)r4�_close)r7rrr�__del__�s
z_ConnectionBase.__del__cCs|jdkrtd��dS)Nzhandle is closed)r4�OSError)r7rrr�
_check_closed�s
z_ConnectionBase._check_closedcCs|jstd��dS)Nzconnection is write-only)r5r>)r7rrr�_check_readable�sz_ConnectionBase._check_readablecCs|jstd��dS)Nzconnection is read-only)r6r>)r7rrr�_check_writable�sz_ConnectionBase._check_writablecCs"|jrd|_n|��td��dS)NFzbad message length)r6r5�closer>)r7rrr�_bad_message_length�sz#_ConnectionBase._bad_message_lengthcCs
|jdkS)z True if the connection is closedN)r4)r7rrr�closed�sz_ConnectionBase.closedcCs|jS)z"True if the connection is readable)r5)r7rrrr9�sz_ConnectionBase.readablecCs|jS)z"True if the connection is writable)r6)r7rrrr:�sz_ConnectionBase.writablecCs|��|jS)z+File descriptor or handle of the connection)r?r4)r7rrr�fileno�sz_ConnectionBase.filenocCs$|jdk	r z|��Wdd|_XdS)zClose the connectionN)r4r<)r7rrrrB�s
z_ConnectionBase.closercCs�|��|��t|�}|jdkr.tt|��}t|�}|dkrFtd��||krVtd��|dkrh||}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)r?rA�
memoryview�itemsize�bytes�lenr#�_send_bytes)r7�buf�offset�size�m�nrrr�
send_bytes�s"


z_ConnectionBase.send_bytescCs$|��|��|�t�|��dS)zSend a (picklable) objectN)r?rArJ�_ForkingPickler�dumps)r7�objrrr�send�sz_ConnectionBase.sendcCsJ|��|��|dk	r(|dkr(td��|�|�}|dkrB|��|��S)z7
        Receive bytes data as a bytes object.
        Nrznegative maxlength)r?r@r#�_recv_bytesrC�getvalue)r7Z	maxlengthrKrrr�
recv_bytes�s
z_ConnectionBase.recv_bytesc	Cs�|��|��t|���}|j}|t|�}|dkr>td��n||krNtd��|��}|��}|||krvt|�	���|�
d�|�||||||��|SQRXdS)zq
        Receive bytes data into a writeable bytes-like object.
        Return the number of bytes read.
        rznegative offsetzoffset too largeN)r?r@rFrGrIr#rU�tellr	rV�seek�readinto)r7rKrLrNrGZbytesize�resultrMrrr�recv_bytes_into�s"


z_ConnectionBase.recv_bytes_intocCs&|��|��|��}t�|���S)zReceive a (picklable) object)r?r@rUrQ�loads�	getbuffer)r7rKrrr�recv�sz_ConnectionBase.recv�cCs|��|��|�|�S)z/Whether there is any input available to be read)r?r@�_poll)r7rrrr�poll�sz_ConnectionBase.pollcCs|S)Nr)r7rrr�	__enter__sz_ConnectionBase.__enter__cCs|��dS)N)rB)r7�exc_type�	exc_value�exc_tbrrr�__exit__sz_ConnectionBase.__exit__)TT)rN)N)r)r`)�__name__�
__module__�__qualname__r4r;r=r?r@rArC�propertyrDr9r:rErBrPrTrWr\r_rbrcrgrrrrr2rs(





r2c@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�dS)N)r4)r7Z_CloseHandlerrrr<szPipeConnection._closec	Cs�tj|j|dd�\}}zHy,|tjkrBt�|jgdt�}|tksBt�Wn|�	��YnXWd|�
d�\}}X|dks|t�|t|�ks�t�dS)NT)�
overlappedFr)�_winapiZ	WriteFiler4�ERROR_IO_PENDING�WaitForMultipleObjects�eventrr�AssertionError�cancel�GetOverlappedResultrI)r7rK�ov�err�waitresZnwrittenrrrrJs
zPipeConnection._send_bytesNc	
Cs|jrd|_t��S|dkr dnt|d�}y�tj|j|dd�\}}zHy,|tjkrnt�|j	gdt
�}|tksnt�Wn|�
��YnXWd|�d�\}}|dkr�t��}|�|���|S|tjkr�|�||�SXWn:tk
�r}z|jtjk�r�t�n�Wdd}~XYnXtd��dS)NF�T)rmrz.shouldn't get here; expected KeyboardInterrupt)�_got_empty_message�io�BytesIO�minrn�ReadFiler4rorprqrrrrrsrt�writer^ZERROR_MORE_DATA�_get_more_datar>�winerror�ERROR_BROKEN_PIPE�EOFError�RuntimeError)	r7�maxsizeZbsizerurvrwZnread�f�errrrU&s6


zPipeConnection._recv_bytescCs.|jst�|j�ddkrdStt|g|��S)NrT)ryrn�
PeekNamedPiper4�boolr)r7rrrrraFszPipeConnection._pollcCs�|��}t��}|�|�t�|j�d}|dks6t�|dk	rVt|�||krV|�	�tj
|j|dd�\}}|�d�\}}|dks�t�||ks�t�|�|���|S)NrrT)rm)r^rzr{r~rnr�r4rrrIrCr}rt)r7rur�rKr��leftrvZrbytesrrrrLs
zPipeConnection._get_more_data)N)rhrirj�__doc__ryrn�CloseHandler<rJrUrarrrrrrls
 rlc@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�dS)N)r4)r7r<rrrr<cszConnection._closecCs||j�dS)N)r4)r7r<rrrr<hscCs<t|�}x.||j|�}||8}|dkr(P||d�}q
WdS)Nr)rIr4)r7rKr~�	remainingrOrrr�_sendmszConnection._sendcCsft��}|j}|}xN|dkr`|||�}t|�}|dkrL||krDt�ntd��|�|�||8}qW|S)Nrzgot end of file during message)rzr{r4rIr�r>r~)r7rM�readrKr8r��chunkrOrrr�_recvvs


zConnection._recvcCsDt|�}t�d|�}|dkr2|�|�|�|�n|�||�dS)Nz!ii@)rI�structZpackr�)r7rKrO�headerrrrrJ�s
zConnection._send_bytesNcCs:|�d�}t�d|���\}|dk	r0||kr0dS|�|�S)N�z!i)r�r�ZunpackrV)r7r�rKrMrrrrU�s

zConnection._recv_bytescCst|g|�}t|�S)N)rr�)r7r�rrrrra�szConnection._poll)N)rhrirjr�rn�_multiprocessingZclosesocketr<rTZ_writer_Z_readrrBr~r�r�r�rJrUrarrrrr�\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|||�|_|dk	rft|t�sft	d��||_
dS)Nrzauthkey should be a byte string)r1�default_familyr%r*�PipeListener�	_listener�SocketListener�
isinstancerH�	TypeError�_authkey)r7r0r$�backlog�authkeyrrrr;�szListener.__init__cCs>|jdkrtd��|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�r>�acceptr��deliver_challenge�answer_challenge)r7�crrrr��s

zListener.acceptcCs |j}|dk	rd|_|��dS)zA
        Close the bound socket or named pipe of `self`.
        N)r�rB)r7ZlistenerrrrrB�szListener.closecCs|jjS)N)r��_address)r7rrrr0�szListener.addresscCs|jjS)N)r��_last_accepted)r7rrr�
last_accepted�szListener.last_acceptedcCs|S)Nr)r7rrrrc�szListener.__enter__cCs|��dS)N)rB)r7rdrerfrrrrg�szListener.__exit__)NNrN)rhrirjr�r;r�rBrkr0r�rcrgrrrrr�s
	cCsh|p
t|�}t|�|dkr&t|�}nt|�}|dk	rHt|t�sHtd��|dk	rdt||�t||�|S)z=
    Returns a connection to the address of a `Listener`
    rNzauthkey should be a byte string)	r1r*�
PipeClient�SocketClientr�rHr�r�r�)r0r$r�r�rrrr�s


TcCsj|r>t��\}}|�d�|�d�t|���}t|���}n$t��\}}t|dd�}t|dd�}||fS)zL
        Returns pair of connection objects at either end of a pipe
        TF)r:)r9)r)Z
socketpair�setblockingr��detachr�pipe)�duplex�s1�s2�c1�c2Zfd1Zfd2rrrr�s

c

Cs�td�}|r*tj}tjtjB}tt}}ntj}tj}dt}}t�||tjBtj	Btj
tjBtjBd||tj
tj�}t�||dtjtjtjtj�}t�|tjdd�tj|dd�}|�d�\}	}
|
dks�t�t||d�}t||d�}||fS)	zL
        Returns pair of connection objects at either end of a pipe
        rrrNT)rm)r:)r9)r%rn�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�ConnectNamedPipertrrrl)
r�r0Zopenmode�accessZobsizeZibsizeZh1Zh2rm�_rvr�r�rrrr
s4



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|��|_yRtjdkr2|j�tjtjd�|j�d�|j�	|�|j�
|�|j��|_Wn t
k
r�|j���YnX||_d|_|dkr�t�|�s�tj|tj|fdd�|_nd|_dS)N�posixrTrr)�args�exitpriority)r)�getattr�_socketr�nameZ
setsockoptZ
SOL_SOCKETZSO_REUSEADDRr�ZbindZlistenZgetsocknamer�r>rBZ_familyr�rr/�Finalize�unlink�_unlink)r7r0r$r�rrrr;=s$



zSocketListener.__init__cCs&|j��\}|_|�d�t|���S)NT)r�r�r�r�r�r�)r7�srrrr�Vs
zSocketListener.acceptcCs0z|j��Wd|j}|dk	r*d|_|�XdS)N)r�rBr�)r7r�rrrrB[szSocketListener.closeN)r)rhrirjr�r;r�rBrrrrr�9s
r�c	CsDt|�}t�tt|���"}|�d�|�|�t|���SQRXdS)zO
    Return a connection object connected to the socket given by `address`
    TN)r1r)r�r�Zconnectr�r�)r0r$r�rrrr�es


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=%rr)r�r�)
r��_new_handle�
_handle_queuer�r�	sub_debugr�r��_finalize_pipe_listenerrB)r7r0r�rrrr;yszPipeListener.__init__Fc
CsHtjtjB}|r|tjO}t�|j|tjtjBtjBtj	t
t
tjtj�S)N)
rnr�r�r�r�r�r�r�r�ZPIPE_UNLIMITED_INSTANCESr�r�r�)r7r��flagsrrrr��s

zPipeListener._new_handlec
Cs�|j�|���|j�d�}ytj|dd�}Wn0tk
r^}z|jtjkrN�Wdd}~XYn\Xz<yt�	|j
gdt�}Wn |��t�
|��YnXWd|�d�\}}|dks�t�Xt|�S)NrT)rmF)r��appendr��poprnr�r>r�Z
ERROR_NO_DATArprqrrsr�rtrrrl)r7r8rur��resr�rvrrrr��s"
zPipeListener.acceptcCs(t�d|�x|D]}t�|�qWdS)Nz closing listener with address=%r)rr�rnr�)Zqueuer0r8rrrr��s
z$PipeListener._finalize_pipe_listener)N)F)	rhrirjr�r;r�r��staticmethodr�rrrrr�us


r�c
Cs�t�}x~y6t�|d�t�|tjtjBdtjtjtjtj�}Wn>t	k
r|}z |j
tjtjfksjt
|�rl�Wdd}~XYqXPqW�t�|tjdd�t|�S)zU
        Return a connection object connected to the pipe given by `address`
        i�rN)rrnZ
WaitNamedPiper�r�r�r�r�r�r>r�ZERROR_SEM_TIMEOUTZERROR_PIPE_BUSYrr�r�rl)r0r�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)Nrz Authkey must be bytes, not {0!s}�md5�zdigest received was wrong)�hmacr�rHr#�formatr+r�urandom�MESSAGE_LENGTHrP�	CHALLENGE�new�digestrW�WELCOME�FAILUREr)�
connectionr�r��messager��responserrrr��s



r�cCs�ddl}t|t�s$td�t|����|�d�}|dtt��tksNt	d|��|tt�d�}|�
||d���}|�|�|�d�}|t
kr�td��dS)Nrz Authkey must be bytes, not {0!s}r�zmessage = %rr�zdigest sent was rejected)r�r�rHr#r�r+rWrIr�rrr�r�rPr�r)r�r�r�r�r�r�rrrr��s

 

r�c@s$eZdZdd�Zdd�Zdd�ZdS)�ConnectionWrappercCs:||_||_||_x"dD]}t||�}t|||�qWdS)N)rErBrbrWrP)�_conn�_dumps�_loadsr��setattr)r7�connrRr]�attrrSrrrr;�s

zConnectionWrapper.__init__cCs|�|�}|j�|�dS)N)r�r�rP)r7rSr�rrrrT�s
zConnectionWrapper.sendcCs|j��}|�|�S)N)r�rWr�)r7r�rrrr_�s
zConnectionWrapper.recvN)rhrirjr;rTr_rrrrr��sr�cCst�|fdddd��d�S)Nrzutf-8)�	xmlrpclibrR�encode)rSrrr�
_xml_dumpssr�cCst�|�d��\\}}|S)Nzutf-8)r�r]�decode)r�rS�methodrrr�
_xml_loadssr�c@seZdZdd�ZdS)�XmlListenercCs"ddlmat�|�}t|tt�S)Nr)�
xmlrpc.client�clientr�rr�r�r�r�)r7rSrrrr�
s
zXmlListener.acceptN)rhrirjr�rrrrr�	sr�cOsddlmatt||�tt�S)Nr)r�r�r�r�rr�r�)r��kwdsrrr�	XmlClientsr�cCs�t|�}g}x�|r�t�|d|�}|tkr,Pn\t|krHtt|�krVnn
|t8}n2t|krrtt|�kr�nn
|t8}ntd��|�||�||dd�}d}qW|S)NFzShould not get hererr)	�listrnrpr
rrIrr�r�)Zhandlesr�L�readyr�rrr�_exhaustive_waits 
 
r�c
sl|dkrt}n|dkrd}nt|dd�}t|�}i�g}t��t�}�zF�x0|D�]&}yt|d�}Wn tk
r�|�|��<YqTXyt�|�dd�\}}Wn8t	k
r�}zd|j
}}|tkrʂWdd}~XYnX|tjkr�|�
|�|�|j<qT|�rnt��dd�dk�rny|�d	�\}	}Wn*t	k
�rT}z
|j
}Wdd}~XYnX|�snt|d
��rnd|_��|�d}qTWt���|�}Wdx|D]}|���q�Wx�|D]�}y|�d�\}	}Wn6t	k
�r�}z|j
}|tk�r�Wdd}~XYnX|tjk�r��|j}��|�|dk�r�t|d
��r�d|_�q�WX���fdd�|D���fd
d�|D�S)z�
        Wait till an object in object_list is ready/readable.

        Returns list of those objects in object_list which are ready/readable.
        Nri�g�?rET�)�r�Fryc3s|]}�|VqdS)Nr)�.0r�)�waithandle_to_objrr�	<genexpr>|szwait.<locals>.<genexpr>csg|]}|�kr|�qSrr)r��o)�
ready_objectsrr�
<listcomp>}szwait.<locals>.<listcomp>)r�intr��setr��AttributeErrorr3rnr}r>r��
_ready_errorsror�rqr&Zgetwindowsversionrtr(ry�addr��keysrsZERROR_OPERATION_ABORTED�update)
�object_listrZov_listZ
ready_handlesrrErurvr�r�r)rrrr1sh








�PollSelectorc	Cs�t��x}x|D]}|�|tj�qW|dk	r8t��|}x@|�|�}|rVdd�|D�S|dk	r:|t��}|dkr:|Sq:WWdQRXdS)z�
        Wait till an object in object_list is ready/readable.

        Returns list of those objects in object_list which are ready/readable.
        NcSsg|]\}}|j�qSr)Zfileobj)r��keyZeventsrrrr�szwait.<locals>.<listcomp>r)�
_WaitSelector�register�	selectorsZ
EVENT_READrrZselect)rrZselectorrSZdeadliner�rrrr�s

c	CsN|��}t�|tjtj��*}ddlm}|�|�}t||j	|j
ffSQRXdS)Nr)�resource_sharer)rEr)ZfromfdrZSOCK_STREAMrrZ	DupSocket�rebuild_connectionr9r:)r�r8r�r�dsrrr�reduce_connection�s

rcCs|��}t|��||�S)N)r�r�)rr9r:Zsockrrrr�srcCsB|jrtjnd|jrtjndB}t�|��|�}t||j|jffS)Nr)	r9rnZFILE_GENERIC_READr:ZFILE_GENERIC_WRITEr
Z	DupHandlerE�rebuild_pipe_connection)r�r��dhrrr�reduce_pipe_connection�srcCs|��}t|||�S)N)r�rl)rr9r:r8rrrr�srcCs t�|���}t||j|jffS)N)r
ZDupFdrErr9r:)r��dfrrrr�scCs|��}t|||�S)N)r�r�)rr9r:�fdrrrr�s)NN)T)T)N)N)I�__all__rzrr&r)r�rr�	itertoolsr�rrrr	�contextr
ZForkingPicklerrQrnrrr
r�ImportErrorr'r�ZCONNECTION_TIMEOUT�countr"r�Zfamiliesr(rrr%r*r1r2rlr��objectrrrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�ZERROR_NETNAME_DELETEDrrrr
rZSelectSelectorrrrrrrrrr�<module>
s�




PJ=

,,8	P