It's REtries, not tries, respect that
This commit is contained in:
@@ -211,7 +211,7 @@ class Transport(object):
|
||||
if body:
|
||||
body = self.serializer.dumps(body)
|
||||
|
||||
for attempt in range(self.max_retries):
|
||||
for attempt in range(self.max_retries + 1):
|
||||
connection, dead_count = self.get_connection()
|
||||
|
||||
try:
|
||||
@@ -220,7 +220,7 @@ class Transport(object):
|
||||
self.mark_dead(connection, dead_count + 1)
|
||||
|
||||
# raise exception on last retry
|
||||
if attempt + 1 == self.max_retries:
|
||||
if attempt == self.max_retries:
|
||||
raise
|
||||
else:
|
||||
# resurrected connection didn't fail, confirm it's live status
|
||||
|
||||
@@ -62,7 +62,7 @@ class TestTransport(TestCase):
|
||||
t = Transport([{'exception': ConnectionError('abandon ship')}], connection_class=DummyConnection)
|
||||
|
||||
self.assertRaises(ConnectionError, t.perform_request, 'GET', '/')
|
||||
self.assertEquals(3, len(t.get_connection()[0].calls))
|
||||
self.assertEquals(4, len(t.get_connection()[0].calls))
|
||||
|
||||
def test_failed_connection_will_be_marked_as_dead(self):
|
||||
t = Transport([{'exception': ConnectionError('abandon ship')}], connection_class=DummyConnection)
|
||||
@@ -102,7 +102,7 @@ class TestTransport(TestCase):
|
||||
|
||||
def test_sniff_on_fail_triggers_sniffing_on_fail(self):
|
||||
t = Transport([{'exception': ConnectionError('abandon ship')}, {"data": CLUSTER_NODES}],
|
||||
connection_class=DummyConnection, sniff_on_connection_fail=True, max_retries=1, randomize_hosts=False)
|
||||
connection_class=DummyConnection, sniff_on_connection_fail=True, max_retries=0, randomize_hosts=False)
|
||||
|
||||
self.assertRaises(ConnectionError, t.perform_request, 'GET', '/')
|
||||
self.assertEquals(1, len(t.connection_pool.connections))
|
||||
|
||||
Reference in New Issue
Block a user