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:
@@ -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):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user