diff options
Diffstat (limited to 'Mailman/queue')
| -rw-r--r-- | Mailman/queue/archive.py | 16 | ||||
| -rw-r--r-- | Mailman/queue/bounce.py | 1 | ||||
| -rw-r--r-- | Mailman/queue/command.py | 36 | ||||
| -rw-r--r-- | Mailman/queue/incoming.py | 24 | ||||
| -rw-r--r-- | Mailman/queue/outgoing.py | 1 |
5 files changed, 24 insertions, 54 deletions
diff --git a/Mailman/queue/archive.py b/Mailman/queue/archive.py index c6565e11d..b0274d49c 100644 --- a/Mailman/queue/archive.py +++ b/Mailman/queue/archive.py @@ -17,11 +17,13 @@ """Archive queue runner.""" +from __future__ import with_statement + import time from email.Utils import parsedate_tz, mktime_tz, formatdate -from Mailman import LockFile from Mailman.configuration import config +from Mailman.lockfile import LockFile from Mailman.queue import Runner @@ -64,14 +66,6 @@ class ArchiveRunner(Runner): msg['X-Original-Date'] = originaldate # Always put an indication of when we received the message. msg['X-List-Received-Date'] = receivedtime - # Now try to get the list lock - try: - mlist.Lock(timeout=config.LIST_LOCK_TIMEOUT) - except LockFile.TimeOutError: - # oh well, try again later - return 1 - try: + # While a list archiving lock is acquired, archive the message. + with LockFile(os.path.join(mlist.full_path, 'archive.lck')): mlist.ArchiveMail(msg) - mlist.Save() - finally: - mlist.Unlock() diff --git a/Mailman/queue/bounce.py b/Mailman/queue/bounce.py index 361b01fac..07fb3ab27 100644 --- a/Mailman/queue/bounce.py +++ b/Mailman/queue/bounce.py @@ -27,7 +27,6 @@ from email.MIMEMessage import MIMEMessage from email.MIMEText import MIMEText from email.Utils import parseaddr -from Mailman import LockFile from Mailman import Utils from Mailman.Bouncers import BouncerAPI from Mailman.Message import UserNotification diff --git a/Mailman/queue/command.py b/Mailman/queue/command.py index a67e757f3..ca53d0192 100644 --- a/Mailman/queue/command.py +++ b/Mailman/queue/command.py @@ -31,7 +31,6 @@ from email.Iterators import typed_subpart_iterator from email.MIMEMessage import MIMEMessage from email.MIMEText import MIMEText -from Mailman import LockFile from Mailman import Message from Mailman import Utils from Mailman.Handlers import Replybot @@ -214,29 +213,18 @@ class CommandRunner(Runner): return False # Now craft the response res = Results(mlist, msg, msgdata) - # BAW: Not all the functions of this qrunner require the list to be - # locked. Still, it's more convenient to lock it here and now and - # deal with lock failures in one place. - try: - mlist.Lock(timeout=config.LIST_LOCK_TIMEOUT) - except LockFile.TimeOutError: - # Oh well, try again later - return True # This message will have been delivered to one of mylist-request, # mylist-join, or mylist-leave, and the message metadata will contain # a key to which one was used. - try: - if msgdata.get('torequest'): - res.process() - elif msgdata.get('tojoin'): - res.do_command('join') - elif msgdata.get('toleave'): - res.do_command('leave') - elif msgdata.get('toconfirm'): - mo = re.match(config.VERP_CONFIRM_REGEXP, msg.get('to', '')) - if mo: - res.do_command('confirm', (mo.group('cookie'),)) - res.send_response() - mlist.Save() - finally: - mlist.Unlock() + if msgdata.get('torequest'): + res.process() + elif msgdata.get('tojoin'): + res.do_command('join') + elif msgdata.get('toleave'): + res.do_command('leave') + elif msgdata.get('toconfirm'): + mo = re.match(config.VERP_CONFIRM_REGEXP, msg.get('to', '')) + if mo: + res.do_command('confirm', (mo.group('cookie'),)) + res.send_response() + config.db.commit() diff --git a/Mailman/queue/incoming.py b/Mailman/queue/incoming.py index 05ab924e6..6118a7ca0 100644 --- a/Mailman/queue/incoming.py +++ b/Mailman/queue/incoming.py @@ -102,7 +102,6 @@ import logging from cStringIO import StringIO from Mailman import Errors -from Mailman import LockFile from Mailman.configuration import config from Mailman.queue import Runner @@ -117,12 +116,6 @@ class IncomingRunner(Runner): def _dispose(self, mlist, msg, msgdata): if msgdata.get('envsender') is None: msg['envsender'] = mlist.no_reply_address - # Try to get the list lock. - try: - mlist.Lock(timeout=config.LIST_LOCK_TIMEOUT) - except LockFile.TimeOutError: - # Oh well, try again later - return 1 # Process the message through a handler pipeline. The handler # pipeline can actually come from one of three places: the message # metadata, the mlist, or the global pipeline. @@ -131,16 +124,13 @@ class IncomingRunner(Runner): # will contain the retry pipeline. Use this above all else. # Otherwise, if the mlist has a `pipeline' attribute, it should be # used. Final fallback is the global pipeline. - try: - pipeline = self._get_pipeline(mlist, msg, msgdata) - msgdata['pipeline'] = pipeline - more = self._dopipeline(mlist, msg, msgdata, pipeline) - if not more: - del msgdata['pipeline'] - mlist.Save() - return more - finally: - mlist.Unlock() + pipeline = self._get_pipeline(mlist, msg, msgdata) + msgdata['pipeline'] = pipeline + more = self._dopipeline(mlist, msg, msgdata, pipeline) + if not more: + del msgdata['pipeline'] + config.db.commit() + return more # Overridable def _get_pipeline(self, mlist, msg, msgdata): diff --git a/Mailman/queue/outgoing.py b/Mailman/queue/outgoing.py index a1e64096d..8322766a4 100644 --- a/Mailman/queue/outgoing.py +++ b/Mailman/queue/outgoing.py @@ -26,7 +26,6 @@ import socket import logging from Mailman import Errors -from Mailman import LockFile from Mailman import Message from Mailman.configuration import config from Mailman.queue import Runner, Switchboard |
