diff options
| author | Justin Ross <jross@apache.org> | 2013-05-02 10:20:00 +0000 |
|---|---|---|
| committer | Justin Ross <jross@apache.org> | 2013-05-02 10:20:00 +0000 |
| commit | 173e9656123e980c057d2f52de31d26e6b67e2b2 (patch) | |
| tree | 8a22fcbde5aa11985ea5db04b560b9db0b68f219 /qpid/python | |
| parent | 4f61727dff884c950421be6260a97050861abb82 (diff) | |
| download | qpid-python-173e9656123e980c057d2f52de31d26e6b67e2b2.tar.gz | |
QPID-4774: Honor reconnect_timeout in Connection; a patch from Ernie Allen
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1478313 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python')
| -rw-r--r-- | qpid/python/qpid/messaging/endpoints.py | 11 | ||||
| -rw-r--r-- | qpid/python/qpid/tests/messaging/endpoints.py | 10 |
2 files changed, 18 insertions, 3 deletions
diff --git a/qpid/python/qpid/messaging/endpoints.py b/qpid/python/qpid/messaging/endpoints.py index b4ddcc3f77..3c9639552c 100644 --- a/qpid/python/qpid/messaging/endpoints.py +++ b/qpid/python/qpid/messaging/endpoints.py @@ -264,7 +264,10 @@ class Connection(Endpoint): if self._open: raise ConnectionError("already open") self._open = True - self.attach() + timeout = None + if self.reconnect and self.reconnect_timeout > 0: + timeout = self.reconnect_timeout + self.attach(timeout=timeout) @synchronized def opened(self): @@ -274,7 +277,7 @@ class Connection(Endpoint): return self._open @synchronized - def attach(self): + def attach(self, timeout=None): """ Attach to the remote endpoint. """ @@ -282,7 +285,9 @@ class Connection(Endpoint): self._connected = True self._driver.start() self._wakeup() - self._ewait(lambda: self._transport_connected and not self._unlinked()) + if not self._ewait(lambda: self._transport_connected and not self._unlinked(), timeout=timeout): + self.reconnect = False + raise Timeout("Connection attach timed out") def _unlinked(self): return [l diff --git a/qpid/python/qpid/tests/messaging/endpoints.py b/qpid/python/qpid/tests/messaging/endpoints.py index cb924dc096..247d6e9a29 100644 --- a/qpid/python/qpid/tests/messaging/endpoints.py +++ b/qpid/python/qpid/tests/messaging/endpoints.py @@ -351,6 +351,16 @@ class TimeoutTests(Base): def testConnectionClose(self): self.timeoutTest(self.conn.close) + def testConnectionOpen(self): + options = self.connection_options() + options["reconnect"] = True + options["reconnect_timeout"] = self.delay() + try: + bad_conn = Connection.establish("badhostname", **options) + assert False, "did not time out" + except Timeout: + pass + ACK_QC = 'test-ack-queue; {create: always}' ACK_QD = 'test-ack-queue; {delete: always}' |
