Jfc@sdddgZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z ddl m Z mZmZmZddlmZmZdZd Zd ZejZd Zd gZeed rd Zed g7Znejd kr4dZedg7ZnedZdZdZdZ de!fdYZ"dddZ$ejd kre%dZ&nddlm'Z'e%dZ&de!fdYZ(dZ)ejd kr de!fdYZ*dZ+ndZ,dZ-d Z.d!Z/d"Z0d#Z1d$Z2d%e!fd&YZ3d'Z4d(Z5d)e"fd*YZ6d+Z7dS(,tClienttListenertPipeiN(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_timeoutPscCsw|dkrd S|dkr5tjdddtS|dkrgtjdd tjtjfStd d S( s? Return an arbitrary free address for the given family R t localhostiR tprefixs listener-tdirRs\\.\pipe\pyc-%d-%d-sunrecognized familyN(Ri(ttempfiletmktempRtostgetpidt _mmap_countertnextt ValueError(tfamily((s2/usr/lib64/python2.7/multiprocessing/connection.pytarbitrary_addressWs    cCset|tkrdSt|tkr;|jdr;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!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_familyR t PipeListenert _listenertSocketListenertNonet isinstancetbytest TypeErrort_authkey(tselfR%Rtbacklogtauthkey((s2/usr/lib64/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(R0tc((s2/usr/lib64/python2.7/multiprocessing/connection.pyR4s  cCs |jjS(sA Close the bound socket or named pipe of `self`. (R)R (R0((s2/usr/lib64/python2.7/multiprocessing/connection.pyR scCs |jjS(N(R)t_address(R0((s2/usr/lib64/python2.7/multiprocessing/connection.pytscCs |jjS(N(R)t_last_accepted(R0((s2/usr/lib64/python2.7/multiprocessing/connection.pyR9sN( t__name__t __module__t__doc__R+R3R4R tpropertyR%t last_accepted(((s2/usr/lib64/python2.7/multiprocessing/connection.pyRys  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.R6R5(R%RR2R7((s2/usr/lib64/python2.7/multiprocessing/connection.pyRs     cCs|rtj\}}|jt|jttjtj|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 socketpairt setblockingtTruet_multiprocessingt ConnectionRtduptfilenoR tpipetFalse(tduplexts1ts2tc1tc2tfd1tfd2((s2/usr/lib64/python2.7/multiprocessing/connection.pyRs    (Rc CsUtd}|r;tj}tjtjB}tt}}ntj}tj}dt}}tj||tjtj Btj Bd||tj tj }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 RiiRBRCN(R RtPIPE_ACCESS_DUPLEXt GENERIC_READt GENERIC_WRITEtBUFSIZEtPIPE_ACCESS_INBOUNDtCreateNamedPipetPIPE_TYPE_MESSAGEtPIPE_READMODE_MESSAGEt PIPE_WAITtNMPWAIT_WAIT_FOREVERtNULLt CreateFilet OPEN_EXISTINGtSetNamedPipeHandleStateR+tConnectNamedPipet WindowsErrortargstERROR_PIPE_CONNECTEDRHtPipeConnection( RNR%topenmodetaccesstobsizetibsizeth1th2teRQRR((s2/usr/lib64/python2.7/multiprocessing/connection.pyRs2      $ R*cBs,eZdZddZdZdZRS(sO Representation of a socket which is bound to an address and listening icCstjtt||_yb|jjtjtjd|jjt|jj||jj ||jj |_ Wn$tj k r|jj nX||_d|_|dkrt|tjd|fdd|_n d|_dS(NiR Ret exitpriorityi(RDtgetattrt_sockett setsockoptt SOL_SOCKETt SO_REUSEADDRRFRGtbindtlistent getsocknameR8terrorR t_familyR+R:RRtunlinkt_unlink(R0R%RR1((s2/usr/lib64/python2.7/multiprocessing/connection.pyR3s     $cCsx\tr^y|jj\}|_Wn2tjk rY}|jdtjkr[q[qXPqW|j tt |j }t j |}|j|S(Ni(RGRqR4R:RDRxReterrnotEINTRRFR RKRHRIR (R0tsRntfdtconn((s2/usr/lib64/python2.7/multiprocessing/connection.pyR4s    cCs-|jj|jdk r)|jndS(N(RqR R{R+(R0((s2/usr/lib64/python2.7/multiprocessing/connection.pyR #s (R;R<R=R3R4R (((s2/usr/lib64/python2.7/multiprocessing/connection.pyR*s  cCst|}tjtt|}|jtt}xsy|j|WnXtjk r}|jdt j kst |rt d|nt jdq=XPq=t|j}tj|}|j|S(sO Return a connection object connected to the socket given by `address` isfailed to connect to address %sg{Gz?(R&RDRpRFRGRtconnectRxReR|t ECONNREFUSEDRRRtsleepR RKRHRIR (R%RR~RRnRR((s2/usr/lib64/python2.7/multiprocessing/connection.pyRA)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=%rReRoi(R8RRZRUR[R\R]tPIPE_UNLIMITED_INSTANCESRXR^R_t _handle_queueR+R:RRR(t_finalize_pipe_listenerR (R0R%R1thandle((s2/usr/lib64/python2.7/multiprocessing/connection.pyR3Ns       c Cstj|jtjtjtjBtjBtjtttj tj }|j j ||j j d}ytj|tj Wn8tk r}|jdtjtjfkrqnXtj|S(Ni(RRZR8RUR[R\R]RRXR^R_RtappendtpopRcRdReRft ERROR_NO_DATARHRg(R0t newhandleRRn((s2/usr/lib64/python2.7/multiprocessing/connection.pyR4as    cCs,td|x|D]}t|qWdS(Ns closing listener with address=%r(RR (tqueueR%R((s2/usr/lib64/python2.7/multiprocessing/connection.pyRus  N(R;R<R=R+R3R4t staticmethodR(((s2/usr/lib64/python2.7/multiprocessing/connection.pyR(Js  cCst}xyHtj|dtj|tjtjBdtjtjdtj}WnDtk r}|j dtj tj fkst |rqq XPq tj |tjddtj|S(sU Return a connection object connected to the pipe given by `address` iiN(RRt WaitNamedPipeR`RVRWR_RaRdRetERROR_SEM_TIMEOUTtERROR_PIPE_BUSYRRbR\R+RHRg(R%RthRn((s2/usr/lib64/python2.7/multiprocessing/connection.pyR@{s  " is #CHALLENGE#s #WELCOME#s #FAILURE#cCsddl}t|tS(Ni(thashlibRptHMAC_DIGEST_NAME(R((s2/usr/lib64/python2.7/multiprocessing/connection.pytget_digestmod_for_hmacs cCsddl}tjt}|jt||j||tj}|j d}||kru|jt n|jt t ddS(Niisdigest received was wrong( thmacRturandomtMESSAGE_LENGTHt send_bytest CHALLENGEtnewRtdigestt recv_bytestWELCOMEtFAILURER(t connectionR2RtmessageRtresponse((s2/usr/lib64/python2.7/multiprocessing/connection.pyR5s   cCsddl}|jd}|tt}|j||tj}|j||jd}|tkrt dndS(Niisdigest sent was rejected( RRtlenRRRRRRR(RR2RRRR((s2/usr/lib64/python2.7/multiprocessing/connection.pyR6s   tConnectionWrappercBs#eZdZdZdZRS(cCsO||_||_||_x-dD]%}t||}t|||q"WdS(NRKR tpollRR(sfilenoscloseRs recv_bytess send_bytes(t_connt_dumpst_loadsRptsetattr(R0Rtdumpstloadstattrtobj((s2/usr/lib64/python2.7/multiprocessing/connection.pyR3s     cCs#|j|}|jj|dS(N(RRR(R0RR~((s2/usr/lib64/python2.7/multiprocessing/connection.pytsendscCs|jj}|j|S(N(RRR(R0R~((s2/usr/lib64/python2.7/multiprocessing/connection.pytrecvs(R;R<R3RR(((s2/usr/lib64/python2.7/multiprocessing/connection.pyRs  cCs%tj|fddddjdS(Nitutf8(t xmlrpclibRR+tencode(R((s2/usr/lib64/python2.7/multiprocessing/connection.pyt _xml_dumpsscCs%tj|jd\\}}|S(NR(RRtdecode(R~Rtmethod((s2/usr/lib64/python2.7/multiprocessing/connection.pyt _xml_loadss!t XmlListenercBseZdZRS(cCs+ddlatj|}t|ttS(Ni(RRR4RRR(R0R((s2/usr/lib64/python2.7/multiprocessing/connection.pyR4s (R;R<R4(((s2/usr/lib64/python2.7/multiprocessing/connection.pyRscOs%ddlatt||ttS(Ni(RRRRR(Retkwds((s2/usr/lib64/python2.7/multiprocessing/connection.pyt XmlClients (8t__all__RtsysRDR|RRt itertoolsRHtmultiprocessingRRtmultiprocessing.utilRRRRtmultiprocessing.forkingR R RXtCONNECTION_TIMEOUTRtcountRR'tfamiliesthasattrtplatformRRR R&tobjectRR+RRGRRR*RAR(R@RRRRRR5R6RRRRR(((s2/usr/lib64/python2.7/multiprocessing/connection.pyt#sd        "      , *. 1