Merge "Qpid: advance thru the list of brokers on reconnect"
This commit is contained in:
commit
a65f17abbb
@ -461,6 +461,10 @@ 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.username = params['username']
|
||||
self.password = params['password']
|
||||
self.reconnect()
|
||||
@ -489,7 +493,6 @@ class Connection(object):
|
||||
|
||||
def reconnect(self):
|
||||
"""Handles reconnecting and re-establishing sessions and queues."""
|
||||
attempt = 0
|
||||
delay = 1
|
||||
while True:
|
||||
# Close the session if necessary
|
||||
@ -499,8 +502,7 @@ class Connection(object):
|
||||
except qpid_exceptions.ConnectionError:
|
||||
pass
|
||||
|
||||
broker = self.brokers[attempt % len(self.brokers)]
|
||||
attempt += 1
|
||||
broker = self.brokers[next(self.next_broker_indices)]
|
||||
|
||||
try:
|
||||
self.connection_create(broker)
|
||||
|
Loading…
x
Reference in New Issue
Block a user