From: Ondrej Lichtner <olichtne(a)redhat.com>
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>
---
lnst/Controller/Machine.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
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)
--
1.8.1.4