Can't get exclusive file lock when safely renaming a file

Jeffrey Straszheim jstraszheim at comcast.net
Sat Dec 6 22:42:08 CET 2008


Steven D'Aprano wrote:
> I'm trying to safely rename a file without over-writing any existing 
> files, and I've run into a problem with file locks. Here's a naive way of 
> renaming without over-writing
By default on a Linux filesystem, flock() gives you an _advisory_ lock.  
Other processes can touch the file unless they explicitly check the lock.

Try

  man mount  (see under the -o mand)

and

  man fcntl (see under file locking)

Jeffrey Straszheim




More information about the Python-list mailing list