ó ’,bc@sydddgZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z ddl m Z mZmZmZddlmZmZdZd ZejƒZd Zd gZeed ƒr d Zed g7Znejd kr.d Zed g7Zned„Zd„Zd„Zd„Zde fd„ƒYZ!ddd„Z#ejd kr˜e$d„Z%nddlm&Z&e$d„Z%de fd„ƒYZ'd„Z(ejd krde 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(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_timeoutLscCs}|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((s0/usr/lib/python2.7/multiprocessing/connection.pytarbitrary_addressSs     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((s0/usr/lib/python2.7/multiprocessing/connection.pyt address_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_familyR t PipeListenert _listenertSocketListenertNonet isinstancetbytest TypeErrort_authkey(tselfR%Rtbacklogtauthkey((s0/usr/lib/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)tacceptR/tdeliver_challengetanswer_challenge(R0tc((s0/usr/lib/python2.7/multiprocessing/connection.pyR4‹s  cCs |jjƒS(sA Close the bound socket or named pipe of `self`. (R)R (R0((s0/usr/lib/python2.7/multiprocessing/connection.pyR —scCs |jjS(N(R)t_address(R0((s0/usr/lib/python2.7/multiprocessing/connection.pytscCs |jjS(N(R)t_last_accepted(R0((s0/usr/lib/python2.7/multiprocessing/connection.pyR9žsN( t__name__t __module__t__doc__R+R3R4R tpropertyR%t last_accepted(((s0/usr/lib/python2.7/multiprocessing/connection.pyRus  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.R6R5(R%RR2R7((s0/usr/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 socketpairt setblockingtTruet_multiprocessingt ConnectionRtduptfilenoR tpipetFalse(tduplexts1ts2tc1tc2tfd1tfd2((s0/usr/lib/python2.7/multiprocessing/connection.pyR·s    (R c CsUtdƒ}|r;tj}tjtjB}tt}}ntj}tj}dt}}tj||tjtj Btj Bd||tj tj ƒ}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 RiiRBRCN(R R tPIPE_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((s0/usr/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$tj k r£|jj ƒ‚nX||_d|_|dkrét|tjd|fddƒ|_n d|_dS(NiR Ret exitpriorityi(RDtgetattrt_sockett setsockoptt SOL_SOCKETt SO_REUSEADDRRFRGtbindtlistent getsocknameR8terrorR t_familyR+R:RRtunlinkt_unlink(R0R%RR1((s0/usr/lib/python2.7/multiprocessing/connection.pyR3ûs     $cCs›x\tr^y|jjƒ\}|_Wn2tjk rY}|jdtjkr[‚q[qXPqW|j tƒt |j ƒƒ}t j |ƒ}|jƒ|S(Ni(RGRqR4R:RDRxReterrnotEINTRRFR RKRHRIR (R0tsRntfdtconn((s0/usr/lib/python2.7/multiprocessing/connection.pyR4s    cCsAz|jjƒWd|j}|dk r<d|_|ƒnXdS(N(RqR R{R+(R0Rz((s0/usr/lib/python2.7/multiprocessing/connection.pyR s    (R;R<R=R3R4R (((s0/usr/lib/python2.7/multiprocessing/connection.pyR*÷s  cCsêttt|ƒƒ}tƒ}xštj|ƒ}|jtƒy|j|ƒWnbtjk r²}|jƒ|j dt j kst |ƒ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„?(RpRDR&RRFRGtconnectRxR ReR|t ECONNREFUSEDRRRtsleepR RKRHRI(R%RRR~RnRR€((s0/usr/lib/python2.7/multiprocessing/connection.pyRA)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=%rReRoi(R8R RZRUR[R\R]tPIPE_UNLIMITED_INSTANCESRXR^R_t _handle_queueR+R:RRR(t_finalize_pipe_listenerR (R0R%R1thandle((s0/usr/lib/python2.7/multiprocessing/connection.pyR3Os       c CsÅtj|jtjtjtjBtjBtjtttj tj ƒ}|j j |ƒ|j j dƒ}ytj|tj ƒWn8tk r·}|jdtjtjfkr¸‚q¸nXtj|ƒS(Ni(R RZR8RUR[R\R]R„RXR^R_R…tappendtpopRcRdReRft ERROR_NO_DATARHRg(R0t newhandleR‡Rn((s0/usr/lib/python2.7/multiprocessing/connection.pyR4bs    cCs,td|ƒx|D]}t|ƒqWdS(Ns closing listener with address=%r(RR (tqueueR%R‡((s0/usr/lib/python2.7/multiprocessing/connection.pyR†vs  N(R;R<R=R+R3R4t staticmethodR†(((s0/usr/lib/python2.7/multiprocessing/connection.pyR(Ks  cCsÉtƒ}x—yHtj|dƒtj|tjtjBdtjtjdtjƒ}WnDtk rš}|j dtj tj fks‘t |ƒrœ‚qœq XPq W‚tj |tjddƒtj|ƒS(sU Return a connection object connected to the pipe given by `address` ièiN(RR t WaitNamedPipeR`RVRWR_RaRdRetERROR_SEM_TIMEOUTtERROR_PIPE_BUSYRRbR\R+RHRg(R%RthRn((s0/usr/lib/python2.7/multiprocessing/connection.pyR@|s  " is #CHALLENGE#s #WELCOME#s #FAILURE#cCs¡ddl}t|tƒs!t‚tjtƒ}|jt|ƒ|j ||ƒj ƒ}|j dƒ}||kr„|jt ƒn|jt ƒtdƒ‚dS(Niÿÿÿÿisdigest received was wrong(thmacR,R-tAssertionErrorRturandomtMESSAGE_LENGTHt send_bytest CHALLENGEtnewtdigestt recv_bytestWELCOMEtFAILURER(t connectionR2R’tmessageR™tresponse((s0/usr/lib/python2.7/multiprocessing/connection.pyR5 s   cCs¹ddl}t|tƒs!t‚|jdƒ}|ttƒ tksVtd|ƒ‚|ttƒ}|j||ƒjƒ}|j |ƒ|jdƒ}|t krµt dƒ‚ndS(Niÿÿÿÿis message = %rsdigest sent was rejected( R’R,R-R“RštlenR—R˜R™R–R›R(RR2R’RžR™RŸ((s0/usr/lib/python2.7/multiprocessing/connection.pyR6­s &  tConnectionWrappercBs#eZd„Zd„Zd„ZRS(cCsO||_||_||_x-dD]%}t||ƒ}t|||ƒq"WdS(NRKR tpollRšR–(RKR R¢RšR–(t_connt_dumpst_loadsRptsetattr(R0R€tdumpstloadstattrtobj((s0/usr/lib/python2.7/multiprocessing/connection.pyR3¾s     cCs#|j|ƒ}|jj|ƒdS(N(R¤R£R–(R0RªR~((s0/usr/lib/python2.7/multiprocessing/connection.pytsendÅscCs|jjƒ}|j|ƒS(N(R£RšR¥(R0R~((s0/usr/lib/python2.7/multiprocessing/connection.pytrecvÈs(R;R<R3R«R¬(((s0/usr/lib/python2.7/multiprocessing/connection.pyR¡½s  cCstj|fddddƒS(Ni(t xmlrpclibR§R+(Rª((s0/usr/lib/python2.7/multiprocessing/connection.pyt _xml_dumpsÌscCstj|ƒ\\}}|S(N(R­R¨(R~Rªtmethod((s0/usr/lib/python2.7/multiprocessing/connection.pyt _xml_loadsÏst XmlListenercBseZd„ZRS(cCs+ddlatj|ƒ}t|ttƒS(Niÿÿÿÿ(R­RR4R¡R®R°(R0Rª((s0/usr/lib/python2.7/multiprocessing/connection.pyR4Ôs (R;R<R4(((s0/usr/lib/python2.7/multiprocessing/connection.pyR±ÓscOs%ddlatt||ŽttƒS(Niÿÿÿÿ(R­R¡RR®R°(Retkwds((s0/usr/lib/python2.7/multiprocessing/connection.pyt XmlClientÚs (6t__all__RtsysRDR|RRt itertoolsRHtmultiprocessingRRtmultiprocessing.utilRRRRtmultiprocessing.forkingR R RXtCONNECTION_TIMEOUTtcountRR'tfamiliesthasattrtplatformRRR R&tobjectRR+RRGRR R*RAR(R@R•R—R›RœR5R6R¡R®R°R±R³(((s0/usr/lib/python2.7/multiprocessing/connection.pyt#s`        "      , *2 1