Petri Lehtinen added the comment: Attaching a patch that changes all single-file mailboxes to be rewritten in-place instead of rewriting and renaming. The patch doesn't add an option, because IMO this should be the default behavior.
In addition to solving the locking problems, this makes it significantly faster and less disk space consuming to remove or replace messages in very large mailbox files, because the whole mailbox is not rewritten. With this patch, the code now writes messages to a temporary file, starting from the first changed message to the end of the mailbox file. After this, the contents of the temporary file are copied back to the mailbox file and the mailbox file is truncated to the correct length. Care is taken that the process can be restarted if a crash (e.g. KeyboardInterrupt) occurs before starting to copy the changes back to the mailbox file, by altering self._toc and self._pending at the right moment. I'm not sure whether this would be a bug fix or a new feature. Suggestions? ---------- keywords: +needs review, patch stage: -> patch review title: Add an option to always rewrite single-file mailboxes in-place. -> Always rewrite single-file mailboxes in-place _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15122> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com