Return-Path: X-Original-To: apmail-qpid-commits-archive@www.apache.org Delivered-To: apmail-qpid-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E7E3EFA1A for ; Thu, 2 May 2013 10:20:25 +0000 (UTC) Received: (qmail 31820 invoked by uid 500); 2 May 2013 10:20:25 -0000 Delivered-To: apmail-qpid-commits-archive@qpid.apache.org Received: (qmail 31744 invoked by uid 500); 2 May 2013 10:20:25 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 31721 invoked by uid 99); 2 May 2013 10:20:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 May 2013 10:20:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 May 2013 10:20:22 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 438862388847; Thu, 2 May 2013 10:20:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@qpid.apache.org From: jross@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130502102001.438862388847@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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