Skip to content

Commit

Permalink
This commit modifies the elasticsearch/connection_pool.py file to sol…
Browse files Browse the repository at this point in the history
…ve the list index out of range error. (#539)

Fixes #371
  • Loading branch information
HusainZafar authored and honzakral committed Feb 19, 2017
1 parent 66cc0a8 commit ed5a1cc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions elasticsearch/connection_pool.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import time
import random
import logging
import threading

try:
from Queue import PriorityQueue, Empty
Expand Down Expand Up @@ -58,12 +59,12 @@ class RoundRobinSelector(ConnectionSelector):
"""
def __init__(self, opts):
super(RoundRobinSelector, self).__init__(opts)
self.rr = -1
self.data = threading.local()

def select(self, connections):
self.rr += 1
self.rr %= len(connections)
return connections[self.rr]
self.data.rr = getattr(self.data, 'rr', -1) + 1
self.data.rr %= len(connections)
return connections[self.data.rr]

class ConnectionPool(object):
"""
Expand Down

0 comments on commit ed5a1cc

Please sign in to comment.