;ò
¢)?Bc           @   sÙ   d  Z  d k Z d k Z d k Z d k l Z d k l Z d k l Z d k l	 Z	 d k l
 Z
 d k l Z d k l Z d	 k l Z d k Z y e e f Wn e j
 o d
 Z d Z n Xd f  d „  ƒ  YZ d S(   s   Generic queue runner class.
N(   s   StringIO(   s   mm_cfg(   s   Utils(   s   Errors(   s   MailList(   s   i18n(   s   Switchboard(   s   syslogi   i    s   Runnerc           B   sž   t  Z e Z e i Z e d d „ Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z e i ƒ  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z RS(   Ni   c         C   s@   h  |  _ t |  i | | ƒ |  _ t t i ƒ |  _	 t
 |  _ d  S(   N(   s   selfs   _kidss   Switchboards   QDIRs   slices	   numslicess   _switchboards   mm_cfgs   SHUNTQUEUE_DIRs   _shunts   Falses   _stop(   s   selfs   slices	   numslices(    (    s$   /var/mailman/Mailman/Queue/Runner.pys   __init__0   s    	c         C   s   d |  i i t |  ƒ f Sd  S(   Ns
   <%s at %s>(   s   selfs	   __class__s   __name__s   id(   s   self(    (    s$   /var/mailman/Mailman/Queue/Runner.pys   __repr__9   s    c         C   s   t  |  _ d  S(   N(   s   Trues   selfs   _stop(   s   self(    (    s$   /var/mailman/Mailman/Queue/Runner.pys   stop<   s    c         C   sq   z_ yE x> t  o6 |  i ƒ  } |  i ƒ  |  i o Pn |  i | ƒ q	 WWn t j
 o n XWd  |  i ƒ  Xd  S(   N(	   s   Trues   selfs   _oneloops   filecnts   _doperiodics   _stops   _snoozes   KeyboardInterrupts   _cleanup(   s   selfs   filecnt(    (    s$   /var/mailman/Mailman/Queue/Runner.pys   run?   s     

	 c         C   s+  |  i i ƒ  } x| D]} y |  i i | ƒ \ } } Wn; t i i	 j
 o) } |  i | ƒ t d d | ƒ q n Xy |  i | | ƒ WnZ t j
 oN } |  i | ƒ |  i i ƒ  | d <|  i i | | ƒ } t d d | ƒ n Xt i |  i d t ƒ|  i ƒ  |  i ƒ  o Pq q Wt | ƒ Sd  S(   Ns   errors    Ignoring unparseable message: %ss   whichqs   SHUNTING: %ss   once(   s   selfs   _switchboards   filess   filebases   dequeues   msgs   msgdatas   emails   Errorss   MessageParseErrors   es   _logs   syslogs   _onefiles	   Exceptions   whichqs   _shunts   enqueues   Utilss   reaps   _kidss   Trues   _doperiodics   _shortcircuits   len(   s   selfs   filess   filebases   es   msgdatas   msg(    (    s$   /var/mailman/Mailman/Queue/Runner.pys   _oneloopY   s*     
	c   
      C   s.  | i d ƒ } | o t i } n |  i | ƒ } | o+ t d d | ƒ |  i	 i
 | | ƒ d  Sn t i ƒ  } | i ƒ  } | o | i | ƒ }	 n
 t i }	 t i |	 ƒ |	 | d <z |  i | | | ƒ } Wd  t i | ƒ X| i d ƒ } | o |  i i | ƒ n | o |  i i
 | | ƒ n d  S(   Ns   listnames   errors/   Dequeuing message destined for missing list: %ss   langs   _kids(   s   msgdatas   gets   listnames   mm_cfgs   MAILMAN_SITE_LISTs   selfs
   _open_lists   mlists   syslogs   _shunts   enqueues   msgs   i18ns   get_translations   otranslations
   get_senders   senders   getMemberLanguages   langs   DEFAULT_SERVER_LANGUAGEs   set_languages   _disposes
   keepqueueds   set_translations   kidss   _kidss   updates   _switchboard(
   s   selfs   msgs   msgdatas   otranslations   listnames
   keepqueueds   kidss   senders   mlists   lang(    (    s$   /var/mailman/Mailman/Queue/Runner.pys   _onefileƒ   s4    
	
 c         C   s~   |  i i | ƒ } | o\ y t i | d t ƒ} Wn/ t i j
 o  } t
 d d | | ƒ t Sqv X| |  i | <n | Sd  S(   Ns   locks   errors   error opening list: %s
%s(   s   selfs
   _listcaches   gets   listnames   mlists   MailLists   Falses   Errorss   MMListErrors   es   syslogs   None(   s   selfs   listnames   mlists   e(    (    s$   /var/mailman/Mailman/Queue/Runner.pys
   _open_list´   s    	c         C   s@   t  d d | ƒ t ƒ  } t i d | ƒ t  d | i ƒ  ƒ d  S(   Ns   errors   Uncaught runner exception: %ss   file(   s   syslogs   excs   StringIOs   ss	   tracebacks	   print_excs   getvalue(   s   selfs   excs   s(    (    s$   /var/mailman/Mailman/Queue/Runner.pys   _logÃ   s    	c         C   s   t  i |  i ƒ d S(   sÔ   Clean up upon exit from the main processing loop.

        Called when the Runner's main loop is stopped, this should perform
        any necessary resource deallocation.  Its return value is irrelevant.
        N(   s   Utilss   reaps   selfs   _kids(   s   self(    (    s$   /var/mailman/Mailman/Queue/Runner.pys   _cleanupÌ   s     c         C   s
   t  ‚ d S(   sÌ  Dispose of a single message destined for a mailing list.

        Called for each message that the Runner is responsible for, this is
        the primary overridable method for processing each message.
        Subclasses, must provide implementation for this method.

        mlist is the MailList instance this message is destined for.

        msg is the Message object representing the message.

        msgdata is a dictionary of message metadata.
        N(   s   NotImplementedError(   s   selfs   mlists   msgs   msgdata(    (    s$   /var/mailman/Mailman/Queue/Runner.pys   _disposeÔ   s     c         C   s   d S(   s*  Do some processing `every once in a while'.

        Called every once in a while both from the Runner's main loop, and
        from the Runner's hash slice processing loop.  You can do whatever
        special periodic processing you want here, and the return value is
        irrelevant.
        N(    (   s   self(    (    s$   /var/mailman/Mailman/Queue/Runner.pys   _doperiodicã   s     c         C   s3   | p |  i d j o d Sn t i |  i ƒ d S(   s+  Sleep for a little while.

        filecnt is the number of messages in the queue the last time through.
        Sub-runners can decide to continue to do work, or sleep for a while
        based on this value.  By default, we only snooze if there was nothing
        to do last time around.
        i    N(   s   filecnts   selfs	   SLEEPTIMEs   times   sleep(   s   selfs   filecnt(    (    s$   /var/mailman/Mailman/Queue/Runner.pys   _snoozeí   s     c         C   s   |  i Sd S(   sn  Return a true value if the individual file processing loop should
        exit before it's finished processing each message in the current slice
        of hash space.  A false value tells _oneloop() to continue processing
        until the current snapshot of hash space is exhausted.

        You could, for example, implement a throttling algorithm here.
        N(   s   selfs   _stop(   s   self(    (    s$   /var/mailman/Mailman/Queue/Runner.pys   _shortcircuitù   s     (   s   __name__s
   __module__s   Nones   QDIRs   mm_cfgs   QRUNNER_SLEEP_TIMEs	   SLEEPTIMEs   __init__s   __repr__s   stops   runs   _oneloops   _onefiles   weakrefs   WeakValueDictionarys
   _listcaches
   _open_lists   _logs   _cleanups   _disposes   _doperiodics   _snoozes   _shortcircuit(    (    (    s$   /var/mailman/Mailman/Queue/Runner.pys   Runner,   s    						*	/						
	(   s   __doc__s   times	   tracebacks   weakrefs	   cStringIOs   StringIOs   Mailmans   mm_cfgs   Utilss   Errorss   MailLists   i18ns   Mailman.Queue.Switchboards   Switchboards   Mailman.Logging.Syslogs   syslogs   email.Errorss   emails   Trues   Falses	   NameErrors   Runner(   s   Switchboards   Errorss   Falses   StringIOs   Runners   Utilss	   tracebacks   MailLists   weakrefs   syslogs   mm_cfgs   times   i18ns   Trues   email(    (    s$   /var/mailman/Mailman/Queue/Runner.pys   ?   s$   				