diff mbox

[KVM-AUTOTEST,2/4] KVM test: kvm_utils.Thread.join(): allow suppressing the exception

Message ID 1294770802-1501-2-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Jan. 11, 2011, 6:33 p.m. UTC
None
diff mbox

Patch

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: