From a0b8db4140bcd82744060d5fb8ef6454967618af Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Fri, 3 Apr 2015 16:57:34 +0000 Subject: QPID-6475: [Python Client] 08..09 Send connection.close before closing socket git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1671100 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/python/qpid/client.py | 12 +++++++++++- qpid/python/qpid/testlib.py | 5 +---- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'qpid/python') diff --git a/qpid/python/qpid/client.py b/qpid/python/qpid/client.py index 7ae0106b51..1bb225e7d1 100644 --- a/qpid/python/qpid/client.py +++ b/qpid/python/qpid/client.py @@ -127,7 +127,17 @@ class Client: def close(self): if self.peer: - self.peer.stop() + try: + if not self.closed: + channel = self.channel(0); + if channel and not channel._closed: + try: + channel.connection_close(reply_code=200) + except: + pass + self.closed = True + finally: + self.peer.stop() class ClientDelegate(Delegate): diff --git a/qpid/python/qpid/testlib.py b/qpid/python/qpid/testlib.py index 0103956ec4..841dcfbd88 100644 --- a/qpid/python/qpid/testlib.py +++ b/qpid/python/qpid/testlib.py @@ -71,10 +71,7 @@ class TestBase(unittest.TestCase): print "Error on tearDown:" print traceback.print_exc() - if not self.client.closed: - self.client.channel(0).connection_close(reply_code=200) - else: - self.client.close() + self.client.close() def connect(self, host=None, port=None, user=None, password=None, tune_params=None, client_properties=None): """Create a new connction, return the Client object""" -- cgit v1.2.1