%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib64/python3.6/multiprocessing/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib64/python3.6/multiprocessing/__pycache__/connection.cpython-36.pyc

3

��fVy�@sddddgZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZm
Z
dd	lmZejZy$ddlZdd
lmZmZmZmZWn$ek
r�ejdkr‚dZYnXdZd
ZdZej�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�ZFejGe(eE�dJdK�ZHdLdM�ZIejGe'eH�ndNdG�ZEdOdI�ZFejGe(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tj�|S)N)�time�	monotonic)�timeout�r�2/usr/lib64/python3.6/multiprocessing/connection.py�
_init_timeout?srcCstj�|kS)N)rr)�trrr�_check_timeoutBsrcCsX|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_addressIsr&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_familyWs

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_typecs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__ys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�pollsz_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_rbrcrgrrrrr2vs(





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)r7rrrrraJszPipeConnection._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��leftrvZrbytesrrrrPs
zPipeConnection._get_more_data)N)rhrirj�__doc__ryrn�CloseHandler<rJrUrarrrrrrls
 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<gszConnection._closecCs||j�dS)N)r4)r7r<rrrr<lscCs<t|�}x.||j|�}||8}|dkr(P||d�}q
WdS)Nr)rIr4)r7rKr~�	remainingrOrrr�_sendqs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�_recvzs


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�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�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;<s$



zSocketListener.__init__cCs&|jj�\}|_|jd�t|j��S)NT)r�r�r�r�r�r�)r7�srrrr�Ts
zSocketListener.acceptcCs0z|jj�Wd|j}|dk	r*d|_|�XdS)N)r�rBr�)r7r�rrrrBYszSocketListener.closeN)r)rhrirjr�r;r�rBrrrrr�8s
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�cs


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;wszPipeListener.__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�ss


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	||t
�j�}|jd�}||kr^|jt
�n|jt�td��dS)Nr�zdigest received was wrong)�hmacr�rHrrr �urandom�MESSAGE_LENGTHrP�	CHALLENGE�new�HMAC_DIGEST_NAME�digestrW�WELCOME�FAILUREr)�
connectionr�r��messager��responserrrr��s


r�cCs�ddl}t|t�st�|jd�}|dtt��tks@td|��|tt�d�}|j||t�j	�}|j
|�|jd�}|tkr�td��dS)Nrr�zmessage = %rzdigest sent was rejected)
r�r�rHrrrWrIr�r�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�	XmlClient
s
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>vszwait.<locals>.<genexpr>csg|]}|�kr|�qSrr)r��o)�
ready_objectsrr�
<listcomp>wszwait.<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)J�__all__rzr r'r*r�rr�	itertoolsr�rrrr	�contextr
ZForkingPicklerrQrnrrr
r�ImportErrorr(r�ZCONNECTION_TIMEOUTr��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


Zerion Mini Shell 1.0