aboutsummaryrefslogtreecommitdiffstats
path: root/Mailman
diff options
context:
space:
mode:
authorbwarsaw <>2004-05-15 21:48:45 +0000
committerbwarsaw <>2004-05-15 21:48:45 +0000
commit13e9e75182d041b4fcc1959fd87314acd6d790ba (patch)
tree6d4b900a0e0b9b51ba4225fa16a8cc4efc0f37d0 /Mailman
parent46dd18b52fcd39c608cabcea60ff506ee0813edd (diff)
downloadmailman2-13e9e75182d041b4fcc1959fd87314acd6d790ba.tar.gz
mailman2-13e9e75182d041b4fcc1959fd87314acd6d790ba.tar.xz
mailman2-13e9e75182d041b4fcc1959fd87314acd6d790ba.zip
_oneloop(): Switchboard.dequeue() can't really return Nones for msg or msgdata
any more (they were error signals in the previous switchboard implementation), so simplify the loop. We can't have 'lost data files'.
Diffstat (limited to 'Mailman')
-rw-r--r--Mailman/Queue/Runner.py54
1 files changed, 29 insertions, 25 deletions
diff --git a/Mailman/Queue/Runner.py b/Mailman/Queue/Runner.py
index 61c902d5..363af6b7 100644
--- a/Mailman/Queue/Runner.py
+++ b/Mailman/Queue/Runner.py
@@ -31,6 +31,8 @@ from Mailman import i18n
from Mailman.Queue.Switchboard import Switchboard
from Mailman.Logging.Syslog import syslog
+import email.Errors
+
try:
True, False
except NameError:
@@ -91,32 +93,34 @@ class Runner:
# available for this qrunner to process.
files = self._switchboard.files()
for filebase in files:
- # Ask the switchboard for the message and metadata objects
- # associated with this filebase.
- msg, msgdata = self._switchboard.dequeue(filebase)
- # 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
+ try:
+ # Ask the switchboard for the message and metadata objects
+ # associated with this filebase.
+ msg, msgdata = self._switchboard.dequeue(filebase)
+ except email.Errors.MessageParseError, e:
+ # It's possible to get here if the message was stored in the
+ # pickle in plain text, and the metadata had a _parsemsg key
+ # that was true, /and/ if the message had some bogosity in
+ # it. It's almost always going to be spam or bounced spam.
+ # There's not much we can do (and we didn't even get the
+ # metadata, so just log the exception and continue.
+ self._log(e)
+ syslog('error', 'Ignoring unparseable message: %s', filebase)
+ continue
+ try:
+ self._onefile(msg, msgdata)
+ except Exception, 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.
- try:
- self._onefile(msg, msgdata)
- except Exception, e:
- self._log(e)
- # Put a marker in the metadata for unshunting
- msgdata['whichq'] = self._switchboard.whichq()
- filebase = self._shunt.enqueue(msg, msgdata)
- syslog('error', 'SHUNTING: %s', filebase)
+ self._log(e)
+ # Put a marker in the metadata for unshunting
+ msgdata['whichq'] = self._switchboard.whichq()
+ filebase = self._shunt.enqueue(msg, msgdata)
+ syslog('error', 'SHUNTING: %s', filebase)
# Other work we want to do each time through the loop
Utils.reap(self._kids, once=True)
self._doperiodic()