Commit f4f5226e authored by toshio's avatar toshio

Style cleanups for the prototype patch

parent cd158259
...@@ -25,18 +25,18 @@ __all__ = [ ...@@ -25,18 +25,18 @@ __all__ = [
] ]
import os
import errno
import hashlib import hashlib
import logging
from base64 import b32encode from base64 import b32encode
from datetime import timedelta from datetime import timedelta
import errno
import logging
from mailbox import Maildir from mailbox import Maildir
import os
from urlparse import urljoin from urlparse import urljoin
from zope.interface import implements
from flufl.lock import Lock, TimeOutError from flufl.lock import Lock, TimeOutError
from zope.interface import implements
from mailman.config import config from mailman.config import config
from mailman.interfaces.archiver import IArchiver from mailman.interfaces.archiver import IArchiver
...@@ -100,17 +100,19 @@ class Prototype: ...@@ -100,17 +100,19 @@ class Prototype:
mail_box = Maildir(list_dir, create=True, factory=None) mail_box = Maildir(list_dir, create=True, factory=None)
# Lock the maildir as Maildir.add() is not threadsafe # Lock the maildir as Maildir.add() is not threadsafe
lock = Lock(os.path.join(config.LOCK_DIR, '%s-maildir.lock' % mlist.fqdn_listname)) lock = Lock(os.path.join(config.LOCK_DIR, '%s-maildir.lock'
try: % mlist.fqdn_listname))
lock.lock(timeout=timedelta(seconds=1)) with lock:
# Add the message to the Maildir try:
# Message_key could be used to construct the file path if lock.lock(timeout=timedelta(seconds=1))
# necessary: # Add the message to the Maildir
# os.path.join(archive_dir,mlist.fqdn_listname,'new',message_key) # Message_key could be used to construct the file path if
message_key = mail_box.add(message) # necessary::
except TimeOutError: # os.path.join(archive_dir, mlist.fqdn_listname, 'new',
# log the error and go on # message_key)
elog.error('Unable to lock archive for %s, discarded message: %s' % (mlist.fqdn_listname, message.get('message-id', '<unknown>'))) message_key = mail_box.add(message)
finally: except TimeOutError:
# unlock the maildir # log the error and go on
lock.unlock(unconditionally=1) elog.error('Unable to lock archive for %s, discarded'
' message: %s' % (mlist.fqdn_listname,
message.get('message-id', '<unknown>')))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment