From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id BAFEB13888F for ; Tue, 6 Oct 2015 06:44:46 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0BA38E07F0; Tue, 6 Oct 2015 06:44:46 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 95D94E07F0 for ; Tue, 6 Oct 2015 06:44:45 +0000 (UTC) Received: from professor-x (S010634bdfa9ecf80.vc.shawcable.net [96.49.31.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dolsen) by smtp.gentoo.org (Postfix) with ESMTPSA id 4EA75340831 for ; Tue, 6 Oct 2015 06:44:44 +0000 (UTC) Date: Mon, 5 Oct 2015 23:43:54 -0700 From: Brian Dolbec To: gentoo-catalyst@lists.gentoo.org Subject: Re: [gentoo-catalyst] [PATCH] lock: rewrite delete_lock_from_path_list Message-ID: <20151005234354.3073eb91.dolsen@gentoo.org> In-Reply-To: <1444104354-15959-1-git-send-email-vapier@gentoo.org> References: <1444104354-15959-1-git-send-email-vapier@gentoo.org> Organization: Gentoo Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archives-Salt: 25d83883-0c52-4fab-bee7-a6eea880e5bf X-Archives-Hash: 796c181b2728be20db39e2422b9460f1 On Tue, 6 Oct 2015 00:05:54 -0400 Mike Frysinger wrote: > 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): great, Thanks... -- Brian Dolbec