------------------------------------------------------------ revno: 6568 committer: Barry Warsaw <[EMAIL PROTECTED]> branch nick: 3.0 timestamp: Wed 2007-10-10 23:22:03 -0400 message: General cleanups some of which is even tested <wink>. Mailman.LockFile module is moved to Mailman.lockfile. Remove a few more MailList methods that aren't used any more, e.g. the lock related stuff, the Save() and CheckValues() methods, as well as ChangeMemberName(). Add a missing import to lifecycle.py. We no longer need withlist to unlock the mailing list. Also, expose config.db.flush() in the namespace of withlist directly, under 'flush'. renamed: Mailman/LockFile.py => Mailman/lockfile.py modified: Mailman/Archiver/HyperArch.py Mailman/Archiver/HyperDatabase.py Mailman/Handlers/Scrubber.py Mailman/MTA/Manual.py Mailman/MTA/Postfix.py Mailman/MailList.py Mailman/app/lifecycle.py Mailman/bin/arch.py Mailman/bin/gate_news.py Mailman/bin/mailmanctl.py Mailman/bin/withlist.py Mailman/database/__init__.py Mailman/database/usermanager.py Mailman/queue/archive.py Mailman/queue/bounce.py Mailman/queue/command.py Mailman/queue/incoming.py Mailman/queue/outgoing.py Mailman/tests/test_lockfile.py Mailman/lockfile.py
=== renamed file 'Mailman/LockFile.py' => 'Mailman/lockfile.py' --- a/Mailman/LockFile.py 2007-09-29 15:09:14 +0000 +++ b/Mailman/lockfile.py 2007-10-11 03:22:03 +0000 @@ -47,6 +47,14 @@ your clocks are properly synchronized. """ +__metaclass__ = type +__all__ = [ + 'LockError', + 'AlreadyLockedError', + 'NotLockedError', + 'LockFile', + ] + # This code has undergone several revisions, with contributions from Barry # Warsaw, Thomas Wouters, Harald Meland, and John Viega. It should also work # well outside of Mailman so it could be used for other Python projects === modified file 'Mailman/Archiver/HyperArch.py' --- a/Mailman/Archiver/HyperArch.py 2007-09-19 11:28:58 +0000 +++ b/Mailman/Archiver/HyperArch.py 2007-10-11 03:22:03 +0000 @@ -43,10 +43,10 @@ from email.Header import decode_header, make_header from Mailman import Errors -from Mailman import LockFile from Mailman import MailList from Mailman import Utils from Mailman import i18n +from Mailman import lockfile from Mailman.Archiver import HyperDatabase from Mailman.Archiver import pipermail from Mailman.Mailbox import ArchiverMailbox @@ -786,12 +786,12 @@ def GetArchLock(self): if self._lock_file: return 1 - self._lock_file = LockFile.LockFile( + self._lock_file = lockfile.LockFile( os.path.join(config.LOCK_DIR, self.maillist.fqdn_listname + '-arch.lock')) try: self._lock_file.lock(timeout=0.5) - except LockFile.TimeOutError: + except lockfile.TimeOutError: return 0 return 1 === modified file 'Mailman/Archiver/HyperDatabase.py' --- a/Mailman/Archiver/HyperDatabase.py 2007-01-19 04:38:06 +0000 +++ b/Mailman/Archiver/HyperDatabase.py 2007-10-11 03:22:03 +0000 @@ -27,7 +27,7 @@ # package/project modules # import pipermail -from Mailman import LockFile +from Mailman.lockfile import LockFile CACHESIZE = pipermail.CACHESIZE @@ -58,7 +58,7 @@ def __init__(self, path): self.current_index = 0 self.path = path - self.lockfile = LockFile.LockFile(self.path + ".lock") + self.lockfile = LockFile(self.path + ".lock") self.lock() self.__dirty = 0 self.dict = {} === modified file 'Mailman/Handlers/Scrubber.py' --- a/Mailman/Handlers/Scrubber.py 2007-09-21 12:51:38 +0000 +++ b/Mailman/Handlers/Scrubber.py 2007-10-11 03:22:03 +0000 @@ -17,6 +17,8 @@ """Cleanse a message for archiving.""" +from __future__ import with_statement + import os import re import sha @@ -34,13 +36,13 @@ from email.parser import HeaderParser from email.utils import make_msgid, parsedate -from Mailman import LockFile from Mailman import Message from Mailman import Utils from Mailman.Errors import DiscardMessage from Mailman.app.archiving import get_base_archive_url from Mailman.configuration import config from Mailman.i18n import _ +from Mailman.lockfile import LockFile # Path characters for common platforms pre = re.compile(r'[/\\:]') @@ -422,10 +424,7 @@ ext = '.bin' path = None # We need a lock to calculate the next attachment number - lockfile = os.path.join(fsdir, 'attachments.lock') - lock = LockFile.LockFile(lockfile) - lock.lock() - try: + with LockFile(os.path.join(fsdir, 'attachments.lock')): # Now base the filename on what's in the attachment, uniquifying it if # necessary. if not filename or config.SCRUBBER_DONT_USE_ATTACHMENT_FILENAME: @@ -461,8 +460,6 @@ extra = '-%04d' % counter else: break - finally: - lock.unlock() # `path' now contains the unique filename for the attachment. There's # just one more step we need to do. If the part is text/html and # ARCHIVE_HTML_SANITIZER is a string (which it must be or we wouldn't be === modified file 'Mailman/MTA/Manual.py' --- a/Mailman/MTA/Manual.py 2007-09-29 18:55:25 +0000 +++ b/Mailman/MTA/Manual.py 2007-10-11 03:22:03 +0000 @@ -98,7 +98,7 @@ def remove(mlist, cgi=False): - listname = mlist.internal_name() + listname = mlist.fqdn_listname fieldsz = len(listname) + len('-unsubscribe') if cgi: # If a list is being removed via the CGI, the best we can do is send === modified file 'Mailman/MTA/Postfix.py' --- a/Mailman/MTA/Postfix.py 2007-01-05 06:47:39 +0000 +++ b/Mailman/MTA/Postfix.py 2007-10-11 03:22:03 +0000 @@ -17,6 +17,8 @@ """Creation/deletion hooks for the Postfix MTA.""" +from __future__ import with_statement + import os import grp import pwd @@ -26,11 +28,11 @@ from stat import * -from Mailman import LockFile from Mailman import Utils from Mailman.MTA.Utils import makealiases from Mailman.configuration import config from Mailman.i18n import _ +from Mailman.lockfile import LockFile LOCKFILE = os.path.join(config.LOCK_DIR, 'creator') ALIASFILE = os.path.join(config.DATA_DIR, 'aliases') @@ -66,10 +68,6 @@ -def makelock(): - return LockFile.LockFile(LOCKFILE) - - def _zapfile(filename): # Truncate the file w/o messing with the file permissions, but only if it # already exists. @@ -274,6 +272,7 @@ # Acquire the global list database lock. quiet flag is ignored. lock = None if not nolock: + # XXX FIXME lock = makelock() lock.lock() # Do the aliases file, which always needs to be done @@ -339,9 +338,7 @@ def remove(mlist, cgi=False): # Acquire the global list database lock - lock = makelock() - lock.lock() - try: + with LockFile(LOCKFILE): if config.USE_LMTP: _do_remove(mlist, TRPTFILE) else: @@ -350,8 +347,7 @@ _do_remove(mlist, VIRTFILE) # Regenerate the alias and map files _update_maps() - finally: - lock.unlock(unconditionally=True) + config.db.commit() === modified file 'Mailman/MailList.py' --- a/Mailman/MailList.py 2007-10-10 04:16:12 +0000 +++ b/Mailman/MailList.py 2007-10-11 03:22:03 +0000 @@ -47,7 +47,6 @@ from email.Utils import getaddresses, formataddr, parseaddr from Mailman import Errors -from Mailman import LockFile from Mailman import Utils from Mailman import Version from Mailman import database @@ -132,36 +131,6 @@ return '<mailing list "%s" at %x>' % (self.fqdn_listname, id(self)) - # - # Lock management - # - def _make_lock(self, name, lock=False): - self._lock = LockFile.LockFile( - os.path.join(config.LOCK_DIR, name) + '.lock', - lifetime=config.LIST_LOCK_LIFETIME) - if lock: - self._lock.lock() - - def Lock(self, timeout=0): - self._lock.lock(timeout) - self._memberadaptor.lock() - # Must reload our database for consistency. Watch out for lists that - # don't exist. - try: - self.Load() - except Exception: - self.Unlock() - raise - - def Unlock(self): - self._lock.unlock(unconditionally=True) - self._memberadaptor.unlock() - - def Locked(self): - return self._lock.locked() - - - def GetConfirmJoinSubject(self, listname, cookie): if config.VERP_CONFIRMATIONS and cookie: cset = i18n.get_translation().charset() or \ @@ -258,59 +227,6 @@ return value - def Save(self): - # Refresh the lock, just to let other processes know we're still - # interested in it. This will raise a NotLockedError if we don't have - # the lock (which is a serious problem!). TBD: do we need to be more - # defensive? - self._lock.refresh() - # The member adaptor may have its own save operation - self._memberadaptor.save() - self.CheckHTMLArchiveDir() - - def Load(self): - self._memberadaptor.load() - - - - # - # Sanity checks - # - def CheckValues(self): - """Normalize selected values to known formats.""" - if '' in urlparse(self.web_page_url)[:2]: - # Either the "scheme" or the "network location" part of the parsed - # URL is empty; substitute faulty value with (hopefully sane) - # default. Note that DEFAULT_URL is obsolete. - self.web_page_url = ( - config.DEFAULT_URL or - config.DEFAULT_URL_PATTERN % config.DEFAULT_URL_HOST) - if self.web_page_url and self.web_page_url[-1] <> '/': - self.web_page_url = self.web_page_url + '/' - # Legacy reply_to_address could be an illegal value. We now verify - # upon setting and don't check it at the point of use. - try: - if self.reply_to_address.strip() and self.reply_goes_to_list: - Utils.ValidateEmail(self.reply_to_address) - except Errors.EmailAddressError: - elog.error('Bad reply_to_address "%s" cleared for list: %s', - self.reply_to_address, self.internal_name()) - self.reply_to_address = '' - self.reply_goes_to_list = 0 - # Legacy topics may have bad regular expressions in their patterns - goodtopics = [] - for name, pattern, desc, emptyflag in self.topics: - try: - orpattern = OR.join(pattern.splitlines()) - re.compile(orpattern) - except (re.error, TypeError): - elog.error('Bad topic pattern "%s" for list: %s', - orpattern, self.internal_name()) - else: - goodtopics.append((name, pattern, desc, emptyflag)) - self.topics = goodtopics - - # # Membership management front-ends and assertion checks # @@ -479,26 +395,6 @@ raise Errors.MMNeedApproval, _( 'unsubscriptions require moderator approval') - def ChangeMemberName(self, addr, name, globally): - self.setMemberName(addr, name) - if not globally: - return - for listname in config.list_manager.names: - # Don't bother with ourselves - if listname == self.internal_name(): - continue - mlist = MailList(listname, lock=0) - if mlist.host_name <> self.host_name: - continue - if not mlist.isMember(addr): - continue - mlist.Lock() - try: - mlist.setMemberName(addr, name) - mlist.Save() - finally: - mlist.Unlock() - def ChangeMemberAddress(self, oldaddr, newaddr, globally): # Changing a member address consists of verifying the new address, # making sure the new address isn't already a member, and optionally === modified file 'Mailman/app/lifecycle.py' --- a/Mailman/app/lifecycle.py 2007-10-10 02:18:14 +0000 +++ b/Mailman/app/lifecycle.py 2007-10-11 03:22:03 +0000 @@ -18,6 +18,7 @@ """Application level list creation.""" import os +import sys import shutil import logging === modified file 'Mailman/bin/arch.py' --- a/Mailman/bin/arch.py 2007-01-19 04:38:06 +0000 +++ b/Mailman/bin/arch.py 2007-10-11 03:22:03 +0000 @@ -15,6 +15,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. +from __future__ import with_statement + import os import sys import errno @@ -25,9 +27,10 @@ from Mailman import Version from Mailman import i18n from Mailman.Archiver.HyperArch import HyperArchive -from Mailman.LockFile import LockFile +from Mailman.Defaults import hours from Mailman.MailList import MailList from Mailman.configuration import config +from Mailman.lockfile import LockFile _ = i18n._ __i18n_templates__ = True @@ -119,53 +122,41 @@ # really don't know how long it will take. # # XXX processUnixMailbox() should refresh the lock. - # - # XXX This may not be necessary because I think we lay claim to the - # list lock up above, although that may be too short to be of use (and - # maybe we don't really want to lock the list anyway). - lockfile = os.path.join(config.LOCK_DIR, mlist._internal_name) + \ - '.archiver.lock' - # set the lock lifetime to 3 hours. XXX is this reasonable??? - lock = LockFile(lockfile, lifetime=3*60*60) - lock.lock() - # Maybe wipe the old archives - if opts.wipe: - if mlist.scrub_nondigest: - # TK: save the attachments dir because they are not in mbox - saved = False - atchdir = os.path.join(mlist.archive_dir(), 'attachments') - savedir = os.path.join(mlist.archive_dir() + '.mbox', - 'attachments') - try: - os.rename(atchdir, savedir) - saved = True - except OSError, e: - if e.errno <> errno.ENOENT: - raise - shutil.rmtree(mlist.archive_dir()) - if mlist.scrub_nondigest and saved: - os.renames(savedir, atchdir) - try: - fp = open(mbox) - except IOError, e: - if e.errno == errno.ENOENT: - print >> sys.stderr, _('Cannot open mbox file: $mbox') - else: - print >> sys.stderr, e - sys.exit(1) + with LockFile(os.path.join(mlist.full_path, '.archiver.lck'), + lifetime=int(hours(3))): + # Maybe wipe the old archives + if opts.wipe: + if mlist.scrub_nondigest: + # TK: save the attachments dir because they are not in mbox + saved = False + atchdir = os.path.join(mlist.archive_dir(), 'attachments') + savedir = os.path.join(mlist.archive_dir() + '.mbox', + 'attachments') + try: + os.rename(atchdir, savedir) + saved = True + except OSError, e: + if e.errno <> errno.ENOENT: + raise + shutil.rmtree(mlist.archive_dir()) + if mlist.scrub_nondigest and saved: + os.renames(savedir, atchdir) + try: + fp = open(mbox) + except IOError, e: + if e.errno == errno.ENOENT: + print >> sys.stderr, _('Cannot open mbox file: $mbox') + else: + print >> sys.stderr, e + sys.exit(1) - archiver = HyperArchive(mlist) - archiver.VERBOSE = opts.verbose - try: - archiver.processUnixMailbox(fp, opts.start, opts.end) - finally: - archiver.close() - fp.close() - finally: - if lock: - lock.unlock() - if mlist: - mlist.Unlock() + archiver = HyperArchive(mlist) + archiver.VERBOSE = opts.verbose + try: + archiver.processUnixMailbox(fp, opts.start, opts.end) + finally: + archiver.close() + fp.close() === modified file 'Mailman/bin/gate_news.py' --- a/Mailman/bin/gate_news.py 2007-10-10 04:16:12 +0000 +++ b/Mailman/bin/gate_news.py 2007-10-11 03:22:03 +0000 @@ -15,6 +15,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. +from __future__ import with_statement + import os import sys import time @@ -26,11 +28,11 @@ import email.Errors from email.Parser import Parser -from Mailman import LockFile from Mailman import MailList from Mailman import Message from Mailman import Utils from Mailman import Version +from Mailman import lockfile from Mailman import loginit from Mailman.configuration import config from Mailman.i18n import _ @@ -210,7 +212,7 @@ # loop over range, and this will not include the last # element in the list. poll_newsgroup(mlist, conn, start, last + 1, glock) - except LockFile.TimeOutError: + except lockfile.TimeOutError: log.error('Could not acquire list lock: %s', listname) finally: if mlist.Locked(): @@ -230,19 +232,14 @@ loginit.initialize(propagate=True) log = logging.getLogger('mailman.fromusenet') - lock = LockFile.LockFile(GATENEWS_LOCK_FILE, - # It's okay to hijack this - lifetime=LOCK_LIFETIME) try: - lock.lock(timeout=0.5) + with lockfile.LockFile(GATENEWS_LOCK_FILE, + # It's okay to hijack this + lifetime=LOCK_LIFETIME): + process_lists(lock) + clearcache() except LockFile.TimeOutError: log.error('Could not acquire gate_news lock') - return - try: - process_lists(lock) - finally: - clearcache() - lock.unlock(unconditionally=True) === modified file 'Mailman/bin/mailmanctl.py' --- a/Mailman/bin/mailmanctl.py 2007-09-29 15:09:14 +0000 +++ b/Mailman/bin/mailmanctl.py 2007-10-11 03:22:03 +0000 @@ -27,9 +27,9 @@ from Mailman import Defaults from Mailman import Errors -from Mailman import LockFile from Mailman import Utils from Mailman import Version +from Mailman import lockfile from Mailman import loginit from Mailman.configuration import config from Mailman.i18n import _ @@ -197,11 +197,11 @@ def acquire_lock_1(force): # Be sure we can acquire the master qrunner lock. If not, it means some # other master qrunner daemon is already going. - lock = LockFile.LockFile(config.LOCK_FILE, LOCK_LIFETIME) + lock = lockfile.LockFile(config.LOCK_FILE, LOCK_LIFETIME) try: lock.lock(0.1) return lock - except LockFile.TimeOutError: + except lockfile.TimeOutError: if not force: raise # Force removal of lock first @@ -216,7 +216,7 @@ try: lock = acquire_lock_1(force) return lock - except LockFile.TimeOutError: + except lockfile.TimeOutError: status = qrunner_state() if status == 1: # host matches and proc exists === modified file 'Mailman/bin/withlist.py' --- a/Mailman/bin/withlist.py 2007-10-10 04:16:12 +0000 +++ b/Mailman/bin/withlist.py 2007-10-11 03:22:03 +0000 @@ -17,7 +17,6 @@ import os import sys -import atexit import optparse from Mailman import Errors @@ -31,20 +30,6 @@ LAST_MLIST = None VERBOSE = True -LOCK = False - - - -def exitfunc(mlist): - """Unlock a locked list, but do not implicitly Save() it.""" - if mlist.Locked(): - if VERBOSE: - listname = mlist.fqdn_listname - print >> sys.stderr, _( - 'Unlocking (but not saving) list: $listname') - mlist.Unlock() - if VERBOSE: - print >> sys.stderr, _('Finalizing') @@ -54,18 +39,12 @@ if '@' not in listname: listname += '@' + config.DEFAULT_EMAIL_HOST - if VERBOSE: - print >> sys.stderr, _('Loading list $listname'), - if LOCK: - print >> sys.stderr, _('(locked)') - else: - print >> sys.stderr, _('(unlocked)') - mlist = config.db.list_manager.get(listname) if mlist is None: print >> sys.stderr, _('Unknown list: $listname') else: - atexit.register(exitfunc, mlist) + if VERBOSE: + print >> sys.stderr, _('Loaded list: $listname') LAST_MLIST = mlist # Try to import the module and run the callable. if func: @@ -107,7 +86,7 @@ the following from the command line: % bin/withlist -r listaddr mylist - Loading list: mylist (unlocked) + Loading list: mylist Importing listaddr ... Running listaddr.listaddr() ... [EMAIL PROTECTED] @@ -115,7 +94,7 @@ And you can print the list's request address by running: % bin/withlist -r listaddr.requestaddr mylist - Loading list: mylist (unlocked) + Loading list: mylist Importing listaddr ... Running listaddr.requestaddr() ... [EMAIL PROTECTED] @@ -136,15 +115,6 @@ and run this from the command line: % bin/withlist -l -r changepw mylist [EMAIL PROTECTED] foobar""")) - parser.add_option('-l', '--lock', - default=False, action='store_true', help=_("""\ -Lock the list when opening. Normally the list is opened unlocked (e.g. for -read-only operations). You can always lock the file after the fact by typing -'m.Lock()' - -Note that if you use this option, you should explicitly call m.Save() before -exiting, since the interpreter's clean up procedure will not automatically -save changes to the IMailingList object (but it will unlock the list).""")) parser.add_option('-i', '--interactive', default=None, action='store_true', help=_("""\ Leaves you at an interactive prompt after all other processing is complete. @@ -180,14 +150,12 @@ def main(): - global LAST_MLIST, LOCK, VERBOSE + global LAST_MLIST, VERBOSE parser, opts, args = parseargs() initialize(opts.config, not opts.quiet) VERBOSE = not opts.quiet - LOCK = opts.lock - # The default for interact is true unless -r was given if opts.interactive is None: if not opts.run: @@ -241,5 +209,5 @@ "The variable 'm' is the $listname mailing list") else: banner = interact.DEFAULT_BANNER - overrides = dict(m=LAST_MLIST, r=r) + overrides = dict(m=LAST_MLIST, r=r, flush=config.db.flush) interact.interact(upframe=False, banner=banner, overrides=overrides) === modified file 'Mailman/database/__init__.py' --- a/Mailman/database/__init__.py 2007-08-08 04:24:13 +0000 +++ b/Mailman/database/__init__.py 2007-10-11 03:22:03 +0000 @@ -56,13 +56,12 @@ self.requests = None def initialize(self): - from Mailman.LockFile import LockFile from Mailman.configuration import config from Mailman.database import model - # Serialize this so we don't get multiple processes trying to create the - # database at the same time. - lockfile = os.path.join(config.LOCK_DIR, '<dbcreatelock>') - with LockFile(lockfile): + from Mailman.lockfile import LockFile + # Serialize this so we don't get multiple processes trying to create + # the database at the same time. + with LockFile(os.path.join(config.LOCK_DIR, 'dbcreate.lck')): model.initialize() self.list_manager = ListManager() self.user_manager = UserManager() === modified file 'Mailman/database/usermanager.py' --- a/Mailman/database/usermanager.py 2007-07-01 15:51:09 +0000 +++ b/Mailman/database/usermanager.py 2007-10-11 03:22:03 +0000 @@ -25,7 +25,6 @@ from zope.interface import implements from Mailman import Errors -from Mailman.LockFile import LockFile from Mailman.configuration import config from Mailman.database.model import * from Mailman.interfaces import IUserManager === modified file 'Mailman/queue/archive.py' --- a/Mailman/queue/archive.py 2007-09-29 18:55:25 +0000 +++ b/Mailman/queue/archive.py 2007-10-11 03:22:03 +0000 @@ -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 @@ 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() === modified file 'Mailman/queue/bounce.py' --- a/Mailman/queue/bounce.py 2007-09-29 18:55:25 +0000 +++ b/Mailman/queue/bounce.py 2007-10-11 03:22:03 +0000 @@ -27,7 +27,6 @@ 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 === modified file 'Mailman/queue/command.py' --- a/Mailman/queue/command.py 2007-09-29 18:55:25 +0000 +++ b/Mailman/queue/command.py 2007-10-11 03:22:03 +0000 @@ -31,7 +31,6 @@ 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 @@ 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() === modified file 'Mailman/queue/incoming.py' --- a/Mailman/queue/incoming.py 2007-09-29 18:55:25 +0000 +++ b/Mailman/queue/incoming.py 2007-10-11 03:22:03 +0000 @@ -102,7 +102,6 @@ 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 @@ 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 @@ # 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): === modified file 'Mailman/queue/outgoing.py' --- a/Mailman/queue/outgoing.py 2007-09-29 18:55:25 +0000 +++ b/Mailman/queue/outgoing.py 2007-10-11 03:22:03 +0000 @@ -26,7 +26,6 @@ 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 === modified file 'Mailman/tests/test_lockfile.py' --- a/Mailman/tests/test_lockfile.py 2007-01-19 04:38:06 +0000 +++ b/Mailman/tests/test_lockfile.py 2007-10-11 03:22:03 +0000 @@ -22,7 +22,7 @@ import tempfile import unittest -from Mailman.LockFile import LockFile +from Mailman.lockfile import LockFile LOCKFILE_NAME = '.mm-test-lock' -- https://code.launchpad.net/~mailman-coders/mailman/3.0 You are receiving this branch notification because you are subscribed to it. To unsubscribe from this branch go to https://code.launchpad.net/~mailman-coders/mailman/3.0/+subscription/mailman-checkins. _______________________________________________ Mailman-checkins mailing list Mailman-checkins@python.org Unsubscribe: http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org