Section critique non bloquante
darcs-hash:20041205133447-d1718-952ffc9db50a4b41190f9be0565e416d99cbaf4a.gz
This commit is contained in:
parent
bd4e952af8
commit
d81797c847
1 changed files with 11 additions and 3 deletions
|
@ -32,9 +32,17 @@ def make_lock(lock_name, lock_comment='',nowait=1, quiet=False) :
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
if e.errno not in [errno.EACCESS, errno.EAGAIN]:
|
if e.errno not in [errno.EACCESS, errno.EAGAIN]:
|
||||||
raise
|
raise
|
||||||
# La procédure de lock est deja en cours d'execution, on essaie un peu plus tard
|
if nowait:
|
||||||
time.sleep(0.5)
|
if quiet:
|
||||||
return make_lock(lock_name, lock_comment)
|
# On va plutot lever une exception
|
||||||
|
raise AssertionError('In critical section')
|
||||||
|
else:
|
||||||
|
sys.stderr.write('\tpropriétaire : inconnu\n\tpid : inconnu\n\tdémarré depuis inconnu\n')
|
||||||
|
sys.exit(254)
|
||||||
|
else:
|
||||||
|
# La procédure de lock est deja en cours d'execution, on essaie un peu plus tard
|
||||||
|
time.sleep(0.5)
|
||||||
|
return make_lock(lock_name, lock_comment)
|
||||||
|
|
||||||
if os.path.isfile(lock_file) :
|
if os.path.isfile(lock_file) :
|
||||||
### Lock existant
|
### Lock existant
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue