AlkantarClanX12

Your IP : 18.216.42.225


Current Path : /opt/alt/python35/lib64/python3.5/multiprocessing/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/multiprocessing/__pycache__/connection.cpython-35.opt-2.pyc



���]�x�@sIddddgZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZdd	l
m
Z
mZdd
lmZy2ddlZddlmZmZmZmZWn*ek
r"ejdkr�dZYnXd
ZdZej�ZdZdgZeed�rldZedg7Zejdkr�dZedg7Zedd�Zdd�Zdd�Z dd�Z!dd�Z"Gdd�d�Z#er�Gdd�de#�Z$Gd d!�d!e#�Z%Gd"d�de&�Z'ddd#d�Z(ejdkr[d$d%d�Z)nd$d&d�Z)Gd'd(�d(e&�Z*d)d*�Z+ejdkr�Gd+d,�d,e&�Z,d-d.�Z-d/Z.d0Z/d1Z0d2Z1d3d4�Z2d5d6�Z3Gd7d8�d8e&�Z4d9d:�Z5d;d<�Z6Gd=d>�d>e'�Z7d?d@�Z8ejdkr|dAdB�Z9ej:ej;hZ<ddCd�Z=n?ddl>Z>ee>dD�r�e>j?Z@n	e>jAZ@ddEd�Z=ejdkrdFdG�ZBdHdI�ZCejDe%eB�dJdK�ZEdLdM�ZFejDe$eE�n(dNdG�ZBdOdI�ZCejDe%eB�dS)P�Client�Listener�Pipe�wait�N�)�	reduction)�util)�AuthenticationError�BufferTooShort)�ForkingPickler)�
WAIT_OBJECT_0�WAIT_ABANDONED_0�WAIT_TIMEOUT�INFINITE�win32i g4@�AF_INET�AF_UNIX�AF_PIPEcCstj�|S)N)�time)�timeout�r�//opt/alt/python35/lib64/python3.5/connection.py�
_init_timeout;srcCstj�|kS)N)r)�trrr�_check_timeout>srcCs�|dkrdS|dkr8tjdddtj��S|dkrptjdd	tj�tt�fdd
�Std��dS)
Nr�	localhostrr�prefixz	listener-�dirrz\\.\pipe\pyc-%d-%d-�zunrecognized family)rr)	�tempfile�mktempr�get_temp_dir�os�getpid�next�
_mmap_counter�
ValueError)�familyrrr�arbitrary_addressEs r(cCsitjdkr+|dkr+td|��tjdkre|dkrett|�setd|��dS)NrrzFamily %s is not recognized.r)�sys�platformr&�hasattr�socket)r'rrr�_validate_familySs
r-cCset|�tkrdSt|�tkr;|jd�r;dSt|�tkrQdStd|��dS)Nrz\\rrzaddress type of %r unrecognized)�type�tuple�str�
startswithr&)�addressrrr�address_type_s!r3c@s!eZdZdZdddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	e
dd��Ze
dd��Ze
dd��Z
dd�Zdd�Zdddd�Zdd�Zddd�Zdd d!�Zd"d#�Zd$d%d&�Zd'd(�Zd)d*�ZdS)+�_ConnectionBaseNTcCs]|j�}|dkr$td��|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)r6�_close)r9rrr�__del__�sz_ConnectionBase.__del__cCs|jdkrtd��dS)Nzhandle is closed)r6�OSError)r9rrr�
_check_closed�sz_ConnectionBase._check_closedcCs|jstd��dS)Nzconnection is write-only)r7r@)r9rrr�_check_readable�s	z_ConnectionBase._check_readablecCs|jstd��dS)Nzconnection is read-only)r8r@)r9rrr�_check_writable�s	z_ConnectionBase._check_writablecCs/|jrd|_n
|j�td��dS)NFzbad message length)r8r7�closer@)r9rrr�_bad_message_length�s	
z#_ConnectionBase._bad_message_lengthcCs
|jdkS)N)r6)r9rrr�closed�sz_ConnectionBase.closedcCs|jS)N)r7)r9rrrr;�sz_ConnectionBase.readablecCs|jS)N)r8)r9rrrr<�sz_ConnectionBase.writablecCs|j�|jS)N)rAr6)r9rrr�fileno�s
z_ConnectionBase.filenocCs.|jdk	r*z|j�Wdd|_XdS)N)r6r>)r9rrrrD�sz_ConnectionBase.closercCs�|j�|j�t|�}|jdkrAtt|��}t|�}|dkretd��||kr}td��|dkr�||}n7|dkr�td��n|||kr�td��|j||||��dS)Nrrzoffset is negativezbuffer length < offsetzsize is negativezbuffer length < offset + size)rArC�
memoryview�itemsize�bytes�lenr&�_send_bytes)r9�buf�offset�size�m�nrrr�
send_bytes�s"


z_ConnectionBase.send_bytescCs.|j�|j�|jtj|��dS)N)rArCrLr�dumps)r9�objrrr�send�s

z_ConnectionBase.sendcCsg|j�|j�|dk	r8|dkr8td��|j|�}|dkr]|j�|j�S)Nrznegative maxlength)rArBr&�_recv_bytesrE�getvalue)r9�	maxlengthrMrrr�
recv_bytes�s


z_ConnectionBase.recv_bytescCs�|j�|j�t|���}|j}|t|�}|dkrWtd��n||krotd��|j�}|j�}|||kr�t|j	���|j
d�|j||||||��|SWdQRXdS)Nrznegative offsetzoffset too large)rArBrHrIrKr&rV�tellr
rW�seek�readinto)r9rMrNrPrI�bytesize�resultrOrrr�recv_bytes_into�s"

	
z_ConnectionBase.recv_bytes_intocCs3|j�|j�|j�}tj|j��S)N)rArBrVr�loads�	getbuffer)r9rMrrr�recv�s

z_ConnectionBase.recvgcCs!|j�|j�|j|�S)N)rArB�_poll)r9rrrr�poll�s

z_ConnectionBase.pollcCs|S)Nr)r9rrr�	__enter__sz_ConnectionBase.__enter__cCs|j�dS)N)rD)r9�exc_type�	exc_value�exc_tbrrr�__exit__sz_ConnectionBase.__exit__)�__name__�
__module__�__qualname__r6r=r?rArBrCrE�propertyrFr;r<rGrDrRrUrYr_rbrdrerirrrrr4rs(

r4c@s[eZdZdZejdd�Zdd�Zddd�Zd	d
�Z	dd�Z
dS)
�PipeConnectionFcCs||j�dS)N)r6)r9Z_CloseHandlerrrr>szPipeConnection._closecCs�tj|j|dd�\}}zJy.|tjkrQtj|jgdt�}Wn|j��YnXWd|jd�\}}XdS)N�
overlappedTF)	�_winapiZ	WriteFiler6�ERROR_IO_PENDING�WaitForMultipleObjects�eventr�cancel�GetOverlappedResult)r9rM�ov�err�waitresZnwrittenrrrrLs!
zPipeConnection._send_bytesNc	Csi|jrd|_tj�S|dkr.dnt|d�}y�tj|j|dd�\}}zJy.|tjkr�tj|j	gdt
�}Wn|j��YnXWd|jd�\}}|dkr�tj�}|j
|j��|S|tjkr|j||�SXWnCtk
rX}z#|jtjkrCt�n�WYdd}~XnXtd��dS)NF�roTrz.shouldn't get here; expected KeyboardInterrupt)�_got_empty_message�io�BytesIO�minrp�ReadFiler6rqrrrsrrtru�writeraZERROR_MORE_DATA�_get_more_datar@�winerror�ERROR_BROKEN_PIPE�EOFError�RuntimeError)	r9�maxsizeZbsizervrwrxZnread�f�errrrV&s6		
!
	zPipeConnection._recv_bytescCs?|js%tj|j�ddkr)dStt|g|��S)NrT)rzrp�
PeekNamedPiper6�boolr)r9rrrrrcFs	zPipeConnection._pollcCs�|j�}tj�}|j|�tj|j�d}|dk	rgt|�||krg|j�tj	|j|dd�\}}|j
d�\}}|j|j��|S)NrroT)rar{r|rrpr�r6rKrEr~ru)r9rvr�rMr��leftrwZrbytesrrrr�Ls
"
!zPipeConnection._get_more_data)rjrkrlrzrp�CloseHandler>rLrVrcr�rrrrrns rnc@s�eZdZer9ejdd�ZejZej	Z
n$ejdd�Zej
ZejZ
edd�Ze
dd�Zdd	�Zd
dd�Zd
d�Zd
S)�
ConnectioncCs||j�dS)N)r6)r9r>rrrr>cszConnection._closecCs||j�dS)N)r6)r9r>rrrr>hscCsPt|�}x=||j|�}||8}|dkr8P||d�}qWdS)Nr)rKr6)r9rMr�	remainingrQrrr�_sendms
zConnection._sendcCs�tj�}|j}|}xo|dkr�|||�}t|�}|dkrr||krft�ntd��|j|�||8}qW|S)Nrzgot end of file during message)r{r|r6rKr�r@r)r9rO�readrMr:r��chunkrQrrr�_recvvs		
zConnection._recvcCs\t|�}tjd|�}|dkrG|j|�|j|�n|j||�dS)Nz!ii@)rK�struct�packr�)r9rMrQ�headerrrrrL�s
zConnection._send_bytesNcCsS|jd�}tjd|j��\}|dk	rF||krFdS|j|�S)N�z!i)r�r��unpackrW)r9r�rMrOrrrrV�s
zConnection._recv_bytescCst|g|�}t|�S)N)rr�)r9r�rrrrrc�szConnection._poll)rjrkrlrp�_multiprocessingZclosesocketr>rU�_writerb�_readr"rDrr�r�r�rLrVrcrrrrr�\s				r�c@s|eZdZdddddd�Zdd�Zdd�Zed	d
��Zedd
��Zdd
�Z	dd�Z
dS)rNrcCs�|p|rt|�pt}|p-t|�}t|�|dkr[t||�|_nt|||�|_|dk	r�t|t�r�t	d��||_
dS)Nrzauthkey should be a byte string)r3�default_familyr(r-�PipeListener�	_listener�SocketListener�
isinstancerJ�	TypeError�_authkey)r9r2r'�backlog�authkeyrrrr=�s
zListener.__init__cCsW|jdkrtd��|jj�}|jrSt||j�t||j�|S)Nzlistener is closed)r�r@�acceptr��deliver_challenge�answer_challenge)r9�crrrr��s	zListener.acceptcCs,|j}|dk	r(d|_|j�dS)N)r�rD)r9�listenerrrrrD�s		zListener.closecCs
|jjS)N)r��_address)r9rrr�<lambda>�szListener.<lambda>cCs
|jjS)N)r��_last_accepted)r9rrrr��scCs|S)Nr)r9rrrre�szListener.__enter__cCs|j�dS)N)rD)r9rfrgrhrrrri�szListener.__exit__)rjrkrlr=r�rDrmr2�
last_acceptedrerirrrrr�s	cCs�|pt|�}t|�|dkr7t|�}nt|�}|dk	rkt|t�rktd��|dk	r�t||�t||�|S)Nrzauthkey should be a byte string)	r3r-�
PipeClient�SocketClientr�rJr�r�r�)r2r'r�r�rrrr�s


TcCs�|rYtj�\}}|jd�|jd�t|j��}t|j��}n6tj�\}}t|dd�}t|dd�}||fS)NTr<Fr;)r,�
socketpair�setblockingr��detachr"�pipe)�duplex�s1�s2�c1�c2�fd1�fd2rrrr�s

c
	CsAtd�}|r;tj}tjtjB}tt}}ntj}tj}dt}}tj||tjBtj	Btj
tjBtjBd||tj
tj�}tj||dtjtjtjtj�}tj|tjdd�tj|dd�}|jd�\}	}
t|d|�}t|d|�}||fS)NrrrroTr<r;)r(rp�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�ConnectNamedPiperurn)
r�r2Zopenmode�accessZobsizeZibsizeZh1Zh2ro�_rwr�r�rrrrs2			


c@s7eZdZddd�Zdd�Zdd�ZdS)	r�rcCstjtt|��|_yqtjdkrI|jjtjtjd�|jjd�|jj	|�|jj
|�|jj�|_Wn"t
k
r�|jj��YnX||_d|_|dkr�tj|tjd|fdd�|_n	d|_dS)N�posixrTr�args�exitpriorityr)r,�getattr�_socketr"�name�
setsockopt�
SOL_SOCKET�SO_REUSEADDRr��bind�listen�getsocknamer�r@rD�_familyr�r�Finalize�unlink�_unlink)r9r2r'r�rrrr=8s$


		$zSocketListener.__init__cCs5|jj�\}|_|jd�t|j��S)NT)r�r�r�r�r�r�)r9�srrrr�Ps
zSocketListener.acceptcCs>z|jj�Wd|j}|dk	r9d|_|�XdS)N)r�rDr�)r9r�rrrrDUs		zSocketListener.closeN)rjrkrlr=r�rDrrrrr�4sr�c	Cs\t|�}tjtt|���1}|jd�|j|�t|j��SWdQRXdS)NT)r3r,r�r��connectr�r�)r2r'r�rrrr�_s


r�c@sLeZdZddd�Zddd�Zdd�Zed	d
��ZdS)r�NcCsq||_|jdd�g|_d|_tjd|j�tj|tjd|j|jfdd�|_	dS)N�firstTz listener created with address=%rr�r�r)
r��_new_handle�
_handle_queuer�r�	sub_debugr�r��_finalize_pipe_listenerrD)r9r2r�rrrr=ss		zPipeListener.__init__Fc	CsbtjtjB}|r#|tjO}tj|j|tjtjBtjBtj	t
t
tjtj�S)N)
rpr�r�r�r�r�r�r�r�ZPIPE_UNLIMITED_INSTANCESr�r�r�)r9r��flagsrrrr�~s
	
zPipeListener._new_handlecCs�|jj|j��|jjd�}ytj|dd�}Wn:tk
r}}z|jtjkrk�WYdd}~XnbXzHytj	|j
gdt�}Wn"|j�tj
|��YnXWd|jd�\}}Xt|�S)NrroTF)r��appendr��poprpr�r@r�Z
ERROR_NO_DATArrrsrrtr�rurn)r9r:rvr��resr�rwrrrr��s"

zPipeListener.acceptcCs2tjd|�x|D]}tj|�qWdS)Nz closing listener with address=%r)rr�rpr�)�queuer2r:rrrr��s
z$PipeListener._finalize_pipe_listener)rjrkrlr=r�r��staticmethodr�rrrrr�osr�cCs�t�}x�yKtj|d�tj|tjtjBdtjtjtjtj�}WnOt	k
r�}z/|j
tjtjfks�t
|�r��WYdd}~XqXPqW�tj|tjdd�t|�S)Ni�r)rrpZ
WaitNamedPiper�r�r�r�r�r�r@r�ZERROR_SEM_TIMEOUTZERROR_PIPE_BUSYrr�r�rn)r2r�hr�rrrr��s"	r��s#CHALLENGE#s	#WELCOME#s	#FAILURE#cCs�ddl}tjt�}|jt|�|j||d�j�}|jd�}||krr|jt	�n|jt
�td��dS)Nr�md5�zdigest received was wrong)�hmacr"�urandom�MESSAGE_LENGTHrR�	CHALLENGE�new�digestrY�WELCOME�FAILUREr	)�
connectionr�r��messager��responserrrr��s
r�cCs�ddl}|jd�}|tt�d�}|j||d�j�}|j|�|jd�}|tkr�td��dS)Nrr�r�zdigest sent was rejected)	r�rYrKr�r�r�rRr�r	)r�r�r�r�r�r�rrrr��s
r�c@s4eZdZdd�Zdd�Zdd�ZdS)�ConnectionWrappercCsO||_||_||_x-dD]%}t||�}t|||�q"WdS)NrGrDrdrYrR)rGrDrdrYrR)�_conn�_dumps�_loadsr��setattr)r9�connrSr`�attrrTrrrr=�s			
zConnectionWrapper.__init__cCs#|j|�}|jj|�dS)N)r�r�rR)r9rTr�rrrrU�szConnectionWrapper.sendcCs|jj�}|j|�S)N)r�rYr�)r9r�rrrrb�szConnectionWrapper.recvN)rjrkrlr=rUrbrrrrr��sr�cCs%tj|fdddd�jd�S)Nrzutf-8)�	xmlrpclibrS�encode)rTrrr�
_xml_dumps�srcCs%tj|jd��\\}}|S)Nzutf-8)r�r`�decode)r�rT�methodrrr�
_xml_loads�s!rc@seZdZdd�ZdS)�XmlListenercCs.ddljatj|�}t|tt�S)Nr)�
xmlrpc.client�clientr�rr�r�rr)r9rTrrrr�szXmlListener.acceptN)rjrkrlr�rrrrr�srcOs(ddljatt||�tt�S)Nr)rrr�r�rrr)r��kwdsrrr�	XmlClientsr	cCs�t|�}g}x�|r�tj|d|�}|tkr@Pnrt|koatt|�knrs|t8}n?t|ko�tt|�knr�|t8}ntd��|j||�||dd�}d}qW|S)NFzShould not get hererr)	�listrprrrrrKr
r�r�)Zhandlesr�L�readyr�rrr�_exhaustive_waits	&
&

r
c
.s
|dkrt}n)|dkr*d}nt|dd�}t|�}i�g}t��t�}z�xy|D]q}yt|d�}Wn"tk
r�|�|j�<YqrXy"tj|�dd�\}}WnDt	k
r}z$d|j
}}|tkr�WYdd}~XnX|tjkrE|j
|�|�|j<qr|r�tj�dd�dkr�y|jd�\}	}Wn.t	k
r�}z|j
}WYdd}~XnX|r�t|d	�r�d|_�j|�d}qrWt�j�|�}Wdx|D]}|j�qWx�|D]�}y|jd�\}	}Wn=t	k
r�}z|j
}|tkrn�WYdd}~XnX|tjkr"�|j}�j|�|dkr"t|d	�r"d|_q"WX�j�fd
d�|D���fdd
�|D�S)Nri�g�?rGT��Frzc3s|]}�|VqdS)Nr)�.0r�)�waithandle_to_objrr�	<genexpr>rszwait.<locals>.<genexpr>cs"g|]}|�kr|�qSrr)r�o)�
ready_objectsrr�
<listcomp>ss	zwait.<locals>.<listcomp>)rr)r�intr
�setr��AttributeErrorr5rpr~r@r��
_ready_errorsrqr�rsr)Zgetwindowsversionrur+rz�addr
�keysrtZERROR_OPERATION_ABORTED�update)
�object_listrZov_listZ
ready_handlesrrGrvrwr�r�r)rrrr'sh				

"
"	



	

 �PollSelectorcCs�t���}x!|D]}|j|tj�qW|dk	rLtj�|}xV|j|�}|rudd�|D�S|dk	rO|tj�}|dkrO|SqOWWdQRXdS)NcSsg|]\}}|j�qSr)�fileobj)r�key�eventsrrrr�s	zwait.<locals>.<listcomp>r)�
_WaitSelector�register�	selectors�
EVENT_READr�select)rr�selectorrT�deadlinerrrrr�s
cCsm|j�}tj|tjtj��?}ddlm}|j|�}t||j	|j
ffSWdQRXdS)Nr)�resource_sharer)rGr,�fromfdr�SOCK_STREAMrr)Z	DupSocket�rebuild_connectionr;r<)r�r:r�r)�dsrrr�reduce_connection�s
r.cCs"|j�}t|j�||�S)N)r�r�)r-r;r<�sockrrrr,�sr,cCs_|jrtjnd|jr'tjndB}tj|j�|�}t||j|jffS)Nr)	r;rpZFILE_GENERIC_READr<ZFILE_GENERIC_WRITErZ	DupHandlerG�rebuild_pipe_connection)r�r��dhrrr�reduce_pipe_connection�sr2cCs|j�}t|||�S)N)r�rn)r1r;r<r:rrrr0�sr0cCs.tj|j��}t||j|jffS)N)r�DupFdrGr,r;r<)r��dfrrrr.�scCs|j�}t|||�S)N)r�r�)r4r;r<�fdrrrr,�s)G�__all__r{r"r)r,r�rr�	itertoolsr�rrrr	r
rrprr
rr�ImportErrorr*r��CONNECTION_TIMEOUT�countr%r��familiesr+rrr(r-r3r4rnr��objectrrrr�r�r�r�r�r�r�r�r�r�r�rrrr	r
r�ZERROR_NETNAME_DELETEDrrr$rr"�SelectSelectorr.r,r#r2r0rrrr�<module>
s�&
	

�PJ8,+8
	P