- >csdkTdklZdkZdkZdkZdkZdklZea dZ dZ dZ dZ dfd YZeeagad Zd Zd Zd ZdefdYZhZeZdZdefdYZdfdYZdS((s*(sStringION(sUIBasecs |adS(N(snewdirs profiledir(snewdir((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys setprofiledirscsFxt|D]}|iq Wxt|D]}|iq.WdS(s`Wait until the semaphore gets back to its original state -- all acquired resources released.N(sranges originalstatesis semaphoresacquiresrelease(s semaphores originalstatesi((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pyssemaphorereset"s  cs|i|idS(N(s semaphoresacquiresrelease(s semaphore((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys semaphorewait+s csx|D]}|iqWdS(N(s threadliststhrsjoin(s threadliststhr((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys threadsreset/ss threadlistcs5tZdZdZdZdZdZRS(Ncst|_g|_dS(N(sLocksselfslockslist(sself((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys__init__4s cs6|iiz|ii|Wd|iiXdS(N(sselfslocksacquireslistsappendsthreadsrelease(sselfsthread((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysadd8s  cs6|iiz|ii|Wd|iiXdS(N(sselfslocksacquireslistsremovesthreadsrelease(sselfsthread((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysremove?s  csL|iiz*t|i otSn|iiSWd|iiXdS(N(sselfslocksacquireslenslistsNonespopsrelease(sself((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pyspopFs cs9x2do*|i}| odSn|iqWdS(Ni(sselfspopsthreadsjoin(sselfsthread((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysresetOs  (s__name__s __module__s__init__saddsremovespopsreset(((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys threadlist3s     icsdS(s)Initialize the exit notify system. This MUST be called from the SAME THREAD that will call monitorloop BEFORE it calls monitorloop. This SHOULD be called before the main thread starts any other ExitNotifyThreads, or else it may miss the ability to catch the exit status from them!N((((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysinitexitnotify_scszxsdoktizOx tt otidqWx%tto|tidq=WWdtiXqWdS(sHEnter an infinite "monitoring" loop. The argument, callback, defines the function to call when an ExitNotifyThread has terminated. That function is called with a single argument -- the ExitNotifyThread that has terminated. The monitor will not continue to monitor for other threads until the function returns, so if it intends to perform long calculations, it should start a new thread itself -- but NOT an ExitNotifyThread, or else an infinite loop may result. Furthermore, the monitor will hold the lock all the while the other thread is waiting. iiN(s exitconditionsacquireslens exitthreadsswaitscallbackspopsrelease(scallback((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysexitnotifymonitorloopgs   csti}|idjoKt|ito tn|i|t i dt i dnI|i djo(|it i dt i dn|i|dS(sCalled when a thread exits.s EXCEPTIONidsSYNC_WITH_TIMER_TERMINATEN(sUIBases getglobaluisuisthreads getExitCauses isinstancesgetExitExceptions SystemExitsthreadExceptionssyssexitsoss_exitsgetExitMessages terminates threadExited(sthreadsui((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys threadexited}s      sExitNotifyThreadcs_tZdZdZdZdZdZdZdZdZ dZ d Z RS( sThis class is designed to alert a "monitor" to the fact that a thread has exited and to provide for the ability for it to find out why.csUti|_yt oti|nrti}y|i dt t }Wnt j onX|itdt|id|idWnW|id|itidt}tid||i|inX|idt|d  o|itntit i!|ti"ti#dS( NsThread.run(self)s/s_s.profs EXCEPTIONisfilesNORMALs exitmessage($sthreads get_identsselfsthreadids profiledirsThreadsrunsprofilesProfilesprofsrunctxsglobalsslocalss SystemExits dump_statssstrsgetNames setExitCausessetExitExceptionssyssexc_infosStringIOssbufs tracebacks print_excssetExitStackTracesgetvalueshasattrssetExitMessagesNones exitconditionsacquires exitthreadssappendsnotifysrelease(sselfssbufsprof((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysruns0 4      cs ||_dS(N(scausesselfs exitcause(sselfscause((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys setExitCausescs |iSdS(sReturns the cause of the exit, one of: 'EXCEPTION' -- the thread aborted because of an exception 'NORMAL' -- normal termination.N(sselfs exitcause(sself((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys getExitCausescs ||_dS(N(sexcsselfs exitexception(sselfsexc((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pyssetExitExceptionscs |iSdS(sdIf getExitCause() is 'EXCEPTION', holds the value from sys.exc_info()[1] for this exception.N(sselfs exitexception(sself((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysgetExitExceptionscs ||_dS(N(sstsselfsexitstacktrace(sselfsst((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pyssetExitStackTracescs |iSdS(skIf getExitCause() is 'EXCEPTION', returns a string representing the stack trace for this exception.N(sselfsexitstacktrace(sself((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysgetExitStackTracescs ||_dS(sSets the exit message to be fetched by a subsequent call to getExitMessage. This message may be any object or type except None.N(smsgsselfs exitmessage(sselfsmsg((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pyssetExitMessagescs |iSdS(sFor any exit cause, returns the message previously set by a call to setExitMessage(), or None if there was no such message set.N(sselfs exitmessage(sself((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysgetExitMessages( s__name__s __module__s__doc__sruns setExitCauses getExitCausessetExitExceptionsgetExitExceptionssetExitStackTracesgetExitStackTracessetExitMessagesgetExitMessage(((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysExitNotifyThreads         cs=titi| ot|t|/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysinitInstanceLimits  sInstanceLimitedThreadcs#tZdZdZdZRS(Ncs'||_tti|f||dS(N(s instancenamesselfsapplysExitNotifyThreads__init__sargsskwargs(sselfs instancenamesargsskwargs((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys__init__s cs"t|iiti|dS(N(sinstancelimitedsemssselfs instancenamesacquiresExitNotifyThreadsstart(sself((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysstartscs*zti|Wdt|iiXdS(N(sExitNotifyThreadsrunsselfsinstancelimitedsemss instancenamesrelease(sself((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysruns(s__name__s __module__s__init__sstartsrun(((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysInstanceLimitedThreads  s MultiLockcs#tZdZdZdZRS(Ncs%t|_t|_h|_dS(N(sLocksselfslocks statuslocks locksheld(sself((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys__init__s  csw|iizHti}||ijo|i|cd7/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysacquires  csx|iizVti}|i|djo|i|cd8/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pysreleases   (s__name__s __module__s__init__sacquiresrelease(((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys MultiLocks  (s threadingsStringIOssyss tracebacksthreadsprofilesofflineimap.uisUIBasesNones profiledirs setprofiledirssemaphoreresets semaphorewaits threadsresets threadlists ConditionsLocks exitconditions exitthreadssinitedsinitexitnotifysexitnotifymonitorloops threadexitedsThreadsExitNotifyThreadsinstancelimitedsemssinstancelimitedlocksinitInstanceLimitsInstanceLimitedThreads MultiLock(sprofilessemaphoreresets semaphorewaits threadlists MultiLockssyss setprofiledirsinitexitnotifys threadexitedsInstanceLimitedThreadsExitNotifyThreadsthreadsStringIOs tracebacks threadsresetsUIBasesexitnotifymonitorloopsinitInstanceLimitsinitedsinstancelimitedsemssinstancelimitedlock((s>/usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys?s* $    (   D