public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Goldish <mgoldish@redhat.com>
To: autotest@test.kernel.org, kvm@vger.kernel.org
Subject: [KVM-AUTOTEST PATCH 2/4] KVM test: kvm_utils.Thread.join(): allow suppressing the exception
Date: Tue, 11 Jan 2011 20:33:20 +0200	[thread overview]
Message-ID: <1294770802-1501-2-git-send-email-mgoldish@redhat.com> (raw)
In-Reply-To: <1294770802-1501-1-git-send-email-mgoldish@redhat.com>

If suppress_exception is True, the exception raised in the thread will not be
re-raised.

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_utils.py |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 8e6cef1..d55594c 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -1188,22 +1188,24 @@ class Thread(threading.Thread):
             del self._target, self._args, self._kwargs
 
 
-    def join(self, timeout=None):
+    def join(self, timeout=None, suppress_exception=False):
         """
         Join the thread.  If target raised an exception, re-raise it.
         Otherwise, return the value returned by target.
 
         @param timeout: Timeout value to pass to threading.Thread.join().
+        @param suppress_exception: If True, don't re-raise the exception.
         """
         threading.Thread.join(self, timeout)
         try:
             if self._e:
-                # Because the exception was raised in another thread, we need
-                # to explicitly insert the current context into it
-                s = error.exception_context(self._e[1])
-                s = error.join_contexts(error.get_context(), s)
-                error.set_exception_context(self._e[1], s)
-                raise self._e[0], self._e[1], self._e[2]
+                if not suppress_exception:
+                    # Because the exception was raised in another thread, we
+                    # need to explicitly insert the current context into it
+                    s = error.exception_context(self._e[1])
+                    s = error.join_contexts(error.get_context(), s)
+                    error.set_exception_context(self._e[1], s)
+                    raise self._e[0], self._e[1], self._e[2]
             else:
                 return self._retval
         finally:
-- 
1.7.3.4

  reply	other threads:[~2011-01-11 18:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-11 18:33 [KVM-AUTOTEST PATCH 1/4] KVM test: kvm_vm.py: add status and output to VMDeadError Michael Goldish
2011-01-11 18:33 ` Michael Goldish [this message]
2011-01-11 18:33 ` [KVM-AUTOTEST PATCH 3/4] KVM test: don't re-raise a background exception if something went wrong in the main thread Michael Goldish
2011-01-11 18:33 ` [KVM-AUTOTEST PATCH 4/4] KVM test: VM.migrate(): make sure the VM is alive after migration 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=1294770802-1501-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox