ó w®¸Qc@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/sys/lib/python2.7/multiprocessing/connection.pyt _init_timeoutIscCstjƒ|kS(N(R(tt((s0/sys/lib/python2.7/multiprocessing/connection.pyt_check_timeoutLscCsw|dkrd S|dkr5tjdddtƒƒS|dkrgtjdd tjƒtjƒfƒStd ƒ‚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((s0/sys/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/sys/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_familyRt PipeListenert _listenertSocketListenertNonet isinstancetbytest TypeErrort_authkey(tselfR$Rtbacklogtauthkey((s0/sys/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(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.pytscCs |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|ƒ}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-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 socketpairt setblockingtTruet_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||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 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_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$tj k r£|jj ƒ‚nX||_d|_|dkrét|tjd|fddƒ|_n d|_dS(NiR Rdt exitpriorityi(RCtgetattrt_sockett setsockoptt SOL_SOCKETt SO_REUSEADDRRERFtbindtlistent getsocknameR7terrorR 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˜t d|ƒ‚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®Gáz„?(R%RCRoRERFRtconnectRwRdterrnot ECONNREFUSEDRRRtsleepR 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 ƒ}|j j |ƒ|j j 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*R2R3t staticmethodR„(((s0/sys/lib/python2.7/multiprocessing/connection.pyR'?s  cCsÈtƒ}x–yHtj|dƒtj|tjtjBdtjtjdtjƒ}WnDtk rš}|j dtj tj fks‘t |ƒrœ‚qœq XPq ‚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 ƒ}|j dƒ}||kr„|jt ƒn|jt ƒtdƒ‚dS(Niÿÿÿÿisdigest received was wrong(thmacR+R,tAssertionErrorRturandomtMESSAGE_LENGTHt send_bytest CHALLENGEtnewtdigestt recv_bytestWELCOMEtFAILURER(t connectionR1RtmessageR—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µt dƒ‚ndS(Niÿÿÿÿis message = %rsdigest sent was rejected( RR+R,R‘R˜tlenR•R–R—R”R™R(R›R1RRœ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!t XmlListenercBseZd„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#s`        "      , *' 1