mς %U²Ic@sͺdZdkZy dkZWn ej oeie=‚nXdklZl Z dk l Z dklZddddd d d d d dddddgZeiZeiZeiZeiZ[eZdefd„ƒYZdadad„Z d„Z!eZ"d„Z#defd„ƒYZ$d„Z%defd„ƒYZ&d„Z'defd„ƒYZ(d „Z)d!e(fd"„ƒYZ*d#„Z+d$efd%„ƒYZ,d&a-d'd(„Z.eƒZ/hZ0hZ1defd)„ƒYZ2d*„Z3d+e2fd,„ƒYZ4d-e2fd.„ƒYZ5d/„Z6d0e2fd1„ƒYZ7d2„Z8d3„Z9d4„Z:e5ƒyd5kl;Z<Wn ej od6k=l<Z<nXd7„Z>ed8jo e>ƒndS(9s;Thread module emulating a subset of Java's threading model.N(stimessleep(s format_exc(sdequet activeCountt Conditiont currentThreadt enumeratetEventtLocktRLockt SemaphoretBoundedSemaphoretThreadtTimert setprofiletsettracetlocalt_VerbosecBstZdd„Zd„ZRS(NcCsdS(N((tselftverbose((t&/data/zmath/lib/python2.4/threading.pyt__init__6scGsdS(N((Rtargs((Rt_note8s(t__name__t __module__tNoneRR(((RR5s cCs |adS(N(tfunct _profile_hook(R((RR @scCs |adS(N(Rt _trace_hook(R((RR DscOs t||ŽS(N(t_RLockRtkwargs(RR((RRLsRcBsMtZdd„Zd„Zdd„Zd„Zd„Zd„Zd„Z RS( NcCs2ti||ƒtƒ|_d|_d|_dS(Ni( RRRRt_allocate_lockt _RLock__blockRt _RLock__ownert _RLock__count(RR((RRQs  cCs-d|ii|io |iiƒ|ifS(Ns <%s(%s, %d)>(Rt __class__RRtgetNameR (R((Rt__repr__WsicCsdtƒ}|i|jo|id|_dSn|ii|ƒ}|o||_d|_n|S(Ni( RtmeRRR Rtacquiretblockingtrc(RR&R$R'((RR%]s   cCsBtƒ}|id|_}|pd|_|iiƒndS(Ni( RR$RR tcountRRRtrelease(RR$R(((RR)os   cCs/|\}}|iiƒ||_||_dS(N(R(townerRRR%R R(Rt.2R(R*((Rt_acquire_restore~s   cCs;|i}d|_|i}d|_|iiƒ||fS(Ni(RR R(RR*RRR)(RR(R*((Rt _release_save…s     cCs|itƒjS(N(RRR(R((Rt _is_owneds( RRRRR#R%R)R,R-R.(((RROs      cOs t||ŽS(N(t _ConditionRR(RR((RR“sR/cBs\tZddd„Zd„Zd„Zd„Zd„Zdd„Zdd„Z d „Z RS( NcCsΚti||ƒ|djo tƒ}n||_|i|_|i |_ y|i |_ Wnt j onXy|i |_ Wnt j onXy|i |_ Wnt j onXg|_dS(N(RRRRtlockRRt_Condition__lockR%R)R-tAttributeErrorR,R.t_Condition__waiters(RR0R((RR˜s&     cCsd|it|iƒfS(Ns(RR1tlenR3(R((RR#±scCs|iiƒdS(N(RR1R)(R((RR-΄scCs|iiƒdS(N(RR1R%(Rtx((RR,·scCs0|iidƒo|iiƒtSntSdS(Ni(RR1R%R)tFalsetTrue(R((RR.Ίs cCstƒ}|iƒ|ii|ƒ|iƒ}zΠ|djo|iƒn²t ƒ|}d}xft o^|idƒ}|oPn|t ƒ}|djoPnt|d|dƒ}t|ƒqcW|p.y|ii|ƒWqώtj oqώXnWd|i|ƒXdS(Nf0.00050000000000000001iif0.050000000000000003(RtwaiterR%RR3tappendR-t saved_statettimeoutRt_timetendtimetdelayR7tgotitt remainingtmint_sleeptremovet ValueErrorR,(RR;R>R?R8R:R=R@((RtwaitΓs<         icCs’|i}|| }|pdSn|id|||djodpdƒx?|D]7}|iƒy|i|ƒWqStj oqSXqSWdS(Ns"%s.notify(): notifying %d waiter%sitst( RR3tntwaitersRR8R)RCRD(RRHR8R3RI((Rtnotifyμs   cCs|it|iƒƒdS(N(RRJR4R3(R((Rt notifyAllύs( RRRRR#R-R,R.RERJRK(((RR/–s    ) cOs t||ŽS(N(t _SemaphoreRR(RR((RRsRLcBs,tZddd„Zdd„Zd„ZRS(NicCs/ti||ƒttƒƒ|_||_dS(N( RRRRRRt_Semaphore__condtvaluet_Semaphore__value(RRNR((RRscCskt}|iiƒxD|idjo|pPn|iiƒqW|id|_t}|ii ƒ|S(Nii( R6R'RRMR%ROR&RER7R)(RR&R'((RR%s  cCs;|iiƒ|id|_|iiƒ|iiƒdS(Ni(RRMR%RORJR)(R((RR)!s   (RRRRR%R)(((RRLs cOs t||ŽS(N(t_BoundedSemaphoreRR(RR((RR+sRPcBs&tZdZded„Zd„ZRS(s6Semaphore that checks that # releases is <= # acquiresicCs ti|||ƒ||_dS(N(RLRRRNRt_initial_value(RRNR((RR0scCs-|i|ijo td‚nti|ƒS(Ns!Semaphore released too many times(RRORQRDRLR)(R((RR)4s (RRt__doc__RRR)(((RRP.s cOs t||ŽS(N(t_EventRR(RR((RR:sRScBs;tZdd„Zd„Zd„Zd„Zdd„ZRS(NcCs/ti||ƒttƒƒ|_t|_dS(N( RRRRRRt _Event__condR6t _Event__flag(RR((RRAscCs|iS(N(RRU(R((RtisSetFscCs<|iiƒzt|_|iiƒWd|iiƒXdS(N(RRTR%R7RURKR)(R((RtsetIs   cCs/|iiƒz t|_Wd|iiƒXdS(N(RRTR%R6RUR)(R((RtclearQs   cCsD|iiƒz"|ip|ii|ƒnWd|iiƒXdS(N(RRTR%RURER;R)(RR;((RREXs   (RRRRRVRWRXRE(((RRS=s     is Thread-%dcCstda|tS(Ni(t_counterttemplate(RZ((Rt_newnamebs cBsͺtZeZeiZdddfhdd„Zd„Z d„Z d„Z d„Z d„Z d„Zd„Zdd „Zd „Zd „Zd „Zd „Zd„ZRS(NcCsti||ƒ||_t|ptƒƒ|_ ||_ ||_ |iƒ|_t|_t|_ttƒƒ|_t|_ti|_dS(N(RRRRttargett_Thread__targettstrtnameR[t _Thread__nameRt _Thread__argsRt_Thread__kwargst _set_daemont_Thread__daemonicR6t_Thread__startedt_Thread__stoppedRRt_Thread__blockR7t_Thread__initializedt_syststderrt_Thread__stderr(RtgroupR\R_RRR((RRxs      cCs tƒiƒS(N(RtisDaemon(R((RRc‰scCs`d}|io d}n|io d}n|io|d}nd|ii|i|fS(Ntinitialtstartedtstoppeds daemons <%s(%s, %s)>(tstatusRReRfRdR!RR`(RRq((RR#s     cCsEtiƒ|t||ip3|tƒ}|djoPn|ii|ƒqPWWd|ii ƒXdS(Ni( RRgR%R;RRfRER<tdeadlineR>R)(RR;R>R((Rtjoins,       cCs|iS(N(RR`(R((RR".scCst|ƒ|_dS(N(R^R_RR`(RR_((RtsetName2scCs|io|i S(N(RReRf(R((RtisAlive6scCs|iS(N(RRd(R((RRm:scCs ||_dS(N(tdaemonicRRd(RR“((Rt setDaemon>s(RRR6RhRitexc_infoR}RRRcR#RvRwRuR‡RˆRR"R‘R’RmR”(((RR os     A  "     cOs t||ŽS(N(t_TimerRR(RR((RR EsR–cBs/tZdZghd„Zd„Zd„ZRS(s²Call a function after a specified number of seconds: t = Timer(30.0, f, args=[], kwargs={}) t.start() t.cancel() # stop the timer's action if it's still waiting cCsAti|ƒ||_||_||_||_tƒ|_dS(N( R RRtintervaltfunctionRRRtfinished(RR—R˜RR((RRPs      cCs|iiƒdS(s(Stop the timer if it hasn't finished yetN(RR™RW(R((RtcancelXscCsN|ii|iƒ|iiƒp|i|i|iŽn|iiƒdS(N( RR™RER—RVR˜RRRW(R((RRw\s(RRRRRRšRw(((RR–Hs  t _MainThreadcBs#tZd„Zd„Zd„ZRS(NcCsZti|ddƒt|_tiƒ|ttƒ