Пример #1
0
    def _cleanup(self):
        """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.
        """
        Utils.reap(self._kids)
Пример #2
0
    def _cleanup(self):
        """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.
        """
        Utils.reap(self._kids)
Пример #3
0
                # It is possible that shunting can throw an exception, e.g. a
                # permissions problem or a MemoryError due to a really large
                # message.  Try to be graceful.
                try:
                    new_filebase = self._shunt.enqueue(msg, msgdata)
                    log.error("SHUNTING: %s", new_filebase)
                    self._switchboard.finish(filebase)
                except Exception, e:
                    # The message wasn't successfully shunted.  Log the
                    # exception and try to preserve the original queue entry
                    # for possible analysis.
                    self._log(e)
                    log.error("SHUNTING FAILED, preserving original entry: %s", filebase)
                    self._switchboard.finish(filebase, preserve=True)
            # Other work we want to do each time through the loop
            Utils.reap(self._kids, once=True)
            self._doperiodic()
            if self._shortcircuit():
                break
        return len(files)

    def _onefile(self, msg, msgdata):
        # Do some common sanity checking on the message metadata.  It's got to
        # be destined for a particular mailing list.  This switchboard is used
        # to shunt off badly formatted messages.  We don't want to just trash
        # them because they may be fixable with human intervention.  Just get
        # them out of our site though.
        #
        # Find out which mailing list this message is destined for.
        listname = msgdata.get("listname")
        mlist = config.db.list_manager.get(listname)
Пример #4
0
                # message.  Try to be graceful.
                try:
                    new_filebase = self._shunt.enqueue(msg, msgdata)
                    syslog('error', 'SHUNTING: %s', new_filebase)
                    self._switchboard.finish(filebase)
                except Exception, e:
                    # The message wasn't successfully shunted.  Log the
                    # exception and try to preserve the original queue entry
                    # for possible analysis.
                    self._log(e)
                    syslog('error',
                           'SHUNTING FAILED, preserving original entry: %s',
                           filebase)
                    self._switchboard.finish(filebase, preserve=True)
            # Other work we want to do each time through the loop
            Utils.reap(self._kids, once=True)
            self._doperiodic()
            if self._shortcircuit():
                break
        return len(files)

    def _onefile(self, msg, msgdata):
        # Do some common sanity checking on the message metadata.  It's got to
        # be destined for a particular mailing list.  This switchboard is used
        # to shunt off badly formatted messages.  We don't want to just trash
        # them because they may be fixable with human intervention.  Just get
        # them out of our site though.
        #
        # Find out which mailing list this message is destined for.
        listname = msgdata.get('listname')
        if not listname:
Пример #5
0
 def _oneloop(self):
     # First, list all the files in our queue directory.
     # Switchboard.files() is guaranteed to hand us the files in FIFO
     # order.  Return an integer count of the number of files that were
     # available for this qrunner to process.
     files = self._switchboard.files()
     for filebase in files:
         try:
             # Ask the switchboard for the message and metadata objects
             # associated with this filebase.
             msg, msgdata = self._switchboard.dequeue(filebase)
         except Exception as e:
             # This used to just catch email.errors.MessageParseError,
             # but other problems can occur in message parsing, e.g.
             # ValueError, and exceptions can occur in unpickling too.
             # We don't want the runner to die, so we just log and skip
             # this entry, but maybe preserve it for analysis.
             self._log(e)
             if mm_cfg.QRUNNER_SAVE_BAD_MESSAGES:
                 syslog('error',
                        'Skipping and preserving unparseable message: %s',
                        filebase)
                 preserve = True
             else:
                 syslog('error', 'Ignoring unparseable message: %s',
                        filebase)
                 preserve = False
             self._switchboard.finish(filebase, preserve=preserve)
             continue
         try:
             self._onefile(msg, msgdata)
             self._switchboard.finish(filebase)
         except Exception as e:
             # All runners that implement _dispose() must guarantee that
             # exceptions are caught and dealt with properly.  Still, there
             # may be a bug in the infrastructure, and we do not want those
             # to cause messages to be lost.  Any uncaught exceptions will
             # cause the message to be stored in the shunt queue for human
             # intervention.
             self._log(e)
             # Put a marker in the metadata for unshunting
             msgdata['whichq'] = self._switchboard.whichq()
             # It is possible that shunting can throw an exception, e.g. a
             # permissions problem or a MemoryError due to a really large
             # message.  Try to be graceful.
             try:
                 new_filebase = self._shunt.enqueue(msg, msgdata)
                 syslog('error', 'SHUNTING: %s', new_filebase)
                 self._switchboard.finish(filebase)
             except Exception as e:
                 # The message wasn't successfully shunted.  Log the
                 # exception and try to preserve the original queue entry
                 # for possible analysis.
                 self._log(e)
                 syslog('error',
                        'SHUNTING FAILED, preserving original entry: %s',
                        filebase)
                 self._switchboard.finish(filebase, preserve=True)
         # Other work we want to do each time through the loop
         Utils.reap(self._kids, once=True)
         self._doperiodic()
         if self._shortcircuit():
             break
     return len(files)