How to safely maintain a status file
steve+comp.lang.python at pearwood.info
Fri Jul 13 03:52:12 CEST 2012
On Thu, 12 Jul 2012 15:05:26 +0200, Christian Heimes wrote:
> You need to flush the data to disk as well as the metadata of the file
> and its directory in order to survive a system crash. The close()
> syscall already makes sure that all data is flushed into the IO layer of
> the operating system.
And some storage devices (e.g. hard drives, USB sticks) don't actually
write data permanently even when you sync the device. They just write to
a temporary cache, then report that they are done (liar liar pants on
fire). Only when the cache is full, or at some random time at the
device's choosing, do they actually write data to the physical media.
The result of this is that even when the device tells you that the data
is synched, it may not be.
More information about the Python-list