Gentoo Archives: gentoo-catalyst

From: Brian Dolbec <dolsen@g.o>
To: gentoo-catalyst@l.g.o
Subject: Re: [gentoo-catalyst] [PATCH] lock: rewrite delete_lock_from_path_list
Date: Tue, 06 Oct 2015 06:44:46
Message-Id: 20151005234354.3073eb91.dolsen@gentoo.org
In Reply to: [gentoo-catalyst] [PATCH] lock: rewrite delete_lock_from_path_list by Mike Frysinger
1 On Tue, 6 Oct 2015 00:05:54 -0400
2 Mike Frysinger <vapier@g.o> wrote:
3
4 > This code looks like it attempts to remove self.lockdir from the
5 > lock_dirs_in_use list, but it doesn't seem to quite work:
6 > - it uses "for x in lock_dirs_in_use", but then indexes
7 > lock_dirs_in_use via the "i" variable
8 > - the "i" variable is set to 0, but then never incremented (looks
9 > like due to incorrect indentation)
10 > - the only way an entry would be deleted is if it happened to be in
11 > the first location of the list
12 >
13 > In the end, this looks like an ad-hoc implementation of the
14 > list .remove builtin, so just delete the code and use that.
15 > ---
16 > catalyst/lock.py | 10 ++--------
17 > 1 file changed, 2 insertions(+), 8 deletions(-)
18 >
19 > diff --git a/catalyst/lock.py b/catalyst/lock.py
20 > index c031258..25d2aa2 100644
21 > --- a/catalyst/lock.py
22 > +++ b/catalyst/lock.py
23 > @@ -57,15 +57,9 @@ class LockDir(object):
24 > self.hardlock_paths={}
25 >
26 > def delete_lock_from_path_list(self):
27 > - i=0
28 > try:
29 > - if LockDir.lock_dirs_in_use:
30 > - for x in LockDir.lock_dirs_in_use:
31 > - if
32 > LockDir.lock_dirs_in_use[i] == self.lockdir:
33 > - del
34 > LockDir.lock_dirs_in_use[i]
35 > - break
36 > - i=i+1
37 > - except AttributeError:
38 > + LockDir.lock_dirs_in_use.remove(self.lockdir)
39 > + except ValueError:
40 > pass
41 >
42 > def islocked(self):
43
44 great, Thanks...
45
46 --
47 Brian Dolbec <dolsen>