multiple instance on Unix

Nigel King nigel.king at orthogonsystems.com
Thu Sep 30 10:17:59 EDT 2004


On 30 Sep 2004, at 14:11, C Ginger wrote:

> 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.

This was why I created a directory rather than a file since I thought 
this was supposed to be atomic.
>
> I think a better approach would be to use the shared memory option 
> (see man shmop). The idea here is that each invoked instance would get 
> back the same shared memory and use an appropriate atomic op to lock 
> the process. Of course doing this in pure Python might be a bit 
> difficult.

Thanks for all of the suggestions flooding in.

This all seems an unusual case of batteries not included.


Nigel King




More information about the Python-list mailing list