multiple instance on Unix
Jeremy Jones
zanesdad at bellsouth.net
Wed Sep 29 14:23:22 EDT 2004
Batista, Facundo wrote:
>
> #- If so, you could do something like this:
> #-
> #- import time
> #- import os
> #- waiting_for_lock = 1
> #-
> #- while waiting_for_lock:
> #- try:
> #- os.mkdir('/tmp/foo')
> #- waiting_for_lock = 0
> #- except OSError:
> #- print "could not create directory"
> #- time.sleep(1)
> #- #do whatever you need one and only one process to do...
>
> If you don't have the permissions to write in /tmp this will fail.
>
> . Facundo
>
Actually, it won't. It'll keep spinning and spinning and will never
acquire the lock. You won't have _any_ processes stepping on each other :-)
Of course, you are correct. This was just a simple piece of example
code. I left it to the OP to figure out what directory he can and can't
write in and adjust accordingly - if he even desired to use this example
at all.....
Jeremy Jones
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20040929/c9794813/attachment.html>
More information about the Python-list
mailing list