summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2013-05-29 18:03:50 +0000
committerAlan Conway <aconway@apache.org>2013-05-29 18:03:50 +0000
commitefa84dfce326ea33e2eddfd3cb8142a8d708e101 (patch)
treefdd0f0d38d0043cd751a42faf331f8a0304374df
parent9ebce34a10a67449e047ad3c76d839df1074dce7 (diff)
downloadqpid-python-efa84dfce326ea33e2eddfd3cb8142a8d708e101.tar.gz
NO-JIRA: Added connection timeout to python client, used in brokertests.
Added an optional timeout parameter to Connection.establish. Set a timeout of 5 seconds in brokertest.py to prevent hanging tests. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1487578 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--cpp/src/tests/brokertest.py4
-rw-r--r--python/qpid/messaging/endpoints.py7
2 files changed, 5 insertions, 6 deletions
diff --git a/cpp/src/tests/brokertest.py b/cpp/src/tests/brokertest.py
index 290a1dde2c..535d7220d7 100644
--- a/cpp/src/tests/brokertest.py
+++ b/cpp/src/tests/brokertest.py
@@ -305,9 +305,9 @@ class Broker(Popen):
def unexpected(self,msg):
raise BadProcessStatus("%s: %s (%s)" % (msg, self.name, self.pname))
- def connect(self, **kwargs):
+ def connect(self, timeout=5, **kwargs):
"""New API connection to the broker."""
- return messaging.Connection.establish(self.host_port(), **kwargs)
+ return messaging.Connection.establish(self.host_port(), timeout=timeout, **kwargs)
def connect_old(self):
"""Old API connection to the broker."""
diff --git a/python/qpid/messaging/endpoints.py b/python/qpid/messaging/endpoints.py
index 3c9639552c..7621dceb3d 100644
--- a/python/qpid/messaging/endpoints.py
+++ b/python/qpid/messaging/endpoints.py
@@ -59,13 +59,13 @@ class Connection(Endpoint):
"""
@static
- def establish(url=None, **options):
+ def establish(url=None, timeout=None, **options):
"""
Constructs a L{Connection} with the supplied parameters and opens
it.
"""
conn = Connection(url, **options)
- conn.open()
+ conn.open(timeout=timeout)
return conn
def __init__(self, url=None, **options):
@@ -257,14 +257,13 @@ class Connection(Endpoint):
self.sessions.pop(ssn.name, 0)
@synchronized
- def open(self):
+ def open(self, timeout=None):
"""
Opens a connection.
"""
if self._open:
raise ConnectionError("already open")
self._open = True
- timeout = None
if self.reconnect and self.reconnect_timeout > 0:
timeout = self.reconnect_timeout
self.attach(timeout=timeout)