ok

Mini Shell

Direktori : /opt/alt/python38/lib64/python3.8/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/multiprocessing/__pycache__/connection.cpython-38.opt-1.pyc

U

.��c�{�@sddddgZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZm
Z
dd	lmZejZz$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/python38/lib64/python3.8/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|�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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|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
|jdkS)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$|jdk	r z|��W5d|_XdS)zClose the connectionNr?rArrrrG�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)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|��|��|dk	r(|dkr(td��|�|�}|dkrB|��|��S)z7
        Receive bytes data as a bytes object.
        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)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	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�boolrrirrrrhFs
�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�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|���\}|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)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|||�|_|dk	rft|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>|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�rC�acceptr��deliver_challenge�answer_challenge)r:�crrrr��s

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

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`
    rNr�)	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)�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

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)	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�ConnectNamedPiperyru)
r�r3Zopenmode�accessZobsizeZibsizeZh1Zh2rw�_rr�r�rrrrsT
�
��	��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��|_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>Gs0

�
�
zSocketListener.__init__cCs&|j��\}|_|�d�t|���S)NT)r�r�r�r�r�r��r:�srrrr�`s
zSocketListener.acceptcCs0z|j��W5|j}|dk	r*d|_|�XdSr)r�r�rG)r:r�rrrrGeszSocketListener.closeN)r)rqrrrsr�r>r�rGrrrrr�Cs
r�c
CsPt|�}t�tt|���.}|�d�|�|�t|���W5QR�SQRXdS)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�}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�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)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��s8
����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�cCsxddl}t|t�s$td�t|����|�d�}|tt�d�}|�	||d��
�}|�|�|�d�}|tkrtt
d��dS)Nrr�r�r�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
cOsddlmatt||�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)	�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�d	k�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���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�?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)rNcSsg|]\}}|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
�r1cCs|��}t|||�Sr)r�ru)r0r<r=r;rrrr/�sr/cCs t�|���}t||j|jffSr)r
ZDupFdrKr+r<r=)r�dfrrrr-�scCs|��}t|||�Srr.)r2r<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_DELETEDrrr)r%r'ZSelectSelectorr-r+r(r1r/rrrr�<module>
s�




PT=

,,8	P


Zerion Mini Shell 1.0