[mhonarc] run mhonarc concurrently with updating the gzip mbox



commit c2f3b2c99c55f558f5d83ba36f8ad0856c74f5dc
Author: Olav Vitters <olav vitters nl>
Date:   Thu Feb 14 10:05:59 2013 +0100

    run mhonarc concurrently with updating the gzip mbox

 archive.py |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/archive.py b/archive.py
index 221bf79..09c8deb 100755
--- a/archive.py
+++ b/archive.py
@@ -110,17 +110,21 @@ class Archiver:
                                   '-definevar', 'ARCHDATE=%s LISTNAME=%s' % (archivepath, self.listname),
                                   '-quiet', newmsgs.name]
 
-                subprocess.call(cmd, stdout=error_fd, stderr=subprocess.STDOUT)
+                # Already start mhonarc in the background
+                p = subprocess.Popen(cmd, stdout=error_fd, stderr=subprocess.STDOUT)
 
-            # Append message(s) to mbox (possibly gzipped)
-            if os.path.exists("%s.txt" % path):
-                archivedmsgs = open("%s.txt" % path, 'ab')
-            else:
-                archivedmsgs = gzip.GzipFile("%s.txt.gz" % path, 'ab')
+                # Append message(s) to mbox (possibly gzipped)
+                if os.path.exists("%s.txt" % path):
+                    archivedmsgs = open("%s.txt" % path, 'ab')
+                else:
+                    archivedmsgs = gzip.GzipFile("%s.txt.gz" % path, 'ab')
 
-            newmsgs.seek(0)
-            shutil.copyfileobj(newmsgs, archivedmsgs)
-            archivedmsgs.close()
+                newmsgs.seek(0)
+                shutil.copyfileobj(newmsgs, archivedmsgs)
+                archivedmsgs.close()
+
+                # Now wait for mhonarc to finish
+                p.wait()
         finally:
             # Always ensure newmsgs is cleared
             newmsgs.seek(0)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]