Skip to contentSkip to conversation

KVM test: migration subtest: Handle case where session2 does not exist

PATCH New Lucas Meneghel Rodrigues 1 participant 1 message Nov 15, 2009 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM test: migration subtest: Handle case where session2 does not exist

In one of the code blocks of the migration test, a finally clause tries to send a command to a session. However, if we are not successful in actually creating a session, that object will hold None, which doesn't have an is_alive attribute, generating an unhandled exception. Fix that by checking if the session2 object is not None before trying to use the method is_alive()

---
 client/tests/kvm/tests/migration.py |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
client/tests/kvm/tests/migration.py +4 -3
index 7b80e51..21df1e2 100644
@@ -74,9 +74,10 @@ def run_migration(test, params, env):
 
     finally:
         # Kill the background process
-        if session2.is_alive():
-            session2.get_command_output(params.get("migration_bg_kill_command",
-                                                   ""))
+        if session2:
+            if session2.is_alive():
+                session2.get_command_output(
+                                    params.get("migration_bg_kill_command", ""))
 
     session2.close()
     session.close()
Signature · 1 line
1.6.2.5