This commit modifies the elasticsearch/connection_pool.py file to solve the list index out of range error. (#539)

Fixes #371
This commit is contained in:
Husain Zafar
2017-02-19 16:04:32 +05:30
committed by Honza Král
parent 66cc0a82b4
commit ed5a1cce8e
+5 -4
View File
@@ -1,6 +1,7 @@
import time import time
import random import random
import logging import logging
import threading
try: try:
from Queue import PriorityQueue, Empty from Queue import PriorityQueue, Empty
@@ -58,12 +59,12 @@ class RoundRobinSelector(ConnectionSelector):
""" """
def __init__(self, opts): def __init__(self, opts):
super(RoundRobinSelector, self).__init__(opts) super(RoundRobinSelector, self).__init__(opts)
self.rr = -1 self.data = threading.local()
def select(self, connections): def select(self, connections):
self.rr += 1 self.data.rr = getattr(self.data, 'rr', -1) + 1
self.rr %= len(connections) self.data.rr %= len(connections)
return connections[self.rr] return connections[self.data.rr]
class ConnectionPool(object): class ConnectionPool(object):
""" """