diff options
| author | Barry Warsaw | 2007-10-10 23:22:03 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2007-10-10 23:22:03 -0400 |
| commit | 1ad73a52bb9d82ef3af1e34ad9ef66ac2eda2909 (patch) | |
| tree | 7985eda24e60a39d58c54436e99f975610ee947d /Mailman/bin/gate_news.py | |
| parent | 15f9e73fdb96a145632e5916cc0073472c014c99 (diff) | |
| download | mailman-1ad73a52bb9d82ef3af1e34ad9ef66ac2eda2909.tar.gz mailman-1ad73a52bb9d82ef3af1e34ad9ef66ac2eda2909.tar.zst mailman-1ad73a52bb9d82ef3af1e34ad9ef66ac2eda2909.zip | |
Diffstat (limited to 'Mailman/bin/gate_news.py')
| -rw-r--r-- | Mailman/bin/gate_news.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/Mailman/bin/gate_news.py b/Mailman/bin/gate_news.py index da78b6068..6fc8139c6 100644 --- a/Mailman/bin/gate_news.py +++ b/Mailman/bin/gate_news.py @@ -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 optparse 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 @@ def process_lists(glock): # 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 @@ def main(): 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) |
