------------------------------------------------------------
revno: 1045
committer: Mark Sapiro <[EMAIL PROTECTED]>
branch nick: 2.1
timestamp: Thu 2008-02-14 08:53:52 -0800
message:
Switchboard.py - Added code to catch exceptions thrown in unpickling .bak
files and preserve the file. This occurred when dequeue
of a large entry threw MemoryError, the runner died and
restarted, and then unpickling the .bak threw another
MemoryError.
modified:
Mailman/Queue/Switchboard.py
=== modified file 'Mailman/Queue/Switchboard.py'
--- a/Mailman/Queue/Switchboard.py 2008-01-03 04:25:11 +0000
+++ b/Mailman/Queue/Switchboard.py 2008-02-14 16:53:52 +0000
@@ -223,24 +223,33 @@
dst = os.path.join(self.__whichq, filebase + '.pck')
fp = open(src, 'rb+')
try:
- msg = cPickle.load(fp)
- data_pos = fp.tell()
- data = cPickle.load(fp)
- data['_bak_count'] = data.setdefault('_bak_count', 0) + 1
- fp.seek(data_pos)
- if data.get('_parsemsg'):
- protocol = 0
+ try:
+ msg = cPickle.load(fp)
+ data_pos = fp.tell()
+ data = cPickle.load(fp)
+ except Exception, s:
+ # If unpickling throws any exception, just log and
+ # preserve this entry
+ syslog('error', 'Unpickling .bak exception: %s\n'
+ + 'preserving file: %s', s, filebase)
+ self.finish(filebase, preserve=True)
else:
- protocol = 1
- cPickle.dump(data, fp, protocol)
- fp.truncate()
- fp.flush()
- os.fsync(fp.fileno())
+ data['_bak_count'] = data.setdefault('_bak_count', 0) + 1
+ fp.seek(data_pos)
+ if data.get('_parsemsg'):
+ protocol = 0
+ else:
+ protocol = 1
+ cPickle.dump(data, fp, protocol)
+ fp.truncate()
+ fp.flush()
+ os.fsync(fp.fileno())
+ if data['_bak_count'] >= MAX_BAK_COUNT:
+ syslog('error',
+ '.bak file max count, preserving file: %s',
+ filebase)
+ self.finish(filebase, preserve=True)
+ else:
+ os.rename(src, dst)
finally:
fp.close()
- if data['_bak_count'] >= MAX_BAK_COUNT:
- syslog('error', '.bak file max count, preserving file: %s',
- filebase)
- self.finish(filebase, preserve=True)
- else:
- os.rename(src, dst)
--
Stable, maintained release series
https://code.launchpad.net/~mailman-coders/mailman/2.1
You are receiving this branch notification because you are subscribed to it.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org