��Qc@sydddgZddlZddlZddlZddlZddlZddlZddlZddlZddl m
Z
mZddlm
Z
mZmZmZddlmZmZdZd Zej�Zd
Zd
gZeed�r dZedg7Znejdkr.d
Zed
g7Zned�Zd�Zd�Zd�Zde fd��YZ!ddd�Z#ejdkr�e$d�Z%nddlm&Z&e$d�Z%de fd��YZ'd�Z(ejdkrde fd��YZ)d�Z*ndZ+dZ,dZ-d Z.d!�Z/d"�Z0d#e fd$��YZ1d%�Z2d&�Z3d'e!fd(��YZ4d)�Z5dS(*tClienttListenertPipei�N(tcurrent_processtAuthenticationError(tget_temp_dirtFinalizet sub_debugtdebug(t duplicatetclosei g4@tAF_INETtAF_UNIXtwin32tAF_PIPEcCstj�|S(N(ttime(ttimeout((s0/sys/lib/python2.7/multiprocessing/connection.pyt
_init_timeoutIscCstj�|kS(N(R(tt((s0/sys/lib/python2.7/multiprocessing/connection.pyt_check_timeoutLscCsw|dkrdS|dkr5tjdddt��S|dkrgtjdd tj�tj�f�Std
��dS(
s?
Return an arbitrary free address for the given family
Rt localhostiRtprefixs listener-tdirRs\\.\pipe\pyc-%d-%d-sunrecognized familyN(Ri(ttempfiletmktempRtostgetpidt
_mmap_countertnextt
ValueError(tfamily((s0/sys/lib/python2.7/multiprocessing/connection.pytarbitrary_addressSscCset|�tkrdSt|�tkr;|jd�r;dSt|�tkrQdStd|��dS(s]
Return the types of the address
This can be 'AF_INET', 'AF_UNIX', or 'AF_PIPE'
Rs\\RRsaddress type of %r unrecognizedN(ttypettupletstrt
startswithR(taddress((s0/sys/lib/python2.7/multiprocessing/connection.pytaddress_typebs!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_familyRtPipeListenert _listenertSocketListenertNonet
isinstancetbytest TypeErrort_authkey(tselfR$Rtbacklogtauthkey((s0/sys/lib/python2.7/multiprocessing/connection.pyt__init__|scCs?|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(tacceptR.tdeliver_challengetanswer_challenge(R/tc((s0/sys/lib/python2.7/multiprocessing/connection.pyR3�s
cCs
|jj�S(sA
Close the bound socket or named pipe of `self`.
(R(R
(R/((s0/sys/lib/python2.7/multiprocessing/connection.pyR
�scCs
|jjS(N(R(t_address(R/((s0/sys/lib/python2.7/multiprocessing/connection.pyt<lambda>�scCs
|jjS(N(R(t_last_accepted(R/((s0/sys/lib/python2.7/multiprocessing/connection.pyR8�sN(
t__name__t
__module__t__doc__R*R2R3R
tpropertyR$t
last_accepted(((s0/sys/lib/python2.7/multiprocessing/connection.pyRus cCs�|pt|�}|dkr-t|�}nt|�}|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
PipeClienttSocketClientR*R+R,R-R5R4(R$RR1R6((s0/sys/lib/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((s0/sys/lib/python2.7/multiprocessing/connection.pyR�s
(R
c CsUtd�}|r;tj}tjtjB}tt}}ntj}tj}dt}}tj||tjtj Btj
Bd||tjtj�}tj
||dtjtjdtj�}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
RiiRARBN(RR
tPIPE_ACCESS_DUPLEXtGENERIC_READt
GENERIC_WRITEtBUFSIZEtPIPE_ACCESS_INBOUNDtCreateNamedPipetPIPE_TYPE_MESSAGEtPIPE_READMODE_MESSAGEt PIPE_WAITtNMPWAIT_WAIT_FOREVERtNULLt
CreateFilet
OPEN_EXISTINGtSetNamedPipeHandleStateR*tConnectNamedPipetWindowsErrortargstERROR_PIPE_CONNECTEDRGtPipeConnection(RMR$topenmodetaccesstobsizetibsizeth1th2teRPRQ((s0/sys/lib/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$tjk
r�|jj
��nX||_d|_|dkr�|tjd|fdd�|_n d|_dS(NiRRdtexitpriorityi(RCtgetattrt_sockett
setsockoptt
SOL_SOCKETtSO_REUSEADDRRERFtbindtlistentgetsocknameR7terrorR
t_familyR*R9RRtunlinkt_unlink(R/R$RR0((s0/sys/lib/python2.7/multiprocessing/connection.pyR2�s
$cCsT|jj�\}|_|jt�t|j��}tj|�}|j �|S(N(
RpR3R9RERFR RJRGRHR
(R/tstfdtconn((s0/sys/lib/python2.7/multiprocessing/connection.pyR3s
cCs-|jj�|jdk r)|j�ndS(N(RpR
RzR*(R/((s0/sys/lib/python2.7/multiprocessing/connection.pyR
s
(R:R;R<R2R3R
(((s0/sys/lib/python2.7/multiprocessing/connection.pyR)�s cCs�t|�}tjtt|��}|jt�t�}xsy|j|�WnXtjk
r�}|jdt j
ks�t|�r�td|��nt
jd�q=XPq=�t|j��}tj|�}|j�|S(sO
Return a connection object connected to the socket given by `address`
isfailed to connect to address %sgz��?(R%RCRoRERFRtconnectRwRdterrnotECONNREFUSEDRRRtsleepR RJRGRHR
(R$RR{RRmR|R}((s0/sys/lib/python2.7/multiprocessing/connection.pyR@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=%rRdRni(R7R
RYRTRZR[R\tPIPE_UNLIMITED_INSTANCESRWR]R^t
_handle_queueR*R9RRR't_finalize_pipe_listenerR
(R/R$R0thandle((s0/sys/lib/python2.7/multiprocessing/connection.pyR2Cs
c Cs�tj|jtjtjtjBtjBtjtttj tj
�}|jj|�|jj
d�}ytj|tj
�Wn8tk
r�}|jdtjtjfkr��q�nXtj|�S(Ni(R
RYR7RTRZR[R\R�RWR]R^R�tappendtpopRbRcRdRet
ERROR_NO_DATARGRf(R/t newhandleR�Rm((s0/sys/lib/python2.7/multiprocessing/connection.pyR3Vs
cCs,td|�x|D]}t|�qWdS(Ns closing listener with address=%r(RR
(tqueueR$R�((s0/sys/lib/python2.7/multiprocessing/connection.pyR�js
N(R:R;R<R*R2R3tstaticmethodR�(((s0/sys/lib/python2.7/multiprocessing/connection.pyR'?s cCs�t�}x�yHtj|d�tj|tjtjBdtjtjdtj�}WnDtk
r�}|j dtj
tjfks�t|�r��q�qXPq�tj
|tjdd�tj|�S(sU
Return a connection object connected to the pipe given by `address`
i�iN(RR
t
WaitNamedPipeR_RURVR^R`RcRdtERROR_SEM_TIMEOUTtERROR_PIPE_BUSYRRaR[R*RGRf(R$RthRm((s0/sys/lib/python2.7/multiprocessing/connection.pyR?ps "
is#CHALLENGE#s #WELCOME#s #FAILURE#cCs�ddl}t|t�s!t�tjt�}|jt|�|j ||�j
�}|jd�}||kr�|jt�n|jt
�td��dS(Ni�isdigest received was wrong(thmacR+R,tAssertionErrorRturandomtMESSAGE_LENGTHt
send_bytest CHALLENGEtnewtdigestt
recv_bytestWELCOMEtFAILURER(t
connectionR1R�tmessageR�tresponse((s0/sys/lib/python2.7/multiprocessing/connection.pyR4�s
cCs�ddl}t|t�s!t�|jd�}|tt� tksVtd|��|tt�}|j||�j�}|j |�|jd�}|t
kr�td��ndS(Ni�ismessage = %rsdigest sent was rejected(R�R+R,R�R�tlenR�R�R�R�R�R(R�R1R�R�R�R�((s0/sys/lib/python2.7/multiprocessing/connection.pyR5�s&
tConnectionWrappercBs#eZd�Zd�Zd�ZRS(cCsO||_||_||_x-dD]%}t||�}t|||�q"WdS(NRJR
tpollR�R�(sfilenoscloseR�s
recv_bytess
send_bytes(t_connt_dumpst_loadsRotsetattr(R/R}tdumpstloadstattrtobj((s0/sys/lib/python2.7/multiprocessing/connection.pyR2�s
cCs#|j|�}|jj|�dS(N(R�R�R�(R/R�R{((s0/sys/lib/python2.7/multiprocessing/connection.pytsend�scCs|jj�}|j|�S(N(R�R�R�(R/R{((s0/sys/lib/python2.7/multiprocessing/connection.pytrecv�s(R:R;R2R�R�(((s0/sys/lib/python2.7/multiprocessing/connection.pyR��s cCs%tj|fdddd�jd�S(Nitutf8(t xmlrpclibR�R*tencode(R�((s0/sys/lib/python2.7/multiprocessing/connection.pyt
_xml_dumps�scCs%tj|jd��\\}}|S(NR�(R�R�tdecode(R{R�tmethod((s0/sys/lib/python2.7/multiprocessing/connection.pyt
_xml_loads�s!tXmlListenercBseZd�ZRS(cCs+ddlatj|�}t|tt�S(Ni�(R�RR3R�R�R�(R/R�((s0/sys/lib/python2.7/multiprocessing/connection.pyR3�s(R:R;R3(((s0/sys/lib/python2.7/multiprocessing/connection.pyR��scOs%ddlatt||�tt�S(Ni�(R�R�RR�R�(Rdtkwds((s0/sys/lib/python2.7/multiprocessing/connection.pyt XmlClient�s(6t__all__RtsysRCRRRt itertoolsRGtmultiprocessingRRtmultiprocessing.utilRRRRtmultiprocessing.forkingR R
RWtCONNECTION_TIMEOUTtcountRR&tfamiliesthasattrtplatformRRRR%tobjectRR*RRFRR
R)R@R'R?R�R�R�R�R4R5R�R�R�R�R�(((s0/sys/lib/python2.7/multiprocessing/connection.pyt<module>#s`" ,*' 1
|