Skip to content

Commit 7d50b47

Browse files
Schnoukikxepal
authored andcommitted
Use the next() builtin for Python 3 compatibility
`iterator.next()` has been replaced by `next(iterator)` in Python 3. Also add a test for retrying requests after a socket timeout. Signed-off-by: Alexander Shorin <kxepal@gmail.com>
1 parent aa58d50 commit 7d50b47

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

couchdb/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def _try_request_with_retries(retries):
315315
if ecode not in self.retryable_errors:
316316
raise
317317
try:
318-
delay = retries.next()
318+
delay = next(retries)
319319
except StopIteration:
320320
# No more retries, raise last socket error.
321321
raise e

couchdb/tests/couchhttp.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ def test_timeout(self):
2525
self.assertRaises(socket.timeout, body.read)
2626
self.assertTrue(time.time() - start < timeout * 1.3)
2727

28+
def test_timeout_retry(self):
29+
dbname, db = self.temp_db()
30+
timeout = 1e-12
31+
session = http.Session(timeout=timeout, retryable_errors=["timed out"])
32+
self.assertRaises(socket.timeout, session.request, 'GET', db.resource.url)
33+
2834

2935
class ResponseBodyTestCase(unittest.TestCase):
3036
def test_close(self):

0 commit comments

Comments
 (0)