Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #9576

Re: Looking for general advice on complex program

Date 2011-07-16 08:37 +1000
From Cameron Simpson <cs@zip.com.au>
Subject Re: Looking for general advice on complex program
References <ivq6ej$vpp$2@speranza.aioe.org>
Newsgroups comp.lang.python
Message-ID <mailman.1084.1310769466.1164.python-list@python.org> (permalink)

Show all headers | View raw


On 15Jul2011 16:03, Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> wrote:
| I remember reading that file locking doesn't work on network mounted
| drives (specifically nfs mounts), but you might be able to simply
| create a 'lock' (mydoc.xml.lock or the like) file for the XML doc in
| question.  If that file exists you could either hang or silently
| give up.  Not sure if that helps.

There are two approaches to this. Plain old make-a-file won't work - it
is racy (and as mentioned, you can't rely on the various lock
facilities).

You can create a file while your umask is 0777; it will be non-writable
immediately (no chmod required), preventing another attempt to make it.

My personal habit is to make a directory for the lock; mkdir
also can't happen twice to the same name, you don't need to fiddle you
umask (racy and annoying, and problematic if you're using multiple
threads), _and_ you can put meta info inside it, like pid files etc.

Cheers,
-- 
Cameron Simpson <cs@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

I had a wierd dream with Ken Thompson in it once.
        - George Politis <george@research.canon.com.au>

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Looking for general advice on complex program Josh English <Joshua.R.English@gmail.com> - 2011-07-15 12:47 -0700
  Re: Looking for general advice on complex program Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> - 2011-07-15 16:03 -0400
    Re: Looking for general advice on complex program Cameron Simpson <cs@zip.com.au> - 2011-07-16 08:37 +1000
    Re: Looking for general advice on complex program Chris Angelico <rosuav@gmail.com> - 2011-07-16 10:01 +1000
  Re: Looking for general advice on complex program geremy condra <debatem1@gmail.com> - 2011-07-16 14:08 -0400

csiph-web