summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2011-03-17 20:03:20 +0000
committerAlan Conway <aconway@apache.org>2011-03-17 20:03:20 +0000
commitd0d0a878ed588084deaf4013d1ca8b04c3d0ab5a (patch)
tree1f768cb809fd67ea820279ade450c90246a343e2 /cpp/src
parentfa356bee994518e9f196be596199b5d518c048c8 (diff)
downloadqpid-python-d0d0a878ed588084deaf4013d1ca8b04c3d0ab5a.tar.gz
NO-JIRA: Put a timeout on calls to Thread.join to avoid tests hanging indefinitely.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1082668 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/tests/brokertest.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/cpp/src/tests/brokertest.py b/cpp/src/tests/brokertest.py
index 5a20dceae4..1023f7152f 100644
--- a/cpp/src/tests/brokertest.py
+++ b/cpp/src/tests/brokertest.py
@@ -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):