summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw2000-03-28 17:19:30 +0000
committerbwarsaw2000-03-28 17:19:30 +0000
commit3a22bfd7afcc99a5f2ee3bedde0f17c53c21e2bf (patch)
tree5e126d16d3271644f3b9c2751a8c4d591882f72d
parent936ba40f2ddc2b30c3e50ae35f5ff2a3da69f859 (diff)
downloadmailman-3a22bfd7afcc99a5f2ee3bedde0f17c53c21e2bf.tar.gz
mailman-3a22bfd7afcc99a5f2ee3bedde0f17c53c21e2bf.tar.zst
mailman-3a22bfd7afcc99a5f2ee3bedde0f17c53c21e2bf.zip
-rw-r--r--bin/withlist25
1 files changed, 23 insertions, 2 deletions
diff --git a/bin/withlist b/bin/withlist
index 3ddd9ed7f..2382d61b5 100644
--- a/bin/withlist
+++ b/bin/withlist
@@ -104,6 +104,22 @@ def usage(msg='', code=1):
sys.exit(code)
+def atexit():
+ """Unlock a locked list, but do not implicitly Save() it.
+
+ This does not get run if the interpreter exits because of a signal, or if
+ os._exit() is called. It will get called if an exception occurs though.
+ """
+ global m
+ if not m:
+ return
+ if m.Locked():
+ print 'Unlocking (but not saving) list:', m.internal_name()
+ m.Unlock()
+ print 'Finalizing'
+ del m
+
+
def main():
global m
@@ -131,8 +147,10 @@ def main():
# first try to open mailing list
print 'Loading list:', listname,
- if lock: print '(locked)'
- else: print '(unlocked)'
+ if lock:
+ print '(locked)'
+ else:
+ print '(unlocked)'
m = MailList(listname, lock=lock)
@@ -150,4 +168,7 @@ def main():
print 'Running %s.%s()' % (module, callable), '...'
r = getattr(mod, callable)(m)
+
+
+sys.exitfunc = atexit
main()