Hacked By AnonymousFox

Current Path : /proc/thread-self/root/proc/self/root/opt/alt/python36/lib64/python3.6/multiprocessing/__pycache__/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/opt/alt/python36/lib64/python3.6/multiprocessing/__pycache__/connection.cpython-36.pyc

3

� f�x�@sddddgZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZm
Z
dd	lmZejZy$ddlZdd
lmZmZmZmZWn$ek
r�ejdkr‚dZYnXdZd
Zej�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�ZEejFe'eD�dIdJ�ZGdKdL�ZHejFe&eG�ndMdF�ZDdNdH�ZEejFe'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tj�|S)N)�time�	monotonic)�timeout�r�?/opt/alt/python36/lib64/python3.6/multiprocessing/connection.py�
_init_timeout;srcCstj�|kS)N)rr)�trrr�_check_timeout>srcCsX|dkrdS|dkr&tjdtj�d�S|dkrLtjdtj�tt�fd	d�Std
��dS)
z?
    Return an arbitrary free address for the given family
    r�	localhostrrz	listener-)�prefix�dirrz\\.\pipe\pyc-%d-%d-�zunrecognized familyN)rr)	�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+cCsJt|�tkrdSt|�tkr*|jd�r*dSt|�tkr:dStd|��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$)�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�_ConnectionBaseNTcCsB|j�}|dkrtd��|r,|r,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|jdk	r|j�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|j�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|j�|jS)z+File descriptor or handle of the connection)r?r4)r7rrr�fileno�sz_ConnectionBase.filenocCs$|jdk	r z|j�Wdd|_XdS)zClose the connectionN)r4r<)r7rrrrB�s
z_ConnectionBase.closercCs�|j�|j�t|�}|jdkr.tt|��}t|�}|dkrFtd��||krVtd��|dkrh||}n&|dkrztd��n|||kr�td��|j||||��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$|j�|j�|jtj|��dS)zSend a (picklable) objectN)r?rArJ�_ForkingPickler�dumps)r7�objrrr�send�sz_ConnectionBase.sendcCsJ|j�|j�|dk	r(|dkr(td��|j|�}|dkrB|j�|j�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�|j�|j�t|���}|j}|t|�}|dkr>td��n||krNtd��|j�}|j�}|||krvt|j	���|j
d�|j||||||��|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&|j�|j�|j�}tj|j��S)zReceive a (picklable) object)r?r@rUrQ�loads�	getbuffer)r7rKrrr�recv�sz_ConnectionBase.recv�cCs|j�|j�|j|�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|j�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._closecCs�tj|j|dd�\}}zHy,|tjkrBtj|jgdt�}|tksBt�Wn|j	��YnXWd|j
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|_tj�S|dkr dnt|d�}y�tj|j|dd�\}}zHy,|tjkrntj|j	gdt
�}|tksnt�Wn|j
��YnXWd|jd�\}}|dkr�tj�}|j|j��|S|tjkr�|j||�SXWn:tk
�r}z|jtjk�r�t�n�WYdd}~XnXtd��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.|jstj|j�ddkrdStt|g|��S)NrT)ryrn�
PeekNamedPiper4�boolr)r7rrrrraFszPipeConnection._pollcCs�|j�}tj�}|j|�tj|j�d}|dks6t�|dk	rVt|�||krV|j	�tj
|j|dd�\}}|jd�\}}|dks�t�||ks�t�|j|j��|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._sendcCsftj�}|j}|}xN|dkr`|||�}t|�}|dkrL||krDt�ntd��|j|�||8}qW|S)Nrzgot end of file during message)rzr{r4rIr�r>r~)r7rM�readrKr8r��chunkrOrrr�_recvvs


zConnection._recvcCsDt|�}tjd|�}|dkr2|j|�|j|�n|j||�dS)Nz!ii@)rI�structZpackr�)r7rKrO�headerrrrrJ�s
zConnection._send_bytesNcCs:|jd�}tjd|j��\}|dk	r0||kr0dS|j|�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_readr rBr~r�r�r�rJrUrarrrrr�\s	
r�c@sReZdZdZddd�Zdd�Zdd	�Zed
d��Zedd��Z	d
d�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.
    NrcCsr|p|rt|�pt}|pt|�}t|�|dkr>t||�|_nt|||�|_|dk	rht|t�rht	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��|jj�}|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|_|j�dS)zA
        Close the bound socket or named pipe of `self`.
        N)r�rB)r7ZlistenerrrrrB�szListener.closecCs|jjS)N)r��_address)r7rrr�<lambda>�szListener.<lambda>cCs|jjS)N)r��_last_accepted)r7rrrr��scCs|S)Nr)r7rrrrc�szListener.__enter__cCs|j�dS)N)rB)r7rdrerfrrrrg�szListener.__exit__)NNrN)rhrirjr�r;r�rBrkr0Z
last_acceptedrcrgrrrrr�s
	cCsj|p
t|�}t|�|dkr&t|�}nt|�}|dk	rJt|t�rJtd��|dk	rft||�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>tj�\}}|jd�|jd�t|j��}t|j��}n$tj�\}}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}}tj||tjBtj	Btj
tjBtjBd||tj
tj�}tj||dtjtjtjtj�}tj|tjdd�tj|dd�}|jd�\}	}
|
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�rrrrs4



c@s*eZdZdZd
dd�Zdd�Zdd�Zd	S)r�zO
    Representation of a socket which is bound to an address and listening
    rcCs�tjtt|��|_yRtjdkr2|jjtjtjd�|jjd�|jj	|�|jj
|�|jj�|_Wn t
k
r�|jj��YnX||_d|_|dkr�tj|tj|fdd�|_nd|_dS)N�posixrTrr)�args�exitpriority)r*�getattr�_socketr �nameZ
setsockoptZ
SOL_SOCKETZSO_REUSEADDRr�ZbindZlistenZgetsocknamer�r>rBZ_familyr�r�Finalize�unlink�_unlink)r7r0r%r�rrrr;8s$



zSocketListener.__init__cCs&|jj�\}|_|jd�t|j��S)NT)r�r�r�r�r�r�)r7�srrrr�Ps
zSocketListener.acceptcCs0z|jj�Wd|j}|dk	r*d|_|�XdS)N)r�rBr�)r7r�rrrrBUszSocketListener.closeN)r)rhrirjr�r;r�rBrrrrr�4s
r�c	CsDt|�}tjtt|���"}|jd�|j|�t|j��SQRXdS)zO
    Return a connection object connected to the socket given by `address`
    TN)r1r*r�r�Zconnectr�r�)r0r%r�rrrr�_s


r�c@s8eZdZdZddd�Zd
dd�Zdd	�Zed
d��ZdS)r�z0
        Representation of a named pipe
        NcCsL||_|jdd�g|_d|_tjd|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;sszPipeListener.__init__Fc	CsHtjtjB}|r|tjO}tj|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_handlecCs�|jj|j��|jjd�}ytj|dd�}Wn0tk
r^}z|jtjkrN�WYdd}~Xn\Xz<ytj	|j
gdt�}Wn |j�tj
|��YnXWd|jd�\}}|dks�t�Xt|�S)NrT)rmF)r��appendr��poprnr�r>r�Z
ERROR_NO_DATArprqrrsr�rtrrrl)r7r8rur��resr�rvrrrr��s"
zPipeListener.acceptcCs(tjd|�x|D]}tj|�qWdS)Nz closing listener with address=%r)rr�rnr�)Zqueuer0r8rrrr��s
z$PipeListener._finalize_pipe_listener)N)F)	rhrirjr�r;r�r��staticmethodr�rrrrr�os


r�cCs�t�}x~y6tj|d�tj|tjtjBdtjtjtjtj�}Wn>t	k
r|}z"|j
tjtjfksjt
|�rl�WYdd}~XqXPqW�tj|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#cCstddl}t|t�st�tjt�}|jt|�|j	||d�j
�}|jd�}||kr^|jt�n|jt
�td��dS)Nr�md5�zdigest received was wrong)�hmacr�rHrrr �urandom�MESSAGE_LENGTHrP�	CHALLENGE�new�digestrW�WELCOME�FAILUREr)�
connectionr�r��messager��responserrrr��s


r�cCs�ddl}t|t�st�|jd�}|dtt��tks@td|��|tt�d�}|j||d�j�}|j	|�|jd�}|t
kr�td��dS)Nrr�zmessage = %rr�zdigest sent was rejected)r�r�rHrrrWrIr�r�r�rPr�r)r�r�r�r�r�r�rrrr��s
 

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

zConnectionWrapper.__init__cCs|j|�}|jj|�dS)N)r�r�rP)r7rSr�rrrrT�s
zConnectionWrapper.sendcCs|jj�}|j|�S)N)r�rWr�)r7r�rrrr_�s
zConnectionWrapper.recvN)rhrirjr;rTr_rrrrr��sr�cCstj|fdddd�jd�S)Nrzutf-8)�	xmlrpclibrR�encode)rSrrr�
_xml_dumps�sr�cCstj|jd��\\}}|S)Nzutf-8)r�r]�decode)r�rS�methodrrr�
_xml_loads�sr�c@seZdZdd�ZdS)�XmlListenercCs ddljatj|�}t|tt�S)Nr)�
xmlrpc.client�clientr�rr�r�r�r�)r7rSrrrr�s

zXmlListener.acceptN)rhrirjr�rrrrr��sr�cOsddljatt||�tt�S)Nr)r�r�r�r�rr�r�)r��kwdsrrr�	XmlClients
r�cCs�t|�}g}x�|r�tj|d|�}|tkr,Pn\t|koFtt|�knrV|t8}n2t|koptt|�knr�|t8}ntd��|j||�||dd�}d}qW|S)NFzShould not get hererr)	�listrnrpr
rrIrr�r�)Zhandlesr�L�readyr�rrr�_exhaustive_waits 
 
r�c
.sn|dkrt}n|dkrd}nt|dd�}t|�}i�g}t��t�}�zH�x2|D�](}yt|d�}Wn tk
r�|�|j�<YqTXytj|�dd�\}}Wn8t	k
r�}zd|j
}}|tkrʂWYdd}~XnX|tjkr�|j
|�|�|j<qT|�rptj�dd�dk�rpy|jd	�\}	}Wn*t	k
�rT}z|j
}WYdd}~XnX|�rpt|d
��rpd|_�j|�d}qTWt�j�|�}Wdx|D]}|j��q�Wx�|D]�}y|jd�\}	}Wn6t	k
�r�}z|j
}|tk�r�WYdd}~XnX|tjk�r��|j}�j|�|dk�r�t|d
��r�d|_�q�WX�j�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��Fryc3s|]}�|VqdS)Nr)�.0r�)�waithandle_to_objrr�	<genexpr>rszwait.<locals>.<genexpr>csg|]}|�kr|�qSrr)r��o)�
ready_objectsrr�
<listcomp>sszwait.<locals>.<listcomp>)r�r�)r�intr��setr��AttributeErrorr3rnr}r>r��
_ready_errorsror�rqr'Zgetwindowsversionrtr)ry�addr��keysrsZERROR_OPERATION_ABORTED�update)
�object_listrZov_listZ
ready_handlesrrErurvr�r�r)rr�rr'sh








�PollSelectorcCs�t��x}x|D]}|j|tj�qW|dk	r8tj�|}x@|j|�}|rVdd�|D�S|dk	r:|tj�}|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)rrZselectorrSZdeadliner�rrrr�s

cCsN|j�}tj|tjtj��*}ddlm}|j|�}t||j	|j
ffSQRXdS)Nr)�resource_sharer)rEr*ZfromfdrZSOCK_STREAMrrZ	DupSocket�rebuild_connectionr9r:)r�r8r�r�dsrrr�reduce_connection�s

rcCs|j�}t|j�||�S)N)r�r�)rr9r:Zsockrrrr�srcCsB|jrtjnd|jrtjndB}tj|j�|�}t||j|jffS)Nr)	r9rnZFILE_GENERIC_READr:ZFILE_GENERIC_WRITEr
Z	DupHandlerE�rebuild_pipe_connection)r�r��dhrrr�reduce_pipe_connection�srcCs|j�}t|||�S)N)r�rl)rr9r:r8rrrr�srcCs tj|j��}t||j|jffS)N)r
ZDupFdrErr9r:)r��dfrrrr�scCs|j�}t|||�S)N)r�r�)rr9r:�fdrrrr�s)NN)T)T)N)N)I�__all__rzr r'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�




PJ8

,+8
	P


Hacked By AnonymousFox1.0, Coded By AnonymousFox