KVM test: kvm_subprocess.py: do not start tail thread by default
Start the tail thread only if the user specifies a non-None output_func or
termination_func.
Signed-off-by: Michael Goldish <mgoldish@redhat.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@3845 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py
index 2ac062a..ede8081 100755
--- a/client/tests/kvm/kvm_subprocess.py
+++ b/client/tests/kvm/kvm_subprocess.py
@@ -596,9 +596,10 @@
self.output_prefix = output_prefix
# Start the thread in the background
+ self.tail_thread = None
self.__thread_kill_requested = False
- self.tail_thread = threading.Thread(None, self._tail)
- self.tail_thread.start()
+ if termination_func or output_func:
+ self._start_thread()
def __getinitargs__(self):
@@ -617,6 +618,8 @@
Must take a single parameter -- the exit status.
"""
self.termination_func = termination_func
+ if termination_func and not self.tail_thread:
+ self._start_thread()
def set_termination_params(self, termination_params):
@@ -637,6 +640,8 @@
output from the process. Must take a single string parameter.
"""
self.output_func = output_func
+ if output_func and not self.tail_thread:
+ self._start_thread()
def set_output_params(self, output_params):
@@ -726,6 +731,11 @@
pass
+ def _start_thread(self):
+ self.tail_thread = threading.Thread(None, self._tail)
+ self.tail_thread.start()
+
+
def _join_thread(self):
# Wait for the tail thread to exit
if self.tail_thread: