This flag indicates whether it was possible to kill the command
gracefully. Since we're using forked processes the value must be shared
between parent and child. I used multiprocessing.Value for this purpose.
The flag is used to mark the result to be sent to controller with the
indication of this kind of interruption.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Common/NetTestCommand.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index 3f11f92..f09e402 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -100,6 +100,7 @@ class NetTestCommand:
self._log_ctl = log_ctl
self._start_time = None
self._result_sent = False
+ self._gracefully_killed = multiprocessing.Value('i', 0)
if "bg_id" not in self._command:
self._id = None
@@ -177,9 +178,21 @@ class NetTestCommand:
result["cmd_id"] = self._id
result["result"] = res_data
+ if self.get_gracefully_killed() == 1:
+ result["result"]["gracefully_killed"] = True
+
send_data(self._write_pipe, result)
self._write_pipe.close()
+ def set_gracefully_killed(self, value=True):
+ if value:
+ self._gracefully_killed.value = 1
+ else:
+ self._gracefully_killed.value = 0
+
+ def get_gracefully_killed(self):
+ return self._gracefully_killed.value
+
def join(self):
self._process.join()
--
2.4.11