[DB-SIG] Q: database integrity, flush and corrupted files....
M.-A. Lemburg
mal@lemburg.com
Fri, 03 Jan 2003 00:25:20 +0100
Michael Scharf wrote:
> Hi,
>
> I am writing a little disk based hashset (like bsddb or gdbm).
You do know about mxBeeBase, do you ?
> I am trying to find info about information about what
> happens in the worst case if the application is killed in
> the wrong moment (e.g. in the middle of a flush). In
> particular: if I do:
>
> f.write(x)
> f.write(y)
>
> can I assume that when y gets flushed that x has been flushed?
No; flushing has to be done explicitly using f.flush() for this.
> If I do:
>
> pos=f.tell()
> f.write(x)
> f.seek(pos-len(x)-len(y)) # going before x
> f.write(y)
>
> Do I have to expect that y might be flushed before x?
>
> Or is auto-flushing completely random (I am talking
> about windows)?
Flushing usually refers to writing line buffers out to the
disk. Whether the file system does write-through or not
depends on the settings of the file system. It also depends
on how you open the file, ie. buffered or not.
> Does anybody know a pointer where I can read about this?
man fflush and the Python docs on files and the os module.
--
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting: http://www.egenix.com/
Python Software: http://www.egenix.com/files/python/