Commit f4f5226e authored by toshio's avatar toshio

Style cleanups for the prototype patch

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