You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2015/09/22 13:09:23 UTC

qpid-proton git commit: PROTON-1000: ensure that when transport is lost, all events are drained to release references within them

Repository: qpid-proton
Updated Branches:
  refs/heads/master fa784b1f3 -> b8b2b344c


PROTON-1000: ensure that when transport is lost, all events are drained to release references within them


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/b8b2b344
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/b8b2b344
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/b8b2b344

Branch: refs/heads/master
Commit: b8b2b344cbdc8bccc0073732b3efdbb3f8fc462e
Parents: fa784b1
Author: Gordon Sim <gs...@redhat.com>
Authored: Tue Sep 22 11:49:43 2015 +0100
Committer: Gordon Sim <gs...@redhat.com>
Committed: Tue Sep 22 11:52:13 2015 +0100

----------------------------------------------------------------------
 proton-c/bindings/python/proton/utils.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b8b2b344/proton-c/bindings/python/proton/utils.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/utils.py b/proton-c/bindings/python/proton/utils.py
index 062df5d..197e60e 100644
--- a/proton-c/bindings/python/proton/utils.py
+++ b/proton-c/bindings/python/proton/utils.py
@@ -186,6 +186,7 @@ class BlockingConnection(Handler):
     A synchronous style connection wrapper.
     """
     def __init__(self, url, timeout=None, container=None, ssl_domain=None, heartbeat=None):
+        self.disconnected = False
         self.timeout = timeout
         self.container = container or Container()
         self.container.timeout = self.timeout
@@ -223,14 +224,14 @@ class BlockingConnection(Handler):
         if timeout is False:
             timeout = self.timeout
         if timeout is None:
-            while not condition():
+            while not condition() and not self.disconnected:
                 self.container.process()
         else:
             container_timeout = self.container.timeout
             self.container.timeout = timeout
             try:
                 deadline = time.time() + timeout
-                while not condition():
+                while not condition() and not self.disconnected:
                     self.container.process()
                     if deadline < time.time():
                         txt = "Connection %s timed out" % self.url
@@ -238,6 +239,9 @@ class BlockingConnection(Handler):
                         raise Timeout(txt)
             finally:
                 self.container.timeout = container_timeout
+        if self.disconnected:
+            self.container.stop();
+            raise ConnectionException("Connection %s disconnected" % self.url);
 
     def on_link_remote_close(self, event):
         if event.link.state & Endpoint.LOCAL_ACTIVE:
@@ -254,7 +258,7 @@ class BlockingConnection(Handler):
 
     def on_transport_closed(self, event):
         if event.connection.state & Endpoint.LOCAL_ACTIVE:
-            raise ConnectionException("Connection %s disconnected" % self.url);
+            self.disconnected = True
 
 class AtomicCount(object):
     def __init__(self, start=0, step=1):


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