How to determine if a file is busy?

Alex Martelli aleaxit at yahoo.com
Fri Oct 8 07:54:03 EDT 2004


Benjamin Niemann <b.niemann at betternet.de> wrote:

> How about writing the data to a file 'mydata.new' and when you are finished,
> delete 'mydata' and rename 'mydata.new' to 'mydata'.
> This way the python script will always get 'complete' files (and sometimes no
> file at all, when it come in between rm and mv ...)

I believe that 'mv' on Mac OS X, within a normal filesystem, is an
atomic operation anyway -- so, so need to rm first then mv.  On the
other hand, this would give no intrinsic guarantee that the datafile
previously produced HAS been consumed/recorded before it's removed.


Alex



More information about the Python-list mailing list