multiple instance on Unix

G. S. Hayes sjdevnull at yahoo.com
Thu Sep 30 20:32:04 CEST 2004


C Ginger <cginboston at hotmail.com> wrote in message news:<mailman.4132.1096549864.5135.python-list at python.org>...
> I know the approach to creating a lock file has been around a long time 
> but there are certain weaknesses to it. There are a number of race 
> conditions in it. For instance if process A detects the directory isn't 
> there it will attempt to create it. During that same time process B 
> might also not find it there - since A hasn't completed its create yet.

The code Nigel posted doesn't have this race.  It (properly) tries to
create the directory (doesn't look at whether the dir exists
beforehand) and checks for success or failure.  That is an atomic
operation.



More information about the Python-list mailing list