-
>c       s  d  k  Td k l Z d k Z d k Z d k Z d k Z d k l Z e a	 d   Z
 d   Z d   Z d   Z d f  d	     YZ e e    a g  a d
 Z d   Z d   Z d   Z d e f d     YZ h  Z e   Z d   Z d e f d     YZ d f  d     YZ d S(   (   s   *(   s   StringION(   s   UIBasec    s
   |  a d  S(   N(   s   newdirs
   profiledir(   s   newdir(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   setprofiledir s     c    sF   x t  |  D] } |  i   q Wx t  |  D] } |  i   q. Wd S(   s`   Wait until the semaphore gets back to its original state -- all acquired
    resources released.N(   s   ranges   originalstates   is	   semaphores   acquires   release(   s	   semaphores   originalstates   i(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   semaphorereset" s       c    s   |  i   |  i   d  S(   N(   s	   semaphores   acquires   release(   s	   semaphore(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   semaphorewait+ s    
c    s   x |  D] } | i   q Wd  S(   N(   s
   threadlists   thrs   join(   s
   threadlists   thr(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   threadsreset/ s     s
   threadlistc      s5   t  Z d   Z d   Z d   Z d   Z d   Z RS(   Nc    s   t    |  _ g  |  _ d  S(   N(   s   Locks   selfs   locks   list(   s   self(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   __init__4 s    c    s6   |  i i   z |  i i |  Wd  |  i i   Xd  S(   N(   s   selfs   locks   acquires   lists   appends   threads   release(   s   selfs   thread(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   add8 s
     c    s6   |  i i   z |  i i |  Wd  |  i i   Xd  S(   N(   s   selfs   locks   acquires   lists   removes   threads   release(   s   selfs   thread(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   remove? s
     c    sL   |  i i   z* t |  i  o t Sn |  i i   SWd  |  i i   Xd  S(   N(   s   selfs   locks   acquires   lens   lists   Nones   pops   release(   s   self(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   popF s     c    s9   x2 d o* |  i   } | o d  Sn | i   q Wd  S(   Ni   (   s   selfs   pops   threads   join(   s   selfs   thread(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   resetO s     (   s   __name__s
   __module__s   __init__s   adds   removes   pops   reset(    (    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys
   threadlist3 s
   					i    c      s   d S(   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.pys   initexitnotify_ s     c    sz   xs d ok t  i   zO x  t t  o t  i d  q Wx% t t  o |  t i d   q= WWd t  i   Xq Wd S(   sH  Enter 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.
    i   i    N(   s   exitconditions   acquires   lens   exitthreadss   waits   callbacks   pops   release(   s   callback(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   exitnotifymonitorloopg s    	   
   c    s   t  i   } |  i   d j oK t |  i   t  o
 t  n | i |   t	 i
 d  t i d  nI |  i   d j o( | i   t	 i
 d  t i d  n | i |   d S(   s   Called when a thread exits.s	   EXCEPTIONid   s   SYNC_WITH_TIMER_TERMINATEN(   s   UIBases   getglobaluis   uis   threads   getExitCauses
   isinstances   getExitExceptions
   SystemExits   threadExceptions   syss   exits   oss   _exits   getExitMessages	   terminates   threadExited(   s   threads   ui(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   threadexited} s     

s   ExitNotifyThreadc      s_   t  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z RS(
   s   This 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.c    sU  t  i   |  _ y t o t i |   nr t i   } y | i
 d t   t    } Wn t j
 o n X| i t d t |  i  d |  i   d  WnW |  i d  |  i t i   d  t   } t i d |  |  i | i    n X|  i d  t |  d	  o |  i t  n t i   t  i! |   t i"   t i#   d  S(
   Ns   Thread.run(self)s   /s   _s   .profs	   EXCEPTIONi   s   files   NORMALs   exitmessage($   s   threads	   get_idents   selfs   threadids
   profiledirs   Threads   runs   profiles   Profiles   profs   runctxs   globalss   localss
   SystemExits
   dump_statss   strs   getNames   setExitCauses   setExitExceptions   syss   exc_infos   StringIOs   sbufs	   tracebacks	   print_excs   setExitStackTraces   getvalues   hasattrs   setExitMessages   Nones   exitconditions   acquires   exitthreadss   appends   notifys   release(   s   selfs   sbufs   prof(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   run s0     4	

c    s   | |  _ d  S(   N(   s   causes   selfs	   exitcause(   s   selfs   cause(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   setExitCause s    c    s   |  i Sd S(   s   Returns the cause of the exit, one of:
        'EXCEPTION' -- the thread aborted because of an exception
        'NORMAL' -- normal termination.N(   s   selfs	   exitcause(   s   self(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   getExitCause s     c    s   | |  _ d  S(   N(   s   excs   selfs   exitexception(   s   selfs   exc(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   setExitException s    c    s   |  i Sd S(   sd   If getExitCause() is 'EXCEPTION', holds the value from
        sys.exc_info()[1] for this exception.N(   s   selfs   exitexception(   s   self(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   getExitException s     c    s   | |  _ d  S(   N(   s   sts   selfs   exitstacktrace(   s   selfs   st(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   setExitStackTrace s    c    s   |  i Sd S(   sk   If getExitCause() is 'EXCEPTION', returns a string representing
        the stack trace for this exception.N(   s   selfs   exitstacktrace(   s   self(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   getExitStackTrace s     c    s   | |  _ d S(   s   Sets the exit message to be fetched by a subsequent call to
        getExitMessage.  This message may be any object or type except
        None.N(   s   msgs   selfs   exitmessage(   s   selfs   msg(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   setExitMessage s     c    s   |  i Sd S(   s   For any exit cause, returns the message previously set by
        a call to setExitMessage(), or None if there was no such message
        set.N(   s   selfs   exitmessage(   s   self(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   getExitMessage s     (   s   __name__s
   __module__s   __doc__s   runs   setExitCauses   getExitCauses   setExitExceptions   getExitExceptions   setExitStackTraces   getExitStackTraces   setExitMessages   getExitMessage(    (    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   ExitNotifyThread s    								c    s=   t  i   t i |   o t |  t |  <n t  i   d S(   sy   Initialize the instance-limited thread implementation to permit
    up to intancemax threads with the given instancename.N(   s   instancelimitedlocks   acquires   instancelimitedsemss   has_keys   instancenames   BoundedSemaphores   instancemaxs   release(   s   instancenames   instancemax(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   initInstanceLimit s
     
s   InstanceLimitedThreadc      s#   t  Z d   Z d   Z d   Z RS(   Nc    s'   | |  _  t t i |  f | |  d  S(   N(   s   instancenames   selfs   applys   ExitNotifyThreads   __init__s   argss   kwargs(   s   selfs   instancenames   argss   kwargs(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   __init__ s    	c    s"   t  |  i i   t i |   d  S(   N(   s   instancelimitedsemss   selfs   instancenames   acquires   ExitNotifyThreads   start(   s   self(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   start s    c    s*   z t  i |   Wd  t |  i i   Xd  S(   N(   s   ExitNotifyThreads   runs   selfs   instancelimitedsemss   instancenames   release(   s   self(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   run s     (   s   __name__s
   __module__s   __init__s   starts   run(    (    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   InstanceLimitedThread s   		s	   MultiLockc      s#   t  Z d   Z d   Z d   Z RS(   Nc    s%   t    |  _ t    |  _ h  |  _ d  S(   N(   s   Locks   selfs   locks
   statuslocks	   locksheld(   s   self(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   __init__ s    c    sw   |  i i   zH t i   } | |  i j o |  i | c d 7<d Sn d |  i | <Wd |  i i   X|  i i   d S(   s  Obtain a lock.  Provides nice support for a single
        thread trying to lock it several times -- as may be the case
        if one I/O-using object calls others, while wanting to make it all
        an atomic operation.  Keeps a "lock request count" for the current
        thread, and acquires the lock when it goes above zero, releases when
        it goes below one.

        This call is always blocking.i   N(	   s   selfs
   statuslocks   acquires   threads	   get_idents   threadids	   lockshelds   releases   lock(   s   selfs   threadid(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   acquire s      c    sx   |  i i   zV t i   } |  i | d j o |  i | c d 8<d  Sn |  i | =|  i i   Wd  |  i i   Xd  S(   Ni   (	   s   selfs
   statuslocks   acquires   threads	   get_idents   threadids	   lockshelds   locks   release(   s   selfs   threadid(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   releases    
 (   s   __name__s
   __module__s   __init__s   acquires   release(    (    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys	   MultiLock s   		(   s	   threadings   StringIOs   syss	   tracebacks   threads   profiles   offlineimap.uis   UIBases   Nones
   profiledirs   setprofiledirs   semaphoreresets   semaphorewaits   threadsresets
   threadlists	   Conditions   Locks   exitconditions   exitthreadss   initeds   initexitnotifys   exitnotifymonitorloops   threadexiteds   Threads   ExitNotifyThreads   instancelimitedsemss   instancelimitedlocks   initInstanceLimits   InstanceLimitedThreads	   MultiLock(   s   profiles   semaphoreresets   semaphorewaits
   threadlists	   MultiLocks   syss   setprofiledirs   initexitnotifys   threadexiteds   InstanceLimitedThreads   ExitNotifyThreads   threads   StringIOs	   tracebacks   threadsresets   UIBases   exitnotifymonitorloops   initInstanceLimits   initeds   instancelimitedsemss   instancelimitedlock(    (    s>   /usr/pkg/lib/python2p2/site-packages/offlineimap/threadutil.pys   ? s*   $					(			D		