1 |
This code looks like it attempts to remove self.lockdir from the |
2 |
lock_dirs_in_use list, but it doesn't seem to quite work: |
3 |
- it uses "for x in lock_dirs_in_use", but then indexes lock_dirs_in_use |
4 |
via the "i" variable |
5 |
- the "i" variable is set to 0, but then never incremented (looks like |
6 |
due to incorrect indentation) |
7 |
- the only way an entry would be deleted is if it happened to be in the |
8 |
first location of the list |
9 |
|
10 |
In the end, this looks like an ad-hoc implementation of the list .remove |
11 |
builtin, so just delete the code and use that. |
12 |
--- |
13 |
catalyst/lock.py | 10 ++-------- |
14 |
1 file changed, 2 insertions(+), 8 deletions(-) |
15 |
|
16 |
diff --git a/catalyst/lock.py b/catalyst/lock.py |
17 |
index c031258..25d2aa2 100644 |
18 |
--- a/catalyst/lock.py |
19 |
+++ b/catalyst/lock.py |
20 |
@@ -57,15 +57,9 @@ class LockDir(object): |
21 |
self.hardlock_paths={} |
22 |
|
23 |
def delete_lock_from_path_list(self): |
24 |
- i=0 |
25 |
try: |
26 |
- if LockDir.lock_dirs_in_use: |
27 |
- for x in LockDir.lock_dirs_in_use: |
28 |
- if LockDir.lock_dirs_in_use[i] == self.lockdir: |
29 |
- del LockDir.lock_dirs_in_use[i] |
30 |
- break |
31 |
- i=i+1 |
32 |
- except AttributeError: |
33 |
+ LockDir.lock_dirs_in_use.remove(self.lockdir) |
34 |
+ except ValueError: |
35 |
pass |
36 |
|
37 |
def islocked(self): |
38 |
-- |
39 |
2.5.2 |