From 39d1dde432efd40e2517d7c9054263910dda0a1f Mon Sep 17 00:00:00 2001 From: Chang Bo Guo Date: Sat, 7 Dec 2013 19:52:46 -0800 Subject: [PATCH] Avoid creating qpid connection twice in initialization In current logic, class impl_qpid.Connnection constructor calls method connection_create twice indirectly. Let us avoid this. Change-Id: I7618cf3506d857579dc37b338690d05179ba272d --- oslo/messaging/_drivers/impl_qpid.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oslo/messaging/_drivers/impl_qpid.py b/oslo/messaging/_drivers/impl_qpid.py index baa040374..f8a0a22ff 100644 --- a/oslo/messaging/_drivers/impl_qpid.py +++ b/oslo/messaging/_drivers/impl_qpid.py @@ -440,6 +440,7 @@ class Connection(object): if not qpid_messaging: raise ImportError("Failed to import qpid.messaging") + self.connection = None self.session = None self.consumers = {} self.consumer_thread = None @@ -463,7 +464,6 @@ class Connection(object): self.brokers = params['qpid_hosts'] self.username = params['username'] self.password = params['password'] - self.connection_create(self.brokers[0]) self.reconnect() def connection_create(self, broker): @@ -494,7 +494,7 @@ class Connection(object): delay = 1 while True: # Close the session if necessary - if self.connection.opened(): + if self.connection is not None and self.connection.opened(): try: self.connection.close() except qpid_exceptions.ConnectionError: