Your IP : 3.22.217.176


Current Path : /lib64/python2.7/multiprocessing/
Upload File :
Current File : //lib64/python2.7/multiprocessing/connection.pyc

�
{fc@s�dddgZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZddlm
Z
mZmZmZddlmZmZdZd	Zd
Zej�ZdZdgZeed�rdZedg7Znejd
kr4dZedg7Zned�Zd�Zd�Zd�Z de!fd��YZ"ddd�Z$ejd
kr�e%d�Z&nddlm'Z'e%d�Z&de!fd��YZ(d�Z)ejd
kr
de!fd��YZ*d�Z+ndZ,dZ-d Z.d!Z/d"�Z0d#�Z1d$�Z2d%e!fd&��YZ3d'�Z4d(�Z5d)e"fd*��YZ6d+�Z7dS(,tClienttListenertPipei����N(tcurrent_processtAuthenticationError(tget_temp_dirtFinalizet	sub_debugtdebug(t	duplicatetclosei g4@tsha256tAF_INETtAF_UNIXtwin32tAF_PIPEcCstj�|S(N(ttime(ttimeout((s2/usr/lib64/python2.7/multiprocessing/connection.pyt
_init_timeoutMscCstj�|kS(N(R(tt((s2/usr/lib64/python2.7/multiprocessing/connection.pyt_check_timeoutPscCs}|dkrd
S|dkr5tjdddt��S|dkrmtjdd	tj�tj�fdd
�Std��dS(s?
    Return an arbitrary free address for the given family
    Rt	localhostiR
tprefixs	listener-tdirRs\\.\pipe\pyc-%d-%d-tsunrecognized familyN(Ri(ttempfiletmktempRtostgetpidt
_mmap_countertnextt
ValueError(tfamily((s2/usr/lib64/python2.7/multiprocessing/connection.pytarbitrary_addressWs cCset|�tkrdSt|�tkr;|jd�r;dSt|�tkrQdStd|��dS(s]
    Return the types of the address

    This can be 'AF_INET', 'AF_UNIX', or 'AF_PIPE'
    Rs\\RR
saddress type of %r unrecognizedN(ttypettupletstrt
startswithR(taddress((s2/usr/lib64/python2.7/multiprocessing/connection.pytaddress_typefs!cBsSeZdZddddd�Zd�Zd�Zed��Zed��Z	RS(s�
    Returns a listener object.

    This is a wrapper for a bound socket which is 'listening' for
    connections, or for a Windows named pipe.
    icCs�|p|rt|�pt}|p-t|�}|dkrQt||�|_nt|||�|_|dk	r�t|t�r�t	d�n||_
dS(NRsauthkey should be a byte string(R'tdefault_familyR!tPipeListenert	_listenertSocketListenertNonet
isinstancetbytest	TypeErrort_authkey(tselfR&R tbacklogtauthkey((s2/usr/lib64/python2.7/multiprocessing/connection.pyt__init__�scCs?|jj�}|jr;t||j�t||j�n|S(sz
        Accept a connection on the bound socket or named pipe of `self`.

        Returns a `Connection` object.
        (R*tacceptR0tdeliver_challengetanswer_challenge(R1tc((s2/usr/lib64/python2.7/multiprocessing/connection.pyR5�s
	cCs
|jj�S(sA
        Close the bound socket or named pipe of `self`.
        (R*R
(R1((s2/usr/lib64/python2.7/multiprocessing/connection.pyR
�scCs
|jjS(N(R*t_address(R1((s2/usr/lib64/python2.7/multiprocessing/connection.pyt<lambda>�RcCs
|jjS(N(R*t_last_accepted(R1((s2/usr/lib64/python2.7/multiprocessing/connection.pyR:�RN(
t__name__t
__module__t__doc__R,R4R5R
tpropertyR&t
last_accepted(((s2/usr/lib64/python2.7/multiprocessing/connection.pyRys		cCs�|pt|�}|dkr-t|�}nt|�}|dk	rat|t�ratd�n|dk	r�t||�t||�n|S(s=
    Returns a connection to the address of a `Listener`
    Rsauthkey should be a byte stringN(	R't
PipeClienttSocketClientR,R-R.R/R7R6(R&R R3R8((s2/usr/lib64/python2.7/multiprocessing/connection.pyR�s
cCs�|r�tj�\}}|jt�|jt�tjtj|j���}tjtj|j���}|j	�|j	�n<tj
�\}}tj|dt�}tj|dt�}||fS(sL
        Returns pair of connection objects at either end of a pipe
        twritabletreadable(tsockett
socketpairtsetblockingtTruet_multiprocessingt
ConnectionRtduptfilenoR
tpipetFalse(tduplexts1ts2tc1tc2tfd1tfd2((s2/usr/lib64/python2.7/multiprocessing/connection.pyR�s



(Rc	CsUtd�}|r;tj}tjtjB}tt}}ntj}tj}dt}}tj||tjtj	Btj
Bd||tjtj�}tj
||dtjtjdtj�}tj|tj	dd�ytj|tj�Wn/tk
r }|jdtjkr!�q!nXtj|d|�}	tj|d|�}
|	|
fS(sL
        Returns pair of connection objects at either end of a pipe
        RiiRCRDN(R!RtPIPE_ACCESS_DUPLEXtGENERIC_READt
GENERIC_WRITEtBUFSIZEtPIPE_ACCESS_INBOUNDtCreateNamedPipetPIPE_TYPE_MESSAGEtPIPE_READMODE_MESSAGEt	PIPE_WAITtNMPWAIT_WAIT_FOREVERtNULLt
CreateFilet
OPEN_EXISTINGtSetNamedPipeHandleStateR,tConnectNamedPipetWindowsErrortargstERROR_PIPE_CONNECTEDRItPipeConnection(ROR&topenmodetaccesstobsizetibsizeth1th2teRRRS((s2/usr/lib64/python2.7/multiprocessing/connection.pyR�s2			

$
R+cBs,eZdZdd�Zd�Zd�ZRS(sO
    Representation of a socket which is bound to an address and listening
    icCs�tjtt|��|_yb|jjtjtjd�|jjt�|jj|�|jj	|�|jj
�|_Wn$tjk
r�|jj
��nX||_d|_|dkr�t|tjd|fdd�|_n	d|_dS(NiR
Rftexitpriorityi(REtgetattrt_sockett
setsockoptt
SOL_SOCKETtSO_REUSEADDRRGRHtbindtlistentgetsocknameR9terrorR
t_familyR,R;RRtunlinkt_unlink(R1R&R R2((s2/usr/lib64/python2.7/multiprocessing/connection.pyR4�s 
		$cCs�x\tr^y|jj�\}|_Wn2tjk
rY}|jdtjkr[�q[qXPqW|j	t�t
|j��}tj
|�}|j�|S(Ni(RHRrR5R;RERyRfterrnotEINTRRGR	RLRIRJR
(R1tsRotfdtconn((s2/usr/lib64/python2.7/multiprocessing/connection.pyR5s	


cCsAz|jj�Wd|j}|dk	r<d|_|�nXdS(N(RrR
R|R,(R1R{((s2/usr/lib64/python2.7/multiprocessing/connection.pyR
#s		(R<R=R>R4R5R
(((s2/usr/lib64/python2.7/multiprocessing/connection.pyR+�s	cCs�ttt|��}t�}x�tj|�}|jt�y|j|�Wnbtjk
r�}|j�|j	dt
jks�t|�r�t
d|��ntjd�q!XPq!W�t|j��}tj|�}|j�|S(sO
    Return a connection object connected to the socket given by `address`
    isfailed to connect to address %sg{�G�z�?(RqRER'RRGRHtconnectRyR
RfR}tECONNREFUSEDRRRtsleepR	RLRIRJ(R&R RRRoR�R�((s2/usr/lib64/python2.7/multiprocessing/connection.pyRB-s&	

"

R)cBs2eZdZdd�Zd�Zed��ZRS(s0
        Representation of a named pipe
        c	Cs�||_tj|tjtjtjBtjBtjtttj	tj
�}|g|_d|_
td|j�t|tjd|j|jfdd�|_dS(Ns listener created with address=%rRfRpi(R9RR[RVR\R]R^tPIPE_UNLIMITED_INSTANCESRYR_R`t
_handle_queueR,R;RRR)t_finalize_pipe_listenerR
(R1R&R2thandle((s2/usr/lib64/python2.7/multiprocessing/connection.pyR4Ss		
	c	Cs�tj|jtjtjtjBtjBtjtttj	tj
�}|jj|�|jj
d�}ytj|tj
�Wn8tk
r�}|jdtjtjfkr��q�nXtj|�S(Ni(RR[R9RVR\R]R^R�RYR_R`R�tappendtpopRdReRfRgt
ERROR_NO_DATARIRh(R1t	newhandleR�Ro((s2/usr/lib64/python2.7/multiprocessing/connection.pyR5fs

cCs,td|�x|D]}t|�qWdS(Ns closing listener with address=%r(RR
(tqueueR&R�((s2/usr/lib64/python2.7/multiprocessing/connection.pyR�zs

N(R<R=R>R,R4R5tstaticmethodR�(((s2/usr/lib64/python2.7/multiprocessing/connection.pyR)Os	cCs�t�}x�yHtj|d�tj|tjtjBdtjtjdtj�}WnDtk
r�}|j	dtj
tjfks�t|�r��q�qXPqW�tj
|tjdd�tj|�S(sU
        Return a connection object connected to the pipe given by `address`
        i�iN(RRt
WaitNamedPipeRaRWRXR`RbReRftERROR_SEM_TIMEOUTtERROR_PIPE_BUSYRRcR]R,RIRh(R&RthRo((s2/usr/lib64/python2.7/multiprocessing/connection.pyRA�s 	"
is#CHALLENGE#s	#WELCOME#s	#FAILURE#cCsddl}t|t�S(Ni����(thashlibRqtHMAC_DIGEST_NAME(R�((s2/usr/lib64/python2.7/multiprocessing/connection.pytget_digestmod_for_hmac�scCs�ddl}t|t�s!t�tjt�}|jt|�|j	||t
��j�}|jd�}||kr�|jt
�n|jt�td��dS(Ni����isdigest received was wrong(thmacR-R.tAssertionErrorRturandomtMESSAGE_LENGTHt
send_bytest	CHALLENGEtnewR�tdigestt
recv_bytestWELCOMEtFAILURER(t
connectionR3R�tmessageR�tresponse((s2/usr/lib64/python2.7/multiprocessing/connection.pyR6�s
cCs�ddl}t|t�s!t�|jd�}|tt� tksVtd|��|tt�}|j||t��j	�}|j
|�|jd�}|tkr�td��ndS(Ni����ismessage = %rsdigest sent was rejected(
R�R-R.R�R�tlenR�R�R�R�R�R�R(R�R3R�R�R�R�((s2/usr/lib64/python2.7/multiprocessing/connection.pyR7�s&
tConnectionWrappercBs#eZd�Zd�Zd�ZRS(cCsO||_||_||_x-dD]%}t||�}t|||�q"WdS(NRLR
tpollR�R�(RLR
R�R�R�(t_connt_dumpst_loadsRqtsetattr(R1R�tdumpstloadstattrtobj((s2/usr/lib64/python2.7/multiprocessing/connection.pyR4�s			
cCs#|j|�}|jj|�dS(N(R�R�R�(R1R�R((s2/usr/lib64/python2.7/multiprocessing/connection.pytsend�scCs|jj�}|j|�S(N(R�R�R�(R1R((s2/usr/lib64/python2.7/multiprocessing/connection.pytrecv�s(R<R=R4R�R�(((s2/usr/lib64/python2.7/multiprocessing/connection.pyR��s		cCstj|fdddd�S(Ni(t	xmlrpclibR�R,(R�((s2/usr/lib64/python2.7/multiprocessing/connection.pyt
_xml_dumps�scCstj|�\\}}|S(N(R�R�(RR�tmethod((s2/usr/lib64/python2.7/multiprocessing/connection.pyt
_xml_loads�stXmlListenercBseZd�ZRS(cCs+ddlatj|�}t|tt�S(Ni����(R�RR5R�R�R�(R1R�((s2/usr/lib64/python2.7/multiprocessing/connection.pyR5�s(R<R=R5(((s2/usr/lib64/python2.7/multiprocessing/connection.pyR��scOs%ddlatt||�tt�S(Ni����(R�R�RR�R�(Rftkwds((s2/usr/lib64/python2.7/multiprocessing/connection.pyt	XmlClient�s(8t__all__RtsysRER}RRt	itertoolsRItmultiprocessingRRtmultiprocessing.utilRRRRtmultiprocessing.forkingR	R
RYtCONNECTION_TIMEOUTR�tcountRR(tfamiliesthasattrtplatformRRR!R'tobjectRR,RRHRRR+RBR)RAR�R�R�R�R�R6R7R�R�R�R�R�(((s2/usr/lib64/python2.7/multiprocessing/connection.pyt<module>#sd"				,*2	 1		
			

?>