summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/qpid/connection.py8
-rw-r--r--python/qpid/delegates.py1
2 files changed, 6 insertions, 3 deletions
diff --git a/python/qpid/connection.py b/python/qpid/connection.py
index 6665e3e40c..3ab430587a 100644
--- a/python/qpid/connection.py
+++ b/python/qpid/connection.py
@@ -71,8 +71,11 @@ class Connection(Assembler):
self.sessions = {}
self.condition = Condition()
+ # XXX: we should combine this into a single comprehensive state
+ # model (whatever that means)
self.opened = False
self.failed = False
+ self.closed = False
self.close_code = (None, "connection aborted")
self.thread = Thread(target=self.run)
@@ -160,15 +163,14 @@ class Connection(Assembler):
raise ConnectionFailed(*self.close_code)
def run(self):
- # XXX: we don't really have a good way to exit this loop without
- # getting the other end to kill the socket
- while True:
+ while not self.closed:
try:
seg = self.read_segment()
except Closed:
self.detach_all()
break
self.delegate.received(seg)
+ self.sock.close()
def close(self, timeout=None):
if not self.opened: return
diff --git a/python/qpid/delegates.py b/python/qpid/delegates.py
index 61c8e8c326..7cfd9b11db 100644
--- a/python/qpid/delegates.py
+++ b/python/qpid/delegates.py
@@ -59,6 +59,7 @@ class Delegate:
def connection_close_ok(self, ch, close_ok):
self.connection.opened = False
+ self.connection.closed = True
notify(self.connection.condition)
def connection_heartbeat(self, ch, hrt):