All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Goldish <mgoldish@redhat.com>
To: autotest@test.kernel.org, kvm@vger.kernel.org
Cc: Michael Goldish <mgoldish@redhat.com>
Subject: [KVM-AUTOTEST PATCH 1/3] KVM test: kvm_subprocess.py: do not start tail thread by default
Date: Tue, 13 Oct 2009 13:48:34 +0200	[thread overview]
Message-ID: <1255434516-22142-1-git-send-email-mgoldish@redhat.com> (raw)

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>
---
 client/tests/kvm/kvm_subprocess.py |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

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 @@ class kvm_tail(kvm_spawn):
         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 @@ class kvm_tail(kvm_spawn):
                 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 @@ class kvm_tail(kvm_spawn):
                 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 @@ class kvm_tail(kvm_spawn):
             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:
-- 
1.5.4.1


             reply	other threads:[~2009-10-13 11:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-13 11:48 Michael Goldish [this message]
2009-10-13 11:48 ` [KVM-AUTOTEST PATCH 2/3] KVM test: kvm_subprocess.py: use only unbound methods as close() hooks Michael Goldish
2009-10-13 11:48   ` [KVM-AUTOTEST PATCH 3/3] KVM test: kvm_subprocess.py: automatically close unreferenced shell sessions Michael Goldish

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1255434516-22142-1-git-send-email-mgoldish@redhat.com \
    --to=mgoldish@redhat.com \
    --cc=autotest@test.kernel.org \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.