There was an error while loading. Please reload this page.
1 parent 66cc0a8 commit ed5a1ccCopy full SHA for ed5a1cc
elasticsearch/connection_pool.py
@@ -1,6 +1,7 @@
1
import time
2
import random
3
import logging
4
+import threading
5
6
try:
7
from Queue import PriorityQueue, Empty
@@ -58,12 +59,12 @@ class RoundRobinSelector(ConnectionSelector):
58
59
"""
60
def __init__(self, opts):
61
super(RoundRobinSelector, self).__init__(opts)
- self.rr = -1
62
+ self.data = threading.local()
63
64
def select(self, connections):
- self.rr += 1
65
- self.rr %= len(connections)
66
- return connections[self.rr]
+ self.data.rr = getattr(self.data, 'rr', -1) + 1
+ self.data.rr %= len(connections)
67
+ return connections[self.data.rr]
68
69
class ConnectionPool(object):
70
0 commit comments