commit 44826b7951eb388dfe38fb5326fdf5d131b0cd22
Author: Jan Tluka <jtluka(a)redhat.com>
Date: Mon Dec 3 16:47:02 2012 +0100
Don't read from result pipe if bg process was killed
If the background process was killed (SIGKILL) the pipe got unreadable
and EOFError exception was raised. This patch fixes that by checking
whether the background process was signalled and returns just the minimal
result data to be able to continue with test execution.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
lnst/Common/NetTestCommand.py | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index 671fe36..c8c807d 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -52,6 +52,7 @@ class BgCommand:
self._cmd_cls = cmd_cls
self._pid = None
self._read_pipe = None
+ self._killed = False
def get_bg_id(self):
return self._bg_id
@@ -95,13 +96,20 @@ class BgCommand:
def kill(self):
logging.debug("Killing background command with id \"%s\", pid
\"%d\"" % (self._bg_id, self._pid))
+ self._killed = True
os.killpg(os.getpgid(self._pid), signal.SIGKILL)
def get_result(self):
- tmp = os.read(self._read_pipe, 4096*10)
- result = pickle.loads(tmp)
- if "Exception" in result:
- raise BgCommandException(result["Exception"])
+ result = {}
+ if self._killed:
+ result["logs"] = []
+ result["passed"] = True
+ else:
+ tmp = os.read(self._read_pipe, 4096*10)
+ result = pickle.loads(tmp)
+ if "Exception" in result:
+ raise BgCommandException(result["Exception"])
+
os.close(self._read_pipe)
return result
Show replies by date