diff options
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}' |
