diff options
| author | bwarsaw | 2001-05-14 18:04:35 +0000 |
|---|---|---|
| committer | bwarsaw | 2001-05-14 18:04:35 +0000 |
| commit | fe29fe1c2498f68f73dac6d66745702cf1c37f6a (patch) | |
| tree | fbf48ecfe2b74fea8df4ffa1631a1b1d0058fed8 | |
| parent | 957898e236a41afed204f4d192d34831f6f6240c (diff) | |
| download | mailman-fe29fe1c2498f68f73dac6d66745702cf1c37f6a.tar.gz mailman-fe29fe1c2498f68f73dac6d66745702cf1c37f6a.tar.zst mailman-fe29fe1c2498f68f73dac6d66745702cf1c37f6a.zip | |
__oneloop(): Guarantee FIFO order on the processed messages. We
assume that the list of files coming back from Switchboard.files() is
sorted by received time, so we don't need to randomize this list.
Also, it's now possible for Switchboard.dequeue() to return None for
either or both of msg and msgdata (say if the .msg file for a .db file
got lost somehow). Check that both are not None before proceeding
(but if either is None, log an error).
| -rw-r--r-- | Mailman/Queue/Runner.py | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/Mailman/Queue/Runner.py b/Mailman/Queue/Runner.py index c896fb4c4..07f127b02 100644 --- a/Mailman/Queue/Runner.py +++ b/Mailman/Queue/Runner.py @@ -73,27 +73,34 @@ class Runner: self._cleanup() def __oneloop(self): - # First, list all the files in our queue directory, and randomize them - # for better coverage even at resource limits. + # First, list all the files in our queue directory. + # Switchboard.files() is guaranteed to hand us the files in FIFO + # order. files = self._switchboard.files() - random.shuffle(files) for filebase in files: # Ask the switchboard for the message and metadata objects # associated with this filebase. msg, msgdata = self._switchboard.dequeue(filebase) - # Now that we've dequeued the message, we want to be incredibly - # anal about making sure that no uncaught exception could cause us - # to lose the message. 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. - try: - self.__onefile(msg, msgdata) - except Exception, e: - self._log(e) - self._shunt.enqueue(msg, msgdata) + # It's possible one or both files got lost. If so, just ignore + # this filebase entry. dequeue() will automatically unlink the + # other file, but we should log an error message for diagnostics. + if msg is None or msgdata is None: + syslog('error', 'lost data files for filebase: %s' % filebase) + else: + # Now that we've dequeued the message, we want to be + # incredibly anal about making sure that no uncaught exception + # could cause us to lose the message. 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. + try: + self.__onefile(msg, msgdata) + except Exception, e: + self._log(e) + self._shunt.enqueue(msg, msgdata) # Other work we want to do each time through the loop Utils.reap(self._kids, once=1) self._doperiodic() |
