[Mailman-Developers] Outgoin queue sugestion

Dan Ohnesorg, admin of POWER Dan@feld.cvut.cz
Sun, 27 Sep 1998 22:08:43 +0200

On 26 Sep 98, at 18:02, Scott wrote:

> I personally like the idea of locking the files more than I like the
> idea of a daemon delivering queued mail because there will always be
> the worry that something accidentally kills the daemon process while
> no admin is around.
> Lock timeouts sound like a good solution and are already available in
> the file locking module.

So I have made it as follows. I haven't used flock module, 
becouse I think it is not good for this situacion. We can use it 
when there is reorganized code in Utis and OutgoinQueue, so it 
is too distributed. 
I haven't made backup before modifing my copy, so I cannot 
send diffs. My mailman is very different from oficial becouse it 
containst features like DSN, administrativ via filter, character set 
conversion .... and so I cannot made diff to clean distribution.

Modification is very short. First in Utils.py

def TrySMTPDelivery(recipient, sender, text, queue_entry):
 is on end added

    if failure:
        from Logging.StampedLogger import StampedLogger
        l = StampedLogger("smtp-failures", "TrySMTPDelivery", immediate=1)
        l.write("To %s:\n" % recipient)
        l.write("\t %s / %s\n" % (failure[0], failure[1]))
+        import os, re
+        lock = re.sub('mm_q\.','mm_l\.',queue_entry)
+        os.unlink(lock)

And in OutgoingQueue

def dequeueMessage(msg):
+    import os, re
+    lock = re.sub('mm_q\.','mm_l\.',msg)
+     os.unlink(lock)
     from Logging.StampedLogger import StampedLogger
     l = StampedLogger("queue", "DequeueMessage", immediate=1)
     l.write("Cannot remove:\t %s\n" % msg)

def processQueue():
+    import os, re
    files = os.listdir(mm_cfg.DATA_DIR)
    for file in files:
        if TEMPLATE <> file[:len(TEMPLATE)]:
        full_fname = os.path.join(mm_cfg.DATA_DIR, file)
+        lock = re.sub('mm_q\.','mm_l\.',full_fname)
+        existence = os.stat(lock)
+        if not(S_ISREG(existence)):
+          continue
+        l = open(lock,"a+")
+        l.write(os.getpid()) 
+        l.close()
        f = open(full_fname,"r")
        recip,sender,text = marshal.load(f)
        import Utils

DD   DD                Dan Ohnesorg, supervisor on POWER     
DD  OOOO               Dan@feld.cvut.cz
DD OODDOO              Dep. of Power Engineering
DDDDDD OO              CTU FEL Prague, Bohemia
   OO  OO              work: +420 2 24352785;+420 2 24972109
    OOOO               home: +420 311 679679;+420 311 679311
Neodkladej na zitrek, co dnes mohou udelat jini.