Exclusively lock a file to prevent other processes from reading it?

John Nagle nagle at animats.com
Wed May 5 00:19:35 EDT 2010


Philip Semanchuk wrote:
> 
> On May 4, 2010, at 5:37 PM, python at bdurham.com wrote:
> 
>> Is there a way to exclusively lock a file to prevent other
>> processes from reading it while we have it open?

    If you can use SQLite to store the data, it will deal with
your locking problems.  The pain of getting locking right has
already been dealt with by others.

    Classic lock files are iffy.  They're not race condition free
on NTFS, and all the junk needed to clean up lock files properly
after a crash is a headache.

				John Nagle



More information about the Python-list mailing list