rfc@sddddgZddlZddlZddlZddlZddlZddlZddlmZddl m Z m Z m Z m Z mZmZddlmZdd lmZmZmZmZdd lmZmZydd lmZWn!ek rdd lmZnXd Zejejegd ddfD]Z e!e"ie ^qDZ#de$fdYZ%fidZ&dZ'de(fdYZ)dZ*dZ+de$fdYZ,de$fdYZ-iej.ej/fd6ej0ej1fd6Z2de$fdYZ3de4fdYZ5de$fd YZ6d!Z7id"Z8e9e9e9e:d#Z;d$e$fd%YZ<d&e$fd'YZ=e:d(Z>d)e6fd*YZ?d+e6fd,YZ@d-e@fd.YZAd/e6fd0YZBd1e6fd2YZCd3e6fd4YZDe8d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKfZEdLeEfdMYZFe8dNd7d8d:d<d@dOdPdQdRd ddGdSdTdUdfZGe8dVd<d:d@d;dAfZHe8dWdXdYdZd[d\d]d^d_d`f ZIidadY6dad_6dbd[6dbd\6eI_Jde3fdcYZKeKjddejeKjdeejeKjdfejLeBeKjdgejMe@eKjdhejNe@eKjdiejOe@eKjdjejPe@eKjdkejQeAeKjdle eIeKjdmeReFeKjdneSeGeKjd&e=eDeKjdoe>eHeKjd$e<eCeKjdbdpe?dqeTeKjdadqeTdS(rt BaseManagert SyncManagert BaseProxytTokeniN(t format_exc(tProcesstcurrent_processtactive_childrentPooltutilt connection(tAuthenticationString(texittPopentassert_spawningtForkingPickler(tFinalizetinfo(t PicklingErrorcCstj|j|jffS(N(tarrayttypecodettostring(ta((s0/usr/lib64/python2.7/multiprocessing/managers.pyt reduce_array@stitemstkeystvaluescBs8eZdZdZdZdZdZdZRS( s4 Type to uniquely indentify a shared object ttypeidtaddresstidcCs!||||_|_|_dS(N(RRR(tselfRRR((s0/usr/lib64/python2.7/multiprocessing/managers.pyt__init__PscCs|j|j|jfS(N(RRR(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyt __getstate__SscCs|\|_|_|_dS(N(RRR(Rtstate((s0/usr/lib64/python2.7/multiprocessing/managers.pyt __setstate__VscCsd|j|j|jfS(Ns#Token(typeid=%r, address=%r, id=%r)(RRR(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyt__repr__Ys(stypeidsaddresssid(t__name__t __module__t__doc__t __slots__RR R"R#(((s0/usr/lib64/python2.7/multiprocessing/managers.pyRJs    cCsN|j||||f|j\}}|dkr;|St||dS(sL Send a message to manager using connection `c` and return response s#RETURNN(tsendtrecvtconvert_to_error(tcRt methodnametargstkwdstkindtresult((s0/usr/lib64/python2.7/multiprocessing/managers.pytdispatchas  cCs~|dkr|S|dkr>t|tks4tt|S|dkrpt|tksbttd|StdSdS(Ns#ERRORs #TRACEBACKs#UNSERIALIZABLEsUnserializable message: %s sUnrecognized message type(ttypetstrtAssertionErrort RemoteErrort ValueError(R/R0((s0/usr/lib64/python2.7/multiprocessing/managers.pyR*ks    R5cBseZdZRS(cCs)ddddt|jdddS(Ns t-iKi(R3R-(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyt__str__xs(R$R%R8(((s0/usr/lib64/python2.7/multiprocessing/managers.pyR5wscCsOg}xBt|D]4}t||}t|dr|j|qqW|S(s4 Return a list of names of methods of `obj` t__call__(tdirtgetattrthasattrtappend(tobjttemptnametfunc((s0/usr/lib64/python2.7/multiprocessing/managers.pyt all_methodss cCs-gt|D]}|ddkr |^q S(sP Return a list of names of methods of `obj` which do not start with '_' it_(RB(R>R@((s0/usr/lib64/python2.7/multiprocessing/managers.pytpublic_methodsstServerc BseZdZddddddddd g Zd Zd Zd Zd ZdZdZ dZ ie d6e d6ed6Z dZ dZ dZdZdZdZdZdZdZRS(sM Server class which runs in a process controlled by a manager object tshutdowntcreatetaccept_connectiont get_methodst debug_infotnumber_of_objectstdummytincreftdecrefcCst|tst||_t||_t|\}}|d|dd|_|jj|_iddfd6|_ i|_ t j |_d|_dS(NRtbacklogit0i((t isinstancetbytesR4tregistryR tauthkeytlistener_clienttlistenerRtNonet id_to_objtid_to_refcountt threadingtRLocktmutextstop(RRSRRTt serializertListenertClient((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs  cCs|t_zykxdy|jj}Wnttfk rDqnXtjd|jd|f}t |_ |j qWnt t fk rnXWdd|_|jjXdS(s( Run the server forever ttargetR-Ni(Rt_manager_serverRVtaccepttOSErrortIOErrorRZtThreadthandle_requesttTruetdaemontstarttKeyboardInterruptt SystemExitR]tclose(RR+tt((s0/usr/lib64/python2.7/multiprocessing/managers.pyt serve_forevers   c Csd}}}yvtj||jtj||j|j}|\}}}}||jksttd|t||}Wn t k rdt f} nFXy||||}Wn t k rdt f} n Xd|f} y|j | Wnqt k rp} y|j dt fWnt k r<nXt j d| t j d|t j d| nX|jdS(s) Handle a new connection s%r unrecognizeds #TRACEBACKs#RETURNsFailure to send message: %rs ... request was %rs ... exception was %rN(RWR tdeliver_challengeRTtanswer_challengeR)tpublicR4R;t ExceptionRR(R RRm( RR+tfuncnameR0trequesttignoreR-R.RAtmsgte((s0/usr/lib64/python2.7/multiprocessing/managers.pyRgs4     cCstjdtjj|j}|j}|j}x|jsyd}}|}|\}}} } ||\}} } || krt d|t || fnt ||} y| | | }Wnt k r}d|f}npX| o| j|d}|rP|j|||\}}t||j|}d||ff}n d|f}Wnt k r|dkrdtf}q?y8|j|}|||||| | }d|f}Wq?t k rdtf}q?XnVtk rtjdtjjtjdn t k r>dtf}nXy>y||Wn)t k r{}|d t|fnXWq7t k r}tjd tjjtjd |tjd ||jtjd q7Xq7WdS(sQ Handle requests from the proxies in a particular process/thread s$starting server thread to service %rs+method %r of %r object is not in exposed=%rs#ERRORs#PROXYs#RETURNs #TRACEBACKs$got EOF -- exiting thread serving %ris#UNSERIALIZABLEsexception in thread serving %rs ... message was %rs ... exception was %riN(R tdebugRZtcurrent_threadR@R)R(RXR]RWtAttributeErrorR2R;RstgetRGRRRtfallback_mappingtEOFErrortsysR treprRRm(RtconnR)R(RXR,R>RutidentR-R.texposedt gettypeidtfunctiontresRxRwRtridenttrexposedttokent fallback_funcR0((s0/usr/lib64/python2.7/multiprocessing/managers.pyt serve_clientsl                 cCs|S(N((RRRR>((s0/usr/lib64/python2.7/multiprocessing/managers.pytfallback_getvalue+scCs t|S(N(R3(RRRR>((s0/usr/lib64/python2.7/multiprocessing/managers.pyt fallback_str.scCs t|S(N(R(RRRR>((s0/usr/lib64/python2.7/multiprocessing/managers.pyt fallback_repr1sR8R#s #GETVALUEcCsdS(N((RR+((s0/usr/lib64/python2.7/multiprocessing/managers.pyRL:scCs|jjzg}|jj}|jxS|D]K}|dkr6|jd||j|t|j|dd fq6q6Wdj|SWd|jj XdS(sO Return some info --- useful to spot problems with refcounting RPs %s: refcount=%s %siiKs N( R\tacquireRXRtsortR=RYR3tjointrelease(RR+R0RR((s0/usr/lib64/python2.7/multiprocessing/managers.pyRJ=s      'cCst|jdS(s* Number of shared objects i(tlenRX(RR+((s0/usr/lib64/python2.7/multiprocessing/managers.pyRKOscCszytjd|jd tjtjkrZtjdtjt_tjt_ntj dx(t D]}tjd|j qqWx(t D]}tjd|j qWtj tj dWnddl}|jnXWdtdXdS( s' Shutdown this process s!manager received shutdown messages#RETURNsresetting stdout, stderris&terminating a child process of managersmanager exiting with exitcode 0iN(s#RETURNN(R RyR(RWRtstdoutt __stdout__t __stderr__tstderrt_run_finalizersRt terminateRRt tracebackt print_excR (RR+tpR((s0/usr/lib64/python2.7/multiprocessing/managers.pyRFUs*         c Os\|jjz:|j|\}}}}|dkrat|dkrN| sTt|d} n|||} |dkrt| }n|dk rt|tkstt |t |}ndt | } t j d|| | t ||f|j| <| |jkr&d|j| Create a new shared object and return its id iis%xs&%r callable returned object with id %rN(R\RRSRWRR4RDR2tdicttlistRR RytsetRXRYRMttupleR( RR+RR-R.tcallableRtmethod_to_typeidt proxytypeR>R((s0/usr/lib64/python2.7/multiprocessing/managers.pyRGus(     cCst|j|jdS(sL Return the methods of the shared object indicated by token i(RRXR(RR+R((s0/usr/lib64/python2.7/multiprocessing/managers.pyRIscCs-|tj_|jd|j|dS(s= Spawn a new thread to serve this connection s#RETURNN(s#RETURNN(RZRzR@R(RWR(RR+R@((s0/usr/lib64/python2.7/multiprocessing/managers.pyRHs cCs9|jjz|j|cd7 Connect manager object to the server process RTRLN( RURRRR1RWRRRR(RR_R`R((s0/usr/lib64/python2.7/multiprocessing/managers.pytconnectsc Csg|jjtjkst|d k rFt|d rFtdntj dt \}}t dt |j d|j|j|j|j|||f|_djd|jjD}t |jd||j_|jj|j|j|_|jtj|j_tj|t |jd|j|j|j|j|jfd d |_d S( s@ Spawn a server process for this manager object R9sinitializer must be a callabletduplexRaR-t:css|]}t|VqdS(N(R3(t.0ti((s0/usr/lib64/python2.7/multiprocessing/managers.pys sR7t exitpriorityiN( RRRRR4RWR<t TypeErrorR tPipetFalseRR2t _run_serverRRRRt_processRt _identityR$R@RjRmR)RR Rt_finalize_managerRRF(Rt initializertinitargstreadertwriterR((s0/usr/lib64/python2.7/multiprocessing/managers.pyRjs(   c Csl|dk r||n|j||||}|j|j|jtjd|j|jdS(s@ Create a server, report its address and run it smanager serving at %rN(RWt_ServerR(RRmR RRo( tclsRSRRTR^RRRtserver((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs   cOs|jjtjks!td|j|jd|j}z)t|dd|f||\}}Wd|j Xt ||j||fS(sP Create a new shared object; return the token and exposed tuple sserver not yet startedRTRGN( RRRRR4RRRR1RWRmR(RRR-R.RRR((s0/usr/lib64/python2.7/multiprocessing/managers.pyt_create0s !) cCs|jj|dS(sC Join the manager process (if it has been spawned) N(RR(Rttimeout((s0/usr/lib64/python2.7/multiprocessing/managers.pyR<scCsA|j|jd|j}zt|ddSWd|jXdS(sS Return some info about the servers shared objects and connections RTRJN(RRRR1RWRm(RR((s0/usr/lib64/python2.7/multiprocessing/managers.pyt _debug_infoBscCsA|j|jd|j}zt|ddSWd|jXdS(s5 Return the number of shared objects RTRKN(RRRR1RWRm(RR((s0/usr/lib64/python2.7/multiprocessing/managers.pyt_number_of_objectsLscCs|S(N((R((s0/usr/lib64/python2.7/multiprocessing/managers.pyt __enter__VscCs|jdS(N(RF(Rtexc_typetexc_valtexc_tb((s0/usr/lib64/python2.7/multiprocessing/managers.pyt__exit__YscCs|jrtjdy8||d|}zt|ddWd|jXWntk rdnX|jdd|jrtjdt|drtjd |j |jdd |jrtjd qqqnt j |_ yt j|=Wntk rnXdS( sQ Shutdown the manager process; will be registered as a finalizer s#sending shutdown message to managerRTRFNRg?smanager still aliveRs'trying to `terminate()` manager processg?s#manager still alive after terminate(tis_aliveR RR1RWRmRsRR<RRRRRt_address_to_localtKeyError(tprocessRRTR!RR((s0/usr/lib64/python2.7/multiprocessing/managers.pyR\s.          cCs|jS(N(R(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyt|sc s$d|jkr$|jj|_ndkr9tn|pNtdd}|pftdd}|rxa|jD]P\}}t|tkst d|t|tks|t d|q|Wn|||f|j<|r fd} | _ t || ndS(s9 Register a typeid with the manager type Rt _exposed_t_method_to_typeid_s%r is not a stringc stjd|j||\}}||jd|d|jd|}|j|jd|j}t|dd|j f|S(Ns)requesting creation of a shared %r objecttmanagerRTRRN( R RyRRRRRR1RWR(RR-R.RtexptproxyR(RR(s0/usr/lib64/python2.7/multiprocessing/managers.pyR?sN( t__dict__RtcopyRWt AutoProxyR;RR2R3R4R$tsetattr( RRRRRRt create_methodtkeyRR?((RRs0/usr/lib64/python2.7/multiprocessing/managers.pytregister~s   ") N(((R$R%R&RRERRWRRRRRjt classmethodRRRRRRRt staticmethodRtpropertyRRhR(((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs*   $     tProcessLocalSetcBseZdZdZRS(cCstj|ddS(NcSs |jS(N(tclear(R>((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs(R tregister_after_fork(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyRscCst|dfS(N((R2(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs(R$R%RR(((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs cBseZdZiZejZd d d edZ dZ d idZ dZ dZ edZdZdZd Zd Zd ZRS(s. A base for proxies of shared objects cCs;tjjzPtjj|jd}|dkr\tjt f}|tj|js  cCs |jS(N(R(Rtmemo((s0/usr/lib64/python2.7/multiprocessing/managers.pyt __deepcopy__KscCs*dt|j|jjdt|fS(Ns<%s object, typeid %r at %s>s0x%x(R2R$RRR(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyR#NscCs8y|jdSWn tk r3t|d dSXdS(sV Return representation of the referent (or a fall-back if that fails) R#is; '__str__()' failed>N(RRsR(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyR8Rs N((R$R%R&RR tForkAwareThreadLockRRWRhRRRRRRRRRRR#R8(((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs %      cCsttdd}|r?|j|jkr?|j|jdS|jdtodttdt }|||d||SdS(s Function used for unpickling proxy objects. If possible the shared object is returned, or otherwise a proxy for it. RbiRMt _inheritingN( R;RRWRRXRtpopRhR(RARR^R.RRM((s0/usr/lib64/python2.7/multiprocessing/managers.pyR_s cBse|}y|||fSWnek r1nXi}x |D]}d||f|Uq?We|ef|}||_||||f<|S(sC Return an proxy type whose methods are given by `exposed` sLdef %s(self, *args, **kwds): return self._callmethod(%r, args, kwds)(RRR2RR(R@Rt_cachetdictmetht ProxyType((s0/usr/lib64/python2.7/multiprocessing/managers.pyt MakeProxyTypets    c Cst|d}|dkr\||jd|}zt|dd|f}Wd|jXn|dkr|dk r|j}n|dkrtj}ntd|j |}|||d|d|d|} t | _ | S(s* Return an auto-proxy for `token` iRTRINs AutoProxy[%s]RRM( RURWRR1RmRRRTR RRhR( RR^RRTRRMRRR R((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs     t NamespacecBseZdZdZRS(cKs|jj|dS(N(Rtupdate(RR.((s0/usr/lib64/python2.7/multiprocessing/managers.pyRscCss|jj}g}x=|D]5\}}|jds|jd||fqqW|jdtjd|S(NRCs%s=%rs Namespace(%s)s, (RRt startswithR=RR3R(RRR?R@R((s0/usr/lib64/python2.7/multiprocessing/managers.pyR#s (R$R%RR#(((s0/usr/lib64/python2.7/multiprocessing/managers.pyR s tValuecBs>eZedZdZdZdZeeeZRS(cCs||_||_dS(N(t _typecodet_value(RRRtlock((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs cCs|jS(N(R(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyR|scCs ||_dS(N(R(RR((s0/usr/lib64/python2.7/multiprocessing/managers.pyRscCs dt|j|j|jfS(Ns %s(%r, %r)(R2R$RR(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyR#s( R$R%RhRR|RR#RR(((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs     cCstj||S(N(R(RtsequenceR((s0/usr/lib64/python2.7/multiprocessing/managers.pytArrayst IteratorProxycBsDeZd ZdZdZdZdZd Zd ZRS( t__next__tnextR(tthrowRmcCs|S(N((R((s0/usr/lib64/python2.7/multiprocessing/managers.pyt__iter__scGs|jd|S(NR(R(RR-((s0/usr/lib64/python2.7/multiprocessing/managers.pyRscGs|jd|S(NR(R(RR-((s0/usr/lib64/python2.7/multiprocessing/managers.pyRscGs|jd|S(NR((R(RR-((s0/usr/lib64/python2.7/multiprocessing/managers.pyR(scGs|jd|S(NR(R(RR-((s0/usr/lib64/python2.7/multiprocessing/managers.pyRscGs|jd|S(NRm(R(RR-((s0/usr/lib64/python2.7/multiprocessing/managers.pyRms(s__next__snextssendsthrowsclose( R$R%RRRRR(RRm(((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs     t AcquirerProxycBs5eZdZedZdZdZdZRS(RRcCs|jd|fS(NR(R(Rtblocking((s0/usr/lib64/python2.7/multiprocessing/managers.pyRscCs |jdS(NR(R(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyRscCs |jdS(NR(R(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyRscCs |jdS(NR(R(RRRR((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs(sacquiresrelease(R$R%RRhRRRR(((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs    tConditionProxycBs,eZdZd dZdZdZRS( RRtwaittnotifyt notify_allcCs|jd|fS(NR(R(RR((s0/usr/lib64/python2.7/multiprocessing/managers.pyRscCs |jdS(NR(R(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyRscCs |jdS(NR(R(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs(sacquiresreleaseswaitsnotifys notify_allN(R$R%RRWRRR(((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs  t EventProxycBs5eZdZdZdZdZd dZRS( tis_setRRRcCs |jdS(NR (R(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyR scCs |jdS(NR(R(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyRscCs |jdS(NR(R(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyRscCs|jd|fS(NR(R(RR((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs(sis_setssetsclearswaitN(R$R%RR RRRWR(((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs    tNamespaceProxycBs)eZdZdZdZdZRS(t__getattribute__t __setattr__t __delattr__cCsB|ddkr tj||Stj|d}|d|fS(NiRCRR"(tobjectR"(RRt callmethod((s0/usr/lib64/python2.7/multiprocessing/managers.pyt __getattr__scCsH|ddkr#tj|||Stj|d}|d||fS(NiRCRR#(R%R#R"(RRRR&((s0/usr/lib64/python2.7/multiprocessing/managers.pyR#scCsB|ddkr tj||Stj|d}|d|fS(NiRCRR$(R%R$R"(RRR&((s0/usr/lib64/python2.7/multiprocessing/managers.pyR$s(s__getattribute__s __setattr__s __delattr__(R$R%RR'R#R$(((s0/usr/lib64/python2.7/multiprocessing/managers.pyR!s  t ValueProxycBs/eZdZdZdZeeeZRS(R|RcCs |jdS(NR|(R(R((s0/usr/lib64/python2.7/multiprocessing/managers.pyR| scCs|jd|fS(NR(R(RR((s0/usr/lib64/python2.7/multiprocessing/managers.pyRs(sgetsset(R$R%RR|RRR(((s0/usr/lib64/python2.7/multiprocessing/managers.pyR( s  t BaseListProxyt__add__t __contains__t __delitem__t __delslice__t __getitem__t __getslice__t__len__t__mul__t __reversed__t__rmul__t __setitem__t __setslice__R=tcounttextendtindextinsertRtremovetreverseRt__imul__t ListProxycBseZdZdZRS(cCs|jd|f|S(NR7(R(RR((s0/usr/lib64/python2.7/multiprocessing/managers.pyt__iadd__scCs|jd|f|S(NR<(R(RR((s0/usr/lib64/python2.7/multiprocessing/managers.pyR<s(R$R%R>R<(((s0/usr/lib64/python2.7/multiprocessing/managers.pyR=s t DictProxyRRR|thas_keytpopitemt setdefaultR t ArrayProxyt PoolProxytapplyt apply_asyncRmtimaptimap_unorderedRtmapt map_asyncRt AsyncResulttIteratorcBseZdZRS(s( Subclass of `BaseManager` which supports a number of shared object types. The types registered are those intended for the synchronization of threads, plus `dict`, `list` and `Namespace`. The `multiprocessing.Manager()` function creates started instances of this class. (R$R%R&(((s0/usr/lib64/python2.7/multiprocessing/managers.pyR?s tQueuet JoinableQueuetEventtLockR[t SemaphoretBoundedSemaphoret ConditionRRRRRR(Ut__all__tosRtweakrefRZRRMRRtmultiprocessingRRRRR R tmultiprocessing.processR tmultiprocessing.forkingR R RRtmultiprocessing.utilRRtcPickleRt ImportErrorRRRR@R2R;t view_typesR%RR1R*RsR5RBRDRERR_R`t XmlListenert XmlClientRURRRRRR RWRhRR RRRRRRR!R(R)R=R?RCRDRRRORPR[RQRRRSRRR(((s0/usr/lib64/python2.7/multiprocessing/managers.pyt$s      ."  4  ,