diff --git a/oslo/messaging/_drivers/impl_qpid.py b/oslo/messaging/_drivers/impl_qpid.py index f9b275f70..f3988409b 100644 --- a/oslo/messaging/_drivers/impl_qpid.py +++ b/oslo/messaging/_drivers/impl_qpid.py @@ -473,10 +473,7 @@ class Connection(object): } params.update(server_params or {}) - self.brokers = params['qpid_hosts'] - - brokers_count = len(self.brokers) - self.next_broker_indices = itertools.cycle(range(brokers_count)) + self.brokers = itertools.cycle(params['qpid_hosts']) self.username = params['username'] self.password = params['password'] @@ -515,7 +512,7 @@ class Connection(object): except qpid_exceptions.ConnectionError: pass - broker = self.brokers[next(self.next_broker_indices)] + broker = six.next(self.brokers) try: self.connection_create(broker) diff --git a/oslo/messaging/_drivers/impl_rabbit.py b/oslo/messaging/_drivers/impl_rabbit.py index 887a19a78..5b6cf03bc 100644 --- a/oslo/messaging/_drivers/impl_rabbit.py +++ b/oslo/messaging/_drivers/impl_rabbit.py @@ -466,10 +466,7 @@ class Connection(object): params_list.append(params) - self.params_list = params_list - - brokers_count = len(self.params_list) - self.next_broker_indices = itertools.cycle(range(brokers_count)) + self.params_list = itertools.cycle(params_list) self.memory_transport = self.conf.fake_rabbit @@ -575,7 +572,7 @@ class Connection(object): attempt = 0 while True: - params = self.params_list[next(self.next_broker_indices)] + params = six.next(self.params_list) attempt += 1 try: self._connect(params)