From 4576ea44aa51703d7ed3b036a044dbd911d6f3e9 Mon Sep 17 00:00:00 2001 From: Xavier Queralt Date: Mon, 26 Aug 2013 16:11:34 +0200 Subject: [PATCH] Ensure that qpid connection is closed (from oslo) This is commit a9bc62814d in oslo-incubator Fixes bug 1172922 When reestablishing a session and a connection already exists the existing connection will be closed prior to opening the new one. Change-Id: I9a25800fe4b56eba89d550e3461ce095bf902f0a --- cinder/openstack/common/rpc/impl_qpid.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cinder/openstack/common/rpc/impl_qpid.py b/cinder/openstack/common/rpc/impl_qpid.py index 24235b1f1..8f52fb84f 100644 --- a/cinder/openstack/common/rpc/impl_qpid.py +++ b/cinder/openstack/common/rpc/impl_qpid.py @@ -331,15 +331,16 @@ class Connection(object): def reconnect(self): """Handles reconnecting and re-establishing sessions and queues""" - if self.connection.opened(): - try: - self.connection.close() - except qpid_exceptions.ConnectionError: - pass - attempt = 0 delay = 1 while True: + # Close the session if necessary + if self.connection.opened(): + try: + self.connection.close() + except qpid_exceptions.ConnectionError: + pass + broker = self.brokers[attempt % len(self.brokers)] attempt += 1 -- 2.45.2