Re: fcntl example
Tue, 03 May 1994 09:16:05 +0200

> I had a need for a way to do some simple file locking which was not
> provided with the builtin file object (why not??). I found some old
> postings to this list talking about fcntl, but there were no examples.
> In case anyone else is in the same boat here is the module
> that I wrote to handle simple locking of full files. This does not
> implement record locking but it is pretty easy to see how to extend it
> to do that if you need to.

Thanks for the contribution...

File locking is not in the standard file object because it's not the
same across different UNIX platforms. Now that we have the configure
script, I suppose someone could figure out how to do it on SYSV and
BSD and add some ifdef'ed code that implements simple file-level
locking using a consistent interface to Python users. (Could a BSD
version be done in Python?)

--Guido van Rossum, CWI, Amsterdam <>
URL: <>