467,130 Members | 1,418 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,130 developers. It's quick & easy.

Python and file locking - NFS or MySQL?

Hi all...

...I've got a Python script running on a bunch of boxen sharing some
common NFS-exported space. I need (not want :) to lock files for
writing, and I need (not want :) to do it safely (i.e. atomically).
I'm doing this in Linux; NFS4 is available. As I understand it, my
options are:

1. Python's fcntl() is an interface to the fcntl(2) system call,
which is claimed to work "mostly" over NFS v >= 3.

2. open(2) is atomic on a local FS, I've read discussions that imply
that link(2) is atomic over NFS (is it?), so I can link from local
lockfile to remote target atomically. I don't grok this; open(2) +
link(2) + stat(2) == 3 calls on my fingers. HTH is this supposed to
work?

3. Atomically update a MySQL database indicating that the file is
locked - MySQL has atomic transactions now, right? And how good is
the Python MySQL API - IIRC Perl didn't have atomic transactions last
year; will this work in contemporary Python?

I've got a while (several weeks) to chew this problem over (my current
implementation is ``assert("Poof! File locked")'').

What are my options for safely locking files via NFS? I don't want to
get involved with NLM as my impression is it's being buggy and
unwieldy. Thanks in advance!
I was present at an undersea, unexplained mass sponge migration.
--
Christopher DeMarco <cm*@alephant.net>
Alephant Systems (http://alephant.net)
PGP public key at http://pgp.alephant.net
+1 412 708 9660

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDEyUdm4cw+C52z1wRAgsfAJ4hu824jKJMmueigt0Ud7 74SV5ZZACfdZZh
YUz2ZGqiWxtowfY2gN2tKMk=
=1Vu2
-----END PGP SIGNATURE-----

Aug 29 '05 #1
  • viewed: 1005
Share:

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Andrew Dalke | last post: by
2 posts views Thread by Cathy Hui | last post: by
reply views Thread by Steve McWilliams | last post: by
6 posts views Thread by Robert Blackwell | last post: by
2 posts views Thread by Roopesh | last post: by
1 post views Thread by Steve Ametjan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.