473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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
0 1212

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
2
by: Cathy Hui | last post by:
I am trying to install MySQL-Python 0.9.1 on my Solaris 8 system. The system has Python 2.3.3 and Mysql 4.0.21 installed. This is where I downloaded the distribution of the Mysql-python...
0
by: Steve McWilliams | last post by:
Hello, I am relatively new to MySql (4.0.14) but I have read through the relevent documentation and am still confused about how row level locking behaves with InnoDB tables. I created a...
6
by: Robert Blackwell | last post by:
I want to make a scheduled task in windows to do a mysqldump. Someone gave me this .bat to run but I'm not able to get it to work. REM @echo off for /f "tokens=1" %%i in ('date /t') do set...
2
by: Roopesh | last post by:
Hi, In my mod_python project I am using mysql as the database. There is table card in which unique cards are stored. When a user request comes he has to get a unique card. In this situation I want...
0
by: Andrey | last post by:
HI i have a newbie question about the file() function. I have 2 daemons running on my linux box. 1 will record the IDs to a file - logs.txt other 1 will open this file, read the IDs, and then...
1
by: Steve Ametjan | last post by:
I've been trying to get MySQL-python to install on Leopard for the past couple of days, and I keep running into relatively the same error. I'm hoping that someone on this list will be able to...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.