diff options
| author | bwarsaw | 2002-04-10 04:48:01 +0000 |
|---|---|---|
| committer | bwarsaw | 2002-04-10 04:48:01 +0000 |
| commit | 8de0d70abbfdac477c9bc9874f3d0ef200b87773 (patch) | |
| tree | fda7044bd15390c6702098d4a243c006200d80b1 | |
| parent | 7a822f26f9dd953644dc0d8ee5fa0058ed88d422 (diff) | |
| download | mailman-8de0d70abbfdac477c9bc9874f3d0ef200b87773.tar.gz mailman-8de0d70abbfdac477c9bc9874f3d0ef200b87773.tar.zst mailman-8de0d70abbfdac477c9bc9874f3d0ef200b87773.zip | |
_dispose(): Catch socket.errors that can come from the underlying
delivery module (i.e. SMTPDirect) when it couldn't connect to the smtp
server. When this happens, log an error message, but only do it once
so we don't fill up logs/error with a message-per-second. We keep a
self.__logged flag which is set when we log the error and reset in the
class constructor, and when the process() function returned
successfully.
| -rw-r--r-- | Mailman/Queue/OutgoingRunner.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Mailman/Queue/OutgoingRunner.py b/Mailman/Queue/OutgoingRunner.py index 56e5233ad..46e3e7089 100644 --- a/Mailman/Queue/OutgoingRunner.py +++ b/Mailman/Queue/OutgoingRunner.py @@ -19,6 +19,7 @@ import sys import os import time +import socket import email @@ -47,6 +48,10 @@ class OutgoingRunner(Runner): modname = 'Mailman.Handlers.' + mm_cfg.DELIVERY_MODULE mod = __import__(modname) self._func = getattr(sys.modules[modname], 'process') + # This prevents smtp server connection problems from filling up the + # error log. It gets reset if the message was successfully sent, and + # set if there was a socket.error. + self.__logged = 0 def _dispose(self, mlist, msg, msgdata): # Make sure we have the most up-to-date state @@ -58,6 +63,20 @@ class OutgoingRunner(Runner): if pid <> os.getpid(): syslog('error', 'child process leaked thru: %s', modname) os._exit(1) + self.__logged = 0 + except socket.error: + # There was a problem connecting to the SMTP server. Log this + # once, but crank up our sleep time so we don't fill the error + # log. + port = mm_cfg.SMTPPORT + if port == 0: + port = 'smtp' + # Log this just once. + if not self.__logged: + syslog('error', 'Cannot connect to SMTP server %s on port %s', + mm_cfg.SMTPHOST, port) + self.__logged = 1 + return 1 except Errors.SomeRecipientsFailed, e: # The delivery module being used (SMTPDirect or Sendmail) failed # to deliver the message to one or all of the recipients. |
