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 | 37afb4d9376558f37ea93c3b39ab66fc69370033 (patch) | |
| tree | df66f390abfb3730cd062d66f9b7bb43e3001058 /python/qpid/connection.py | |
| parent | 9b00c29e5ca198d9168c8bae71d2dd3eccbe5397 (diff) | |
| download | qpid-python-37afb4d9376558f37ea93c3b39ab66fc69370033.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/qpid@736742 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/connection.py')
| -rw-r--r-- | python/qpid/connection.py | 8 |
1 files changed, 5 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 |
