commit d65e7193d347dd46fcecd7de15f457c6b59a78a8
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Mar 29 14:03:18 2013 +0100
NetTestSlave: add handling for exception messages
If an exception is raised in a command a message of type "exception" is
sent to the slave server. This commit adds support for correct handling
of such messages.
I also added an additional field to the exception message that can be
used to identify the command from which the message arrived. This is
used both in the log message created and to correctly remove the command
after it's failed.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
lnst/Common/NetTestCommand.py | 1 +
lnst/Slave/NetTestSlave.py | 9 +++++++++
2 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index 146401e..2ce9b67 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -126,6 +126,7 @@ class NetTestCommand:
except:
type, value, tb = sys.exc_info()
result = {"type": "exception",
+ "cmd_id": self._id,
"Exception":
''.join(traceback.format_exception(type,
value, tb))}
send_data(self._write_pipe, result)
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index aad7074..677fe6b 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -377,6 +377,15 @@ class NetTestSlave:
if not self._server_handler.send_data_to_ctl(msg):
self._log_ctl.cancel_connection()
elif msg["type"] == "exception":
+ if msg["cmd_id"] != None:
+ logging.debug("Recieved an exception from command with id: %s"
+ % msg["cmd_id"])
+ else:
+ logging.debug("Recieved an exception from foreground command")
+ logging.error(msg["Exception"])
+ cmd = self._cmd_context.get_cmd(msg["cmd_id"])
+ cmd.join()
+ self._cmd_context.del_cmd(cmd)
if not self._server_handler.send_data_to_ctl(msg):
self._log_ctl.cancel_connection()
elif msg["type"] == "result":
Show replies by thread