mailbox.mbox not locking mbox properly
Tim Roberts
timr at probo.com
Tue Aug 10 02:28:16 EDT 2010
tinnews at isbd.co.uk wrote:
>
>I'm using the python mailbox class in a script that processes incoming
>mail and delivers it to various mbox format mailboxes. It appears
>that, although I am calling the lock method on the destination before
>writing to the mbox and calling unlock afterwards the locking isn't
>working correctly.
>...
>So it seems that python's mailbox class locking isn't playing nicely
>with mutt's mailbox locking whereas postfix's locking does work
>correctly.
Correct. The "dest.flush()" method creates a temporary file, copies the
entire modified mailbox into it, removed the original file, and renames the
temp file into place.
The Postfix MDA, like most MDAs, just opens the existing file and appends
the new data to it.
>Has anyone seen this problem before, and/or do I need to anything more
>than the following for the locking to work correctly:-
It's not the locking. It's the flush mechanism. The mbox class doesn't
know that the ONLY thing you did was an append. You might have modified
other messages in the middle. If you want to do an append, you'll need to
write your own subclass of mbox.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list