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 {})
|
params.update(server_params or {})
|
||||||
|
|
||||||
self.brokers = params['qpid_hosts']
|
self.brokers = params['qpid_hosts']
|
||||||
|
|
||||||
|
brokers_count = len(self.brokers)
|
||||||
|
self.next_broker_indices = itertools.cycle(range(brokers_count))
|
||||||
|
|
||||||
self.username = params['username']
|
self.username = params['username']
|
||||||
self.password = params['password']
|
self.password = params['password']
|
||||||
self.reconnect()
|
self.reconnect()
|
||||||
@ -489,7 +493,6 @@ class Connection(object):
|
|||||||
|
|
||||||
def reconnect(self):
|
def reconnect(self):
|
||||||
"""Handles reconnecting and re-establishing sessions and queues."""
|
"""Handles reconnecting and re-establishing sessions and queues."""
|
||||||
attempt = 0
|
|
||||||
delay = 1
|
delay = 1
|
||||||
while True:
|
while True:
|
||||||
# Close the session if necessary
|
# Close the session if necessary
|
||||||
@ -499,8 +502,7 @@ class Connection(object):
|
|||||||
except qpid_exceptions.ConnectionError:
|
except qpid_exceptions.ConnectionError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
broker = self.brokers[attempt % len(self.brokers)]
|
broker = self.brokers[next(self.next_broker_indices)]
|
||||||
attempt += 1
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.connection_create(broker)
|
self.connection_create(broker)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user