summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw1999-08-21 05:07:51 +0000
committerbwarsaw1999-08-21 05:07:51 +0000
commitf770c8f34026d4734b03c3e7a59ce75950da9f97 (patch)
treee64795f757178a3e610a73ea1fedffc77d04efd1
parent0977d08d1d2425e805a3c42c8c99ed44c49649e2 (diff)
downloadmailman-f770c8f34026d4734b03c3e7a59ce75950da9f97.tar.gz
mailman-f770c8f34026d4734b03c3e7a59ce75950da9f97.tar.zst
mailman-f770c8f34026d4734b03c3e7a59ce75950da9f97.zip
Extensive changes based on Jeremy Hylton's investigations. These
should considerably help the performance of the archiver. Specifically: ArchiveMail(): Create a lock file (and lock it), just after the fork. Jeremy observes that there is a race condition when many posts show up in a short amount of time. By creating a lock file we make sure that the separate archiver processes won't clobber each other. Use the new LockFile module. Move the (c)StringIO import to the top of the file.
-rw-r--r--Mailman/Archiver/Archiver.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/Mailman/Archiver/Archiver.py b/Mailman/Archiver/Archiver.py
index c890b5dd1..d44318a05 100644
--- a/Mailman/Archiver/Archiver.py
+++ b/Mailman/Archiver/Archiver.py
@@ -28,6 +28,13 @@ archival.
#
import sys, os, string
import errno
+import traceback
+
+try:
+ from cStringIO import StringIO
+except ImportError:
+ from StringIO import StringIO
+
from Mailman.Utils import reraise, mkdir
#
@@ -36,6 +43,7 @@ from Mailman.Utils import reraise, mkdir
from Mailman import Utils
from Mailman import Mailbox
from Mailman import mm_cfg
+from Mailman.LockFile import LockFile
@@ -184,8 +192,11 @@ class Archiver:
return
if os.fork():
return
- # archive to builtin html archiver
- import traceback
+ # archive to builtin html archiver. first grab the archiver lock
+ lockfile = os.path.join(mm_cfg.LOCK_DIR, self._internal_name) + \
+ '.archiver.lock'
+ lock = LockFile(lockfile, lifetime=60)
+ lock.lock()
try:
try:
if mm_cfg.ARCHIVE_TO_MBOX in [1, 2]:
@@ -193,10 +204,8 @@ class Archiver:
if mm_cfg.ARCHIVE_TO_MBOX == 1:
# Archive to mbox only.
os._exit(0)
- try:
- from cStringIO import StringIO
- except ImportError:
- from StringIO import StringIO
+ # from this point on, we're doing all the expensive archiving
+ # work.
txt = msg.unixfrom
for h in msg.headers:
txt = txt + h
@@ -216,6 +225,7 @@ class Archiver:
except:
traceback.print_exc(file=sys.stderr)
finally:
+ lock.unlock()
# need this or we'll never see the error messages!
sys.stderr.flush()
os._exit(0)