From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Goldish Subject: Re: [Autotest PATCH] KVM test: No need close session when login timeout Date: Fri, 25 Dec 2009 08:28:18 -0500 (EST) Message-ID: <1816815221.2189471261747698769.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com> References: <843369727.2189451261747394285.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, autotest@test.kernel.org To: Amos Kong Return-path: Received: from mx1.redhat.com ([209.132.183.28]:50257 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752074AbZLYN2U (ORCPT ); Fri, 25 Dec 2009 08:28:20 -0500 In-Reply-To: <843369727.2189451261747394285.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: ----- "Amos Kong" wrote: > If login timeout, wait_for() returned 'None' and assigned to > 'session'. > When call session.close(), this prlblem was caused: > "AttributeError: 'NoneType' object has no attribute 'close'" > > Signed-off-by: Amos Kong > --- > client/tests/kvm/tests/timedrift_with_migration.py | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) > > diff --git a/client/tests/kvm/tests/timedrift_with_migration.py > b/client/tests/kvm/tests/timedrift_with_migration.py > index a012db3..0b93183 100644 > --- a/client/tests/kvm/tests/timedrift_with_migration.py > +++ b/client/tests/kvm/tests/timedrift_with_migration.py > @@ -76,7 +76,8 @@ def run_timedrift_with_migration(test, params, > env): > time_filter_re, > time_format) > > finally: > - session.close() > + if session != None: > + session.close() Agreed, but we can make this simply: if session: session.close() There's no need to explicitly check for None (and if there was, the preferred syntax would be 'is not None' rather than '!= None'). Also, just to be safe, we should make the same modification to timedrift_with_reboot.py. We can also consider removing the try..finally clauses altogether because sessions are now closed automatically when they're no longer needed. > > # Report results > host_delta = ht1 - ht0 > -- > 1.5.5.6 > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html