Commit 294773ba authored by Valentin Samir's avatar Valentin Samir

[ldap_locks, lc_ldap] Ooups, erreur d'index / d'iteration

parent 1b76ba54
......@@ -508,8 +508,8 @@ class lc_ldap(ldap.ldapobject.LDAPObject, object):
except ldap_locks.LockError:
continue
else:
raise EnvironmentError('Aucun %s libre dans la plage [%d, %d]' %
(attr, plage[0], i))
raise EnvironmentError('Aucun %s libre dans la plage %s' %
(attr, realm))
else:
# On extrait seulement les valeurs des id qui nous intêressent dans une liste
nonfree = [ int(r[1].get(attr)[0]) for r in res if r[1].get(attr) ]
......
......@@ -172,11 +172,12 @@ class LdapLockHolder:
def check(self, Id='default', delai=0):
"""Vérifie que l'on a toujours tous nos locks"""
for item, value in self.locks[Id]:
host, pid, begin = self.getlock(item, value)
time_left = self.timeout - (time.time() - begin)
if time_left <= delai:
raise LockExpired("Le lock sur la donnée %r=%r à expiré" % (item, value, time_left))
for item, values in self.locks[Id].items():
for value in values:
host, pid, begin = self.getlock(item, value)
time_left = self.timeout - (time.time() - begin)
if time_left <= delai:
raise LockExpired("Le lock sur la donnée %r=%r à expiré" % (item, value, time_left))
def removelock(self, item, value, Id='default', force=False):
"""
......@@ -207,6 +208,9 @@ class LdapLockHolder:
return host, int(pid), float(begin)
except ldap.NO_SUCH_OBJECT:
raise LockNotFound()
except ldap.INVALID_DN_SYNTAX:
print '%s=%s,%s' % (item, value, LOCKS_DN)
raise
except ValueError as e:
self.removelock(item, value, Id, force=True)
raise LockNotFound()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment