7ec@sddddddgZddlZddlZddlZddlmZmZddlZdd l m Z dd l m Z m Z mZdd lmZmZydd lmZWn)ek red dddnXed\ZZejjZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdS(tLocktRLockt SemaphoretBoundedSemaphoret ConditiontEventiN(ttimetsleep(tcurrent_process(tFinalizetregister_after_forktdebug(tassert_spawningtPopen(tSemLocks*This platform lacks a functioning sem_opens( implementation, therefore, the requireds+ synchronization primitives needed will nots function, see issue 3770.iRcBs>eZdZdZdZdZdZdZRS(cCsctj|||}|_td|j|jtjdkr_d}t||ndS(Nscreated semlock with handle %stwin32cSs|jjdS(N(t_semlockt _after_fork(tobj((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyRPs( t_multiprocessingRRR thandlet _make_methodstsystplatformR (tselftkindtvaluetmaxvaluetslR((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyt__init__Js   cCs"|jj|_|jj|_dS(N(Rtacquiretrelease(R((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyRTscCs |jjS(N(Rt __enter__(R((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyR XscGs|jj|S(N(Rt__exit__(Rtargs((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyR![scCs2t||j}tj|j|j|jfS(N(R RR tduplicate_for_childRRR(RR((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyt __getstate__^s  cCs5tjj||_td|d|jdS(Ns recreated blocker with handle %ri(RRt_rebuildRR R(Rtstate((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyt __setstate__cs(t__name__t __module__RRR R!R$R'(((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyRHs     cBs&eZddZdZdZRS(icCstj|t|tdS(N(RRt SEMAPHOREt SEM_VALUE_MAX(RR((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyRnscCs |jjS(N(Rt _get_value(R((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyt get_valueqscCs5y|jj}Wntk r,d}nXd|S(Ntunknowns(RR,t Exception(RR((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyt__repr__ts   (R(R)RR-R0(((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyRls  cBseZddZdZRS(icCstj|t||dS(N(RRR*(RR((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyRscCsAy|jj}Wntk r,d}nXd||jjfS(NR.s)(RR,R/R(RR((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyR0s   (R(R)RR0(((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyRs cBseZdZdZRS(cCstj|tdddS(Ni(RRR*(R((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyRscCsy|jjrPtj}tjjdkr|dtjj7}qnB|jjdkrnd}n$|jjdkrd}nd}Wntk rd}nXd |S( Nt MainThreadt|itNoneitSomeOtherThreadtSomeOtherProcessR.s( Rt_is_mineRtnamet threadingtcurrent_threadR,t_countR/(RR7((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyR0s      (R(R)RR0(((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyRs cBseZdZdZRS(cCstj|tdddS(Ni(RRtRECURSIVE_MUTEX(R((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyRscCsy|jjr_tj}tjjdkrM|dtjj7}n|jj}nT|jjdkrd \}}n0|jjdkrd \}}n d \}}Wntk rd\}}nXd ||fS(NR1R2iR3iR4tnonzeroR5R.s(R3i(R4R<(R5R<(R.R.( RR6RR7R8R9R:R,R/(RR7tcount((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyR0s  (R(R)RR0(((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyRs cBsheZd dZdZdZdZdZdZdZ d dZ dZ d Z RS( cCsM|p t|_td|_td|_td|_|jdS(Ni(Rt_lockRt_sleeping_countt _woken_countt_wait_semaphoreR(Rtlock((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyRs cCs&t||j|j|j|jfS(N(R R>R?R@RA(R((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyR$s  cCs,|\|_|_|_|_|jdS(N(R>R?R@RAR(RR&((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyR'scCs |jjS(N(R>R (R((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyR scGs|jj|S(N(R>R!(RR"((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyR!scCs"|jj|_|jj|_dS(N(R>RR(R((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyRscCsQy&|jjj|jjj}Wntk r?d}nXd|j|fS(NR.s(R?RR,R@R/R>(Rt num_waiters((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyR0s   cCs|jjjstd|jj|jjj}x!t|D]}|jjqJWz|jj t |Wd|j jx!t|D]}|jj qWXdS(Ns,must acquire() condition before using wait()( R>RR6tAssertionErrorR?RR:txrangeRARtTrueR@(RttimeoutR=ti((s3/usr/lib64/python2.7/multiprocessing/synchronize.pytwaits   cCs|jjjstd|jjt s7tx4|jjtrm|jjt}|s:tq:W|jjtr|jj |jj|jjtndS(Nslock is not owned( R>RR6RDRARtFalseR@R?R(Rtres((s3/usr/lib64/python2.7/multiprocessing/synchronize.pytnotifys  cCs|jjjstd|jjt s7tx4|jjtrm|jjt}|s:tq:Wd}x-|jjtr|jj |d7}qwW|rx!t |D]}|jjqWx|jjtrqWndS(Nslock is not ownedii( R>RR6RDRARRJR@R?RRE(RRKtsleepersRH((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyt notify_alls N( R(R)R3RR$R'R R!RR0RIRLRN(((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyRs         cBs8eZdZdZdZdZddZRS(cCs%tt|_td|_dS(Ni(RRt_condRt_flag(R((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyR-scCsM|jjz+|jjtr3|jjtStSWd|jjXdS(N(RORRPRJRRF(R((s3/usr/lib64/python2.7/multiprocessing/synchronize.pytis_set1s  cCsP|jjz.|jjt|jj|jjWd|jjXdS(N(RORRPRJRRN(R((s3/usr/lib64/python2.7/multiprocessing/synchronize.pytset;s   cCs6|jjz|jjtWd|jjXdS(N(RORRPRJR(R((s3/usr/lib64/python2.7/multiprocessing/synchronize.pytclearDs cCs|jjz]|jjtr2|jjn|jj||jjtre|jjtStSWd|jjXdS(N(RORRPRJRRIRF(RRG((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyRIKs  N(R(R)RRQRRRSR3RI(((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyR+s   (t__all__R8tosRRt_timeRt_sleepRtmultiprocessing.processRtmultiprocessing.utilR R R tmultiprocessing.forkingR R Rt ImportErrortrangeR;R*R+tobjectRRRRRR(((s3/usr/lib64/python2.7/multiprocessing/synchronize.pyt$s.       $h