This code looks like it attempts to remove self.lockdir from the
lock_dirs_in_use list, but it doesn't seem to quite work:
- it uses "for x in lock_dirs_in_use", but then indexes lock_dirs_in_use
via the "i" variable
- the "i" variable is set to 0, but then never incremented (looks like
due to incorrect indentation)
- the only way an entry would be deleted is if it happened to be in the
first location of the list
In the end, this looks like an ad-hoc implementation of the list .remove
builtin, so just delete the code and use that.
---
catalyst/lock.py | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/catalyst/lock.py b/catalyst/lock.py
index c031258..25d2aa2 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -57,15 +57,9 @@ class LockDir(object):
self.hardlock_paths={}
def delete_lock_from_path_list(self):
- i=0
try:
- if LockDir.lock_dirs_in_use:
- for x in LockDir.lock_dirs_in_use:
- if LockDir.lock_dirs_in_use[i] ==
self.lockdir:
- del LockDir.lock_dirs_in_use[i]
- break
- i=i+1
- except AttributeError:
+ LockDir.lock_dirs_in_use.remove(self.lockdir)
+ except ValueError:
pass
def islocked(self):
--
2.5.2