commit 98d43fde2764126910c23ac7cb7fe4c14e15c4a4
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Wed Jul 17 14:09:45 2013 +0200
Machine: handle timeout exception
Previously when a command timed out, the exception was handled too late
resulting in a message "Recieved an unknown exception...".
This commit adds handling of this exception. The timed out command is
then killed so that it doesn't leave a process running.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/Machine.py | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index d4348e2..1847adf 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -174,7 +174,14 @@ class Machine(object):
logging.debug("Setting timeout to \"%d\"", timeout)
signal.alarm(timeout)
- cmd_res = self._rpc_call("run_command", command)
+ try:
+ cmd_res = self._rpc_call("run_command", command)
+ except MachineError as exc:
+ if "bg_id" in command:
+ self._rpc_call("kill_command", command["bg_id"])
+ else:
+ self._rpc_call("kill_command", None)
+ cmd_res = {"passed": False, "err_msg": str(exc)}
signal.alarm(0)
signal.signal(signal.SIGALRM, prev_handler)
Show replies by date