How to determine if a file is busy?

Andreas Kostyrka andreas at kostyrka.org
Fri Oct 8 08:59:02 EDT 2004


On Fri, Oct 08, 2004 at 01:54:03PM +0200, Alex Martelli wrote:
> 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.
Then the consumer of that file should remove it afterwards.

Andreas



More information about the Python-list mailing list