low-end persistence strategies?

John Lenton john at grulic.org.ar
Fri Feb 18 09:43:03 EST 2005


On Thu, Feb 17, 2005 at 10:20:58PM -0800, Michele Simionato wrote:
> Ok, I have yet another question: what is the difference
> between fcntl.lockf  and fcntl.flock? The man page of
> my Linux system says that flock is implemented independently
> of fcntl, however it does not say if I should use it in preference
> over fcntl or not.

it depends on what you want to do: as the manpages say, flock is
present on most Unices, but lockf is POSIX; flock is BSD, lockf is
SYSV (although its in XPG4.2, so you have it on newer Unices of any
flavor); on Linux, lockf works over NFS (if the server supports it),
and gives you access to mandatory locking if you want it. You can't
mix lockf and flock (by this I mean: you can get a LOCK_EX via flock
and via lockf on the same file at the same time).

So: use whichever you feel more comfortable with, although if you are
pretty confident your program will run mostly on Linux there is a bias
towards lockf given its extra capabilities there.

-- 
John Lenton (john at grulic.org.ar) -- Random fortune:
¡¡  QQuuiittaa  eell  LLooccaall  EEcchhoo,,  MMaannoolloo  !!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20050218/f1072bf6/attachment.sig>


More information about the Python-list mailing list