Author: aconway
Date: Thu Mar 17 20:03:20 2011
New Revision: 1082668

URL: http://svn.apache.org/viewvc?rev=1082668&view=rev
Log:
NO-JIRA: Put a timeout on calls to Thread.join to avoid tests hanging 
indefinitely.

Modified:
    qpid/trunk/qpid/cpp/src/tests/brokertest.py

Modified: qpid/trunk/qpid/cpp/src/tests/brokertest.py
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/brokertest.py?rev=1082668&r1=1082667&r2=1082668&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/brokertest.py (original)
+++ qpid/trunk/qpid/cpp/src/tests/brokertest.py Thu Mar 17 20:03:20 2011
@@ -498,6 +498,10 @@ class BrokerTest(TestCase):
         r.close()
         self.assertEqual(expect_contents, actual_contents)
 
+def join(thread, timeout=1):
+    thread.join(timeout)
+    if thread.isAlive(): raise Exception("Timed out joining thread %s"%thread)
+
 class RethrownException(Exception):
     """Captures the stack trace of the current exception to be thrown later"""
     def __init__(self, msg=""):
@@ -515,7 +519,7 @@ class StoppableThread(Thread):
 
     def stop(self):
         self.stopped = True
-        self.join()
+        join(self)
         if self.error: raise self.error
 
 class NumberedSender(Thread):
@@ -574,7 +578,7 @@ class NumberedSender(Thread):
             self.stopped = True
             self.condition.notify()
         finally: self.condition.release()
-        self.join()
+        join(self)
         self.write_message(-1)          # end-of-messages marker.
         if self.error: raise self.error
 
@@ -621,7 +625,7 @@ class NumberedReceiver(Thread):
 
     def stop(self):
         """Returns when termination message is received"""
-        self.join()
+        join(self)
         if self.error: raise self.error
 
 class ErrorGenerator(StoppableThread):



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to