summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw1999-07-07 21:54:48 +0000
committerbwarsaw1999-07-07 21:54:48 +0000
commitbd61ac47a20570136bc1a4bde9ac81cd9e9bd2fd (patch)
tree9be7ba9f495c7ac359feace78cf524918640c533
parent3097b567e6313b91ba8ad3892d0123f22d942c15 (diff)
downloadmailman-bd61ac47a20570136bc1a4bde9ac81cd9e9bd2fd.tar.gz
mailman-bd61ac47a20570136bc1a4bde9ac81cd9e9bd2fd.tar.zst
mailman-bd61ac47a20570136bc1a4bde9ac81cd9e9bd2fd.zip
Move the locking stuff to here from OutgoingQueue.processQueue().
This way, I can wrap the body of the code in a try/finally so the lock is definitely released should something bad happen.
-rw-r--r--cron/run_queue17
1 files changed, 16 insertions, 1 deletions
diff --git a/cron/run_queue b/cron/run_queue
index 86ca66367..a6082c16f 100644
--- a/cron/run_queue
+++ b/cron/run_queue
@@ -20,12 +20,27 @@
# messages pending delivery on the mailman mail queue.
+import os
import sys
import paths
from Mailman import OutgoingQueue
+from Mailman import flock
+from Mailman import mm_cfg
# Work around known problems with some RedHat cron daemons
import signal
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
-OutgoingQueue.processQueue()
+def main():
+ path = os.path.join(mm_cfg.LOCK_DIR, 'mmqueue_run.lock')
+ lockfile = flock.FileLock(path,
+ # running the queue can take a long time
+ hung_timeout=14400)
+ lockfile.lock()
+ try:
+ OutgoingQueue.processQueue()
+ finally:
+ lockfile.unlock()
+
+
+main()