transaction-like file operations

Gerson Kurz moc.q-dnan-p at p-nand-q.com
Wed Aug 7 05:27:45 EDT 2002


I am working on a python program that will run on an embedded
ppc-linux system. If, during a file write operation (to flash memory),
the machine is powered off, the file gets corrupted, and is lost on
the next reboot. (I cannot prevent the user from powering off the
machine - there is no display, nor any indication if the system is
right now writing to disk or not. Its an embedded system, after all).

So, what I need is a transaction-like file operation, that allows me
to either write the file completely, or keep the old file (so that at
every point there is at least one set of data available).

I have made a "homegrown" solution that includes writing to a backup
file first, then doing two rename operations. I wonder if there exists
a standard class for transaction-like file operations in python?
[Note: a database is not an option]





More information about the Python-list mailing list