diff options
| author | Rafael H. Schloming <rhs@apache.org> | 2009-01-22 18:55:12 +0000 |
|---|---|---|
| committer | Rafael H. Schloming <rhs@apache.org> | 2009-01-22 18:55:12 +0000 |
| commit | d23a587fee328ffa88f4ed18d2a0766db1c36d88 (patch) | |
| tree | e960a9a47eab0f39c871658b10ca8cf66150a9d4 /qpid/python | |
| parent | 14942da3ac0ecd5adcbd6dd7675f648a7d6f425c (diff) | |
| download | qpid-python-d23a587fee328ffa88f4ed18d2a0766db1c36d88.tar.gz | |
ensure that we always close the socket, even if the other end doesn't
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@736742 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python')
| -rw-r--r-- | qpid/python/qpid/connection.py | 8 | ||||
| -rw-r--r-- | qpid/python/qpid/delegates.py | 1 |
2 files changed, 6 insertions, 3 deletions
diff --git a/qpid/python/qpid/connection.py b/qpid/python/qpid/connection.py index 6665e3e40c..3ab430587a 100644 --- a/qpid/python/qpid/connection.py +++ b/qpid/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/qpid/python/qpid/delegates.py b/qpid/python/qpid/delegates.py index 61c8e8c326..7cfd9b11db 100644 --- a/qpid/python/qpid/delegates.py +++ b/qpid/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): |
