From 73e3711097f49b12adc0ea2dee303f0ff212022f Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Tue, 9 May 2000 20:34:45 +0000 Subject: Robustification of handling mail commands. If any of the following fails -- the list name is missing or bogus, or the list lock cannot be acquired within the LIST_LOCK_TIMEOUT time frame -- the message is enqueued for qrunner to try again later. Previously, the message was simply lost! --- scripts/request | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'scripts/request') diff --git a/scripts/request b/scripts/request index 8ed6c86e1..71d62277b 100755 --- a/scripts/request +++ b/scripts/request @@ -32,6 +32,7 @@ from Mailman import mm_cfg from Mailman import MailList from Mailman import Utils from Mailman import Message +from Mailman import Errors from Mailman.pythonlib.StringIO import StringIO from Mailman.Logging.Utils import LogStdErr @@ -39,18 +40,35 @@ LogStdErr("error", "mailcmd") -def main(): - # allow misconfigurations to be logged in logs/error - mlist = MailList.MailList(sys.argv[1]) +def main(mlist): + try: + listname = sys.argv[1] + except IndexError: + sys.stderr.write('Mailman error: mailcmd got no listname.\n') + sys.exit(1) + try: + mlist = MailList.MailList(listname, lock=0) + except Errors.MMListError, e: + sys.stderr.write('Mailman error: mailcmd got bad listname: %s\n%s' % + (listname, e)) + sys.exit(1) + # Try to obtain the mailing list lock. If that fails, enqueue the message + # for delivery by the qrunner cron job. + try: + mlist.Lock(timeout=mm_cfg.LIST_LOCK_TIMEOUT) + except LockFile.TimeOutError: + msg.Enqueue(mlist) + return try: s = StringIO(sys.stdin.read()) msg = Message.Message(s) - msg.torequest = 1 + # Moved the setting of 'torequest' into MailCommandHandler mlist.ParseMailCommands(msg) finally: mlist.Save() mlist.Unlock() + if __name__ == '__main__': main() -- cgit v1.2.3-70-g09d2