On 15Jul2011 16:03, Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9...@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 <c...@zip.com.au> DoD#743 http://www.cskk.ezoshosting.com/cs/ I had a wierd dream with Ken Thompson in it once. - George Politis <geo...@research.canon.com.au> -- http://mail.python.org/mailman/listinfo/python-list