Handle no hosts when populating load balancer
This commit is contained in:
@@ -26,7 +26,7 @@ class RoundRobinPolicy(LoadBalancingPolicy):
|
|||||||
|
|
||||||
def populate(self, cluster, hosts):
|
def populate(self, cluster, hosts):
|
||||||
self._live_hosts = set(hosts)
|
self._live_hosts = set(hosts)
|
||||||
if len(hosts) == 1:
|
if len(hosts) <= 1:
|
||||||
self._position = 0
|
self._position = 0
|
||||||
else:
|
else:
|
||||||
self._position = randint(0, len(hosts) - 1)
|
self._position = randint(0, len(hosts) - 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user