qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jr...@apache.org
Subject svn commit: r1478313 - in /qpid/trunk/qpid/python/qpid: messaging/endpoints.py tests/messaging/endpoints.py
Date Thu, 02 May 2013 10:20:01 GMT
Author: jross
Date: Thu May  2 10:20:00 2013
New Revision: 1478313

URL: http://svn.apache.org/r1478313
Log:
QPID-4774: Honor reconnect_timeout in Connection; a patch from Ernie Allen

Modified:
    qpid/trunk/qpid/python/qpid/messaging/endpoints.py
    qpid/trunk/qpid/python/qpid/tests/messaging/endpoints.py

Modified: qpid/trunk/qpid/python/qpid/messaging/endpoints.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/messaging/endpoints.py?rev=1478313&r1=1478312&r2=1478313&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/messaging/endpoints.py (original)
+++ qpid/trunk/qpid/python/qpid/messaging/endpoints.py Thu May  2 10:20:00 2013
@@ -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

Modified: qpid/trunk/qpid/python/qpid/tests/messaging/endpoints.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/tests/messaging/endpoints.py?rev=1478313&r1=1478312&r2=1478313&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/tests/messaging/endpoints.py (original)
+++ qpid/trunk/qpid/python/qpid/tests/messaging/endpoints.py Thu May  2 10:20:00 2013
@@ -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}'
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message