diff options
| author | bwarsaw | 2003-09-12 13:47:12 +0000 |
|---|---|---|
| committer | bwarsaw | 2003-09-12 13:47:12 +0000 |
| commit | eac31fc24a64a7a4a3a4ba3d412effb3e8ea519d (patch) | |
| tree | 7b2cc996e1c34b592b782f36a3b48a4a21774c5f | |
| parent | 021832d89f23c62b0626679b3d6e868f5e981263 (diff) | |
| download | mailman-eac31fc24a64a7a4a3a4ba3d412effb3e8ea519d.tar.gz mailman-eac31fc24a64a7a4a3a4ba3d412effb3e8ea519d.tar.zst mailman-eac31fc24a64a7a4a3a4ba3d412effb3e8ea519d.zip | |
| -rw-r--r-- | Mailman/Queue/Switchboard.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/Mailman/Queue/Switchboard.py b/Mailman/Queue/Switchboard.py index 77179fcfe..4a56223d4 100644 --- a/Mailman/Queue/Switchboard.py +++ b/Mailman/Queue/Switchboard.py @@ -50,7 +50,20 @@ from Mailman.Logging.Syslog import syslog # 20 bytes of all bits set, maximum sha.digest() value shamax = 0xffffffffffffffffffffffffffffffffffffffffL -SAVE_MSGS_AS_PICKLES = 1 +try: + True, False +except NameError: + True = 1 + False = 0 + +# This flag causes Mailman to fsync() the file after writing and flushing its +# contents. While this ensures the data is written to disk, avoiding data +# loss, it is a huge performance killer. +SYNC_AFTER_WRITE = False +# This flag causes messages to be written as pickles (when True) or text files +# (when False). Pickles are more efficient because the message doesn't need +# to be re-parsed every time it's unqueued, but pickles are not human readable. +SAVE_MSGS_AS_PICKLES = True @@ -127,6 +140,7 @@ class _Switchboard: tmpfile = dbfile + '.tmp' self._ext_write(tmpfile, data) os.rename(tmpfile, dbfile) + return filebase def dequeue(self, filebase): # Calculate the .db and .msg filenames from the given filebase. @@ -239,6 +253,10 @@ class MarshalSwitchboard(_Switchboard): else: dict[attr] = repr(fval) marshal.dump(dict, fp) + # Make damn sure that the data we just wrote gets flushed to disk + fp.flush() + if SYNC_AFTER_WRITE: + os.fsync(fp.fileno()) fp.close() def _ext_read(self, filename): @@ -307,6 +325,10 @@ class ASCIISwitchboard(_Switchboard): os.umask(omask) for k, v in dict.items(): print >> fp, '%s = %s' % (k, repr(v)) + # Make damn sure that the data we just wrote gets flushed to disk + fp.flush() + if SYNC_AFTER_WRITE: + os.fsync(fp.fileno()) fp.close() def _ext_read(self, filename): |
