locking files on Linux

andrea crotti andrea.crotti.0 at gmail.com
Fri Oct 19 08:15:25 EDT 2012


2012/10/18 Oscar Benjamin <oscar.j.benjamin at gmail.com>:
>
> The lock is cooperative. It does not prevent the file from being
> opened or overwritten. It only prevents any other process from
> obtaining the lock. Here you open the file with mode 'w' which
> truncates the file instantly (without checking for the lock).
>
>
> Oscar


Very good thanks now I understood, actually my problem was in the
assumption that it should fail when the lock is already taken, but by
default lockf just blocks until the lock is released.

It seems to work quite nicely so I'm going to use this..



More information about the Python-list mailing list