When resurrect happens it shouldn't return the risen connection, just return it to pool
This commit is contained in:
@@ -58,16 +58,13 @@ class ConnectionPool(object):
|
||||
# either we were forced or the node is elligible to be retried
|
||||
connection = self.dead.pop(0)[1]
|
||||
self.connections.append(connection)
|
||||
return connection
|
||||
|
||||
def get_connection(self):
|
||||
connection = self.resurrect()
|
||||
if connection:
|
||||
return connection
|
||||
self.resurrect()
|
||||
|
||||
# no live nodes, resurrect one by force
|
||||
if not self.connections:
|
||||
return self.resurrect(True)
|
||||
self.resurrect(True)
|
||||
|
||||
return self.selector.select(self.connections)
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ class TestConnectionPool(TestCase):
|
||||
|
||||
now = time.time()
|
||||
pool.mark_dead(42, now=now-61)
|
||||
self.assertEquals(42, pool.get_connection())
|
||||
pool.get_connection()
|
||||
self.assertEquals(42, pool.connections[-1])
|
||||
self.assertEquals(100, len(pool.connections))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user