Your IP : 172.28.240.42


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


|_c@sydddgZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZddlm
Z
mZmZmZddlmZmZdZd	ZejZd
Zd
gZeedr	dZedg7Znejdkr.d
Zed
g7ZnedZdZdZdZde fdYZ!dddZ#ejdkre$dZ%nddlm&Z&e$dZ%de fdYZ'dZ(ejdkrde fdYZ)dZ*ndZ+dZ,dZ-d Z.d!Z/d"Z0d#e fd$YZ1d%Z2d&Z3d'e!fd(YZ4d)Z5dS(*tClienttListenertPipeiN(tcurrent_processtAuthenticationError(tget_temp_dirtFinalizet	sub_debugtdebug(t	duplicatetclosei g4@tAF_INETtAF_UNIXtwin32tAF_PIPEcCstj|S(N(ttime(ttimeout((s0/usr/lib/python2.7/multiprocessing/connection.pyt
_init_timeoutIscCstj|kS(N(R(tt((s0/usr/lib/python2.7/multiprocessing/connection.pyt_check_timeoutLscCsw|dkrdS|dkr5tjdddtS|dkrgtjdd	tjtjfStd
dS(
s?
    Return an arbitrary free address for the given family
    Rt	localhostiRtprefixs	listener-tdirRs\\.\pipe\pyc-%d-%d-sunrecognized familyN(Ri(ttempfiletmktempRtostgetpidt
_mmap_countertnextt
ValueError(tfamily((s0/usr/lib/python2.7/multiprocessing/connection.pytarbitrary_addressSscCset|tkrdSt|tkr;|jdr;dSt|tkrQdStd|dS(s]
    Return the types of the address

    This can be 'AF_INET', 'AF_UNIX', or 'AF_PIPE'
    Rs\\RRsaddress type of %r unrecognizedN(ttypettupletstrt
startswithR(taddress((s0/usr/lib/python2.7/multiprocessing/connection.pytaddress_typebs!cBsSeZdZdddddZdZdZedZedZ	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	rt|trt	dn||_
dS(NRsauthkey should be a byte string(R%tdefault_familyRtPipeListenert	_listenertSocketListenertNonet
isinstancetbytest	TypeErrort_authkey(tselfR$Rtbacklogtauthkey((s0/usr/lib/python2.7/multiprocessing/connection.pyt__init__|scCs?|jj}|jr;t||jt||jn|S(sz
        Accept a connection on the bound socket or named pipe of `self`.

        Returns a `Connection` object.
        (R(tacceptR.tdeliver_challengetanswer_challenge(R/tc((s0/usr/lib/python2.7/multiprocessing/connection.pyR3s
	cCs
|jjS(sA
        Close the bound socket or named pipe of `self`.
        (R(R
(R/((s0/usr/lib/python2.7/multiprocessing/connection.pyR
scCs
|jjS(N(R(t_address(R/((s0/usr/lib/python2.7/multiprocessing/connection.pyt<lambda>scCs
|jjS(N(R(t_last_accepted(R/((s0/usr/lib/python2.7/multiprocessing/connection.pyR8sN(
t__name__t
__module__t__doc__R*R2R3R
tpropertyR$t
last_accepted(((s0/usr/lib/python2.7/multiprocessing/connection.pyRus		cCs|pt|}|dkr-t|}nt|}|dk	rat|tratdn|dk	rt||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-R5R4(R$RR1R6((s0/usr/lib/python2.7/multiprocessing/connection.pyRs
cCs|rktj\}}tjtj|j}tjtj|j}|j|jn<tj\}}tj|dt	}tj|dt	}||fS(sL
        Returns pair of connection objects at either end of a pipe
        twritabletreadable(
tsockett
socketpairt_multiprocessingt
ConnectionRtduptfilenoR
tpipetFalse(tduplexts1ts2tc1tc2tfd1tfd2((s0/usr/lib/python2.7/multiprocessing/connection.pyRs

(R
c	CsUtd}|r;tj}tjtjB}tt}}ntj}tj}dt}}tj||tjtj	Btj
Bd||tjtj}tj
||dtjtjdtj}tj|tj	ddytj|tjWn/tk
r }|jdtjkr!q!nXtj|d|}	tj|d|}
|	|
fS(sL
        Returns pair of connection objects at either end of a pipe
        RiiRARBN(RR
tPIPE_ACCESS_DUPLEXtGENERIC_READt
GENERIC_WRITEtBUFSIZEtPIPE_ACCESS_INBOUNDtCreateNamedPipetPIPE_TYPE_MESSAGEtPIPE_READMODE_MESSAGEt	PIPE_WAITtNMPWAIT_WAIT_FOREVERtNULLt
CreateFilet
OPEN_EXISTINGtSetNamedPipeHandleStateR*tConnectNamedPipetWindowsErrortargstERROR_PIPE_CONNECTEDREtPipeConnection(RKR$topenmodetaccesstobsizetibsizeth1th2teRNRO((s0/usr/lib/python2.7/multiprocessing/connection.pyRs2			

$
R)cBs,eZdZddZdZdZRS(sO
    Representation of a socket which is bound to an address and listening
    icCstjtt||_yR|jjtjtjd|jj||jj||jj|_	Wn$tj
k
r|jjnX||_d|_|dkrt|tjd|fdd|_n	d|_dS(NiRRbtexitpriorityi(RCtgetattrt_sockett
setsockoptt
SOL_SOCKETtSO_REUSEADDRtbindtlistentgetsocknameR7terrorR
t_familyR*R9RRtunlinkt_unlink(R/R$RR0((s0/usr/lib/python2.7/multiprocessing/connection.pyR2s
		$cCsG|jj\}|_t|j}tj|}|j|S(N(RnR3R9R	RHRERFR
(R/tstfdtconn((s0/usr/lib/python2.7/multiprocessing/connection.pyR3s

cCs-|jj|jdk	r)|jndS(N(RnR
RxR*(R/((s0/usr/lib/python2.7/multiprocessing/connection.pyR
s
(R:R;R<R2R3R
(((s0/usr/lib/python2.7/multiprocessing/connection.pyR)s	cCst|}tjtt|}t}xsy|j|WnXtjk
r}|jdtjksxt	|rt
d|ntjdq0XPq0t
|j}tj|}|j|S(sO
    Return a connection object connected to the socket given by `address`
    isfailed to connect to address %sg{Gz?(R%RCRmRtconnectRuRbterrnotECONNREFUSEDRRRtsleepR	RHRERFR
(R$RRyRRkRzR{((s0/usr/lib/python2.7/multiprocessing/connection.pyR@s"	"

R'cBs2eZdZddZdZedZRS(s0
        Representation of a named pipe
        c	Cs||_tj|tjtjtjBtjBtjtttj	tj
}|g|_d|_
td|jt|tjd|j|jfdd|_dS(Ns listener created with address=%rRbRli(R7R
RWRRRXRYRZtPIPE_UNLIMITED_INSTANCESRUR[R\t
_handle_queueR*R9RRR't_finalize_pipe_listenerR
(R/R$R0thandle((s0/usr/lib/python2.7/multiprocessing/connection.pyR2?s		
	c	Cstj|jtjtjtjBtjBtjtttj	tj
}|jj||jj
d}ytj|tj
Wn/tk
r}|jdtjkrqnXtj|S(Ni(R
RWR7RRRXRYRZRRUR[R\RtappendtpopR`RaRbRcRERd(R/t	newhandleRRk((s0/usr/lib/python2.7/multiprocessing/connection.pyR3Rs

cCs,td|x|D]}t|qWdS(Ns closing listener with address=%r(RR
(tqueueR$R((s0/usr/lib/python2.7/multiprocessing/connection.pyRcs

N(R:R;R<R*R2R3tstaticmethodR(((s0/usr/lib/python2.7/multiprocessing/connection.pyR';s	cCst}xyHtj|dtj|tjtjBdtjtjdtj}WnDtk
r}|j	dtj
tjfkst|rqqXPqtj
|tjddtj|S(sU
        Return a connection object connected to the pipe given by `address`
        iiN(RR
t
WaitNamedPipeR]RSRTR\R^RaRbtERROR_SEM_TIMEOUTtERROR_PIPE_BUSYRR_RYR*RERd(R$RthRk((s0/usr/lib/python2.7/multiprocessing/connection.pyR?is 	"
is#CHALLENGE#s	#WELCOME#s	#FAILURE#cCsddl}t|ts!ttjt}|jt||j	||j
}|jd}||kr|jtn|jt
tddS(Niisdigest received was wrong(thmacR+R,tAssertionErrorRturandomtMESSAGE_LENGTHt
send_bytest	CHALLENGEtnewtdigestt
recv_bytestWELCOMEtFAILURER(t
connectionR1RtmessageRtresponse((s0/usr/lib/python2.7/multiprocessing/connection.pyR4s
cCsddl}t|ts!t|jd}|tt tksVtd||tt}|j||j}|j	||jd}|t
krtdndS(Niismessage = %rsdigest sent was rejected(RR+R,RRtlenRRRRRR(RR1RRRR((s0/usr/lib/python2.7/multiprocessing/connection.pyR5s&
tConnectionWrappercBs#eZdZdZdZRS(cCsO||_||_||_x-dD]%}t||}t|||q"WdS(NRHR
tpollRR(sfilenoscloseRs
recv_bytess
send_bytes(t_connt_dumpst_loadsRmtsetattr(R/R{tdumpstloadstattrtobj((s0/usr/lib/python2.7/multiprocessing/connection.pyR2s			
cCs#|j|}|jj|dS(N(RRR(R/RRy((s0/usr/lib/python2.7/multiprocessing/connection.pytsendscCs|jj}|j|S(N(RRR(R/Ry((s0/usr/lib/python2.7/multiprocessing/connection.pytrecvs(R:R;R2RR(((s0/usr/lib/python2.7/multiprocessing/connection.pyRs		cCs%tj|fddddjdS(Nitutf8(t	xmlrpclibRR*tencode(R((s0/usr/lib/python2.7/multiprocessing/connection.pyt
_xml_dumpsscCs%tj|jd\\}}|S(NR(RRtdecode(RyRtmethod((s0/usr/lib/python2.7/multiprocessing/connection.pyt
_xml_loadss!tXmlListenercBseZdZRS(cCs+ddlatj|}t|ttS(Ni(RRR3RRR(R/R((s0/usr/lib/python2.7/multiprocessing/connection.pyR3s(R:R;R3(((s0/usr/lib/python2.7/multiprocessing/connection.pyRscOs%ddlatt||ttS(Ni(RRRRR(Rbtkwds((s0/usr/lib/python2.7/multiprocessing/connection.pyt	XmlClients(6t__all__RtsysRCR}RRt	itertoolsREtmultiprocessingRRtmultiprocessing.utilRRRRtmultiprocessing.forkingR	R
RUtCONNECTION_TIMEOUTtcountRR&tfamiliesthasattrtplatformRRRR%tobjectRR*RtTrueRR
R)R@R'R?RRRRR4R5RRRRR(((s0/usr/lib/python2.7/multiprocessing/connection.pyt<module>#s`"				,*%	.