ó õùPc@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((s+..\python\lib\multiprocessing\connection.pyt _init_timeout/scCstjƒ|kS(N(R(tt((s+..\python\lib\multiprocessing\connection.pyt_check_timeout2scCsw|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((s+..\python\lib\multiprocessing\connection.pytarbitrary_address9s    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((s+..\python\lib\multiprocessing\connection.pyt address_typeHs!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((s+..\python\lib\multiprocessing\connection.pyt__init__bs  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((s+..\python\lib\multiprocessing\connection.pyR3qs  cCs |jjƒS(sA Close the bound socket or named pipe of `self`. (R(R (R/((s+..\python\lib\multiprocessing\connection.pyR }scCs |jjS(N(R(t_address(R/((s+..\python\lib\multiprocessing\connection.pytƒscCs |jjS(N(R(t_last_accepted(R/((s+..\python\lib\multiprocessing\connection.pyR8„sN( t__name__t __module__t__doc__R*R2R3R tpropertyR$t last_accepted(((s+..\python\lib\multiprocessing\connection.pyR[s  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((s+..\python\lib\multiprocessing\connection.pyR‡s     cCs±|rktjƒ\}}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_multiprocessingt ConnectionRtduptfilenoR tpipetFalse(tduplexts1ts2tc1tc2tfd1tfd2((s+..\python\lib\multiprocessing\connection.pyRs  (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_CONNECTEDREtPipeConnection( RKR$topenmodetaccesstobsizetibsizeth1th2teRNRO((s+..\python\lib\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|ƒƒ|_|jjtjtjdƒ|jj|ƒ|jj|ƒ|jjƒ|_ ||_ d|_ |dkr®t |tjd|fddƒ|_n d|_dS(NiR Rbt exitpriorityi(RCtgetattrt_sockett setsockoptt SOL_SOCKETt SO_REUSEADDRtbindtlistent getsocknameR7t_familyR*R9RRtunlinkt_unlink(R/R$RR0((s+..\python\lib\multiprocessing\connection.pyR2às   $cCsG|jjƒ\}|_t|jƒƒ}tj|ƒ}|jƒ|S(N(RnR3R9R RHRERFR (R/tstfdtconn((s+..\python\lib\multiprocessing\connection.pyR3ðs  cCs-|jjƒ|jdk r)|jƒndS(N(RnR RwR*(R/((s+..\python\lib\multiprocessing\connection.pyR ÷s (R:R;R<R2R3R (((s+..\python\lib\multiprocessing\connection.pyR)Üs  cCsÒt|ƒ}tjtt|ƒƒ}tƒ}xsy|j|ƒWnXtjk r›}|jdtjksxt |ƒr‹t d|ƒ‚nt j dƒq0XPq0‚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„?(R%RCRmRtconnectterrorRbterrnot ECONNREFUSEDRRRtsleepR RHRERFR (R$RRxRRkRyRz((s+..\python\lib\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=%rRbRli(R7R RWRRRXRYRZtPIPE_UNLIMITED_INSTANCESRUR[R\t _handle_queueR*R9RRR't_finalize_pipe_listenerR (R/R$R0thandle((s+..\python\lib\multiprocessing\connection.pyR2!s       c Cs¼tj|jtjtjtjBtjBtjtttj tj ƒ}|j j |ƒ|j j dƒ}ytj|tj ƒWn/tk r®}|jdtjkr¯‚q¯nXtj|ƒS(Ni(R RWR7RRRXRYRZR€RUR[R\RtappendtpopR`RaRbRcRERd(R/t newhandleRƒRk((s+..\python\lib\multiprocessing\connection.pyR34s    cCs,td|ƒx|D]}t|ƒqWdS(Ns closing listener with address=%r(RR (tqueueR$Rƒ((s+..\python\lib\multiprocessing\connection.pyR‚Es  N(R:R;R<R*R2R3t staticmethodR‚(((s+..\python\lib\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]RSRTR\R^RaRbtERROR_SEM_TIMEOUTtERROR_PIPE_BUSYRR_RYR*RERd(R$RthRk((s+..\python\lib\multiprocessing\connection.pyR?Ks  " 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((s+..\python\lib\multiprocessing\connection.pyR4os   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š((s+..\python\lib\multiprocessing\connection.pyR5|s &  tConnectionWrappercBs#eZd„Zd„Zd„ZRS(cCsO||_||_||_x-dD]%}t||ƒ}t|||ƒq"WdS(NRHR tpollR•R‘(sfilenoscloseRs recv_bytess send_bytes(t_connt_dumpst_loadsRmtsetattr(R/Rztdumpstloadstattrtobj((s+..\python\lib\multiprocessing\connection.pyR2s     cCs#|j|ƒ}|jj|ƒdS(N(RŸRžR‘(R/R¥Rx((s+..\python\lib\multiprocessing\connection.pytsend”scCs|jjƒ}|j|ƒS(N(RžR•R (R/Rx((s+..\python\lib\multiprocessing\connection.pytrecv—s(R:R;R2R¦R§(((s+..\python\lib\multiprocessing\connection.pyRœŒs  cCs%tj|fddddƒjdƒS(Nitutf8(t xmlrpclibR¢R*tencode(R¥((s+..\python\lib\multiprocessing\connection.pyt _xml_dumps›scCs%tj|jdƒƒ\\}}|S(NR¨(R©R£tdecode(RxR¥tmethod((s+..\python\lib\multiprocessing\connection.pyt _xml_loadsžs!t XmlListenercBseZd„ZRS(cCs+ddlatj|ƒ}t|ttƒS(Niÿÿÿÿ(R©RR3RœR«R®(R/R¥((s+..\python\lib\multiprocessing\connection.pyR3£s (R:R;R3(((s+..\python\lib\multiprocessing\connection.pyR¯¢scOs%ddlatt||ŽttƒS(Niÿÿÿÿ(R©RœRR«R®(Rbtkwds((s+..\python\lib\multiprocessing\connection.pyt XmlClient©s (6t__all__RtsysRCR}RRt itertoolsREtmultiprocessingRRtmultiprocessing.utilRRRRtmultiprocessing.forkingR R RUtCONNECTION_TIMEOUTtcountRR&tfamiliesthasattrtplatformRRRR%tobjectRR*RtTrueRR R)R@R'R?RR’R–R—R4R5RœR«R®R¯R±(((s+..\python\lib\multiprocessing\connection.pyt s`        "      , *! .