avoid script running twice

Nick Craig-Wood nick at craig-wood.com
Mon Jun 18 15:30:05 EDT 2007


Robin Becker <robin at reportlab.com> wrote:
>  I looked at the temporary files idea, but I'm not certain about the exact 
>  details. Normally your create a file and then remove it whilst keeping the file 
>  handle; that allows your program to write to it whilst guaranteeing that it will 
>  vanish when you die, but this has to be a named file so that the second instance 
>  can check for it. Doesn't that prevent it from being already
>  removed?

No

> My unix experience is long, but fairly primitive.

Locking with files alone is racy..

You need flock under unix (this recipe shows windows flock equivalent also)

  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203

or use the directory idea I posted in another post.

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list