summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Petrov <andrey.petrov@shazow.net>2014-06-26 17:36:23 -0700
committerAndrey Petrov <andrey.petrov@shazow.net>2014-06-26 17:36:23 -0700
commit3ff5ff0ff819280316f174b458d2e60204e29997 (patch)
tree672ea21b50c545f2c1ee4ab96fa5dca77b197cbb
parentcd1db4a969595b94c96fc2240d75042709b32be5 (diff)
downloadurllib3-3ff5ff0ff819280316f174b458d2e60204e29997.tar.gz
Retry.count
-rw-r--r--test/test_retry.py4
-rw-r--r--urllib3/connectionpool.py2
-rw-r--r--urllib3/util/retry.py9
3 files changed, 10 insertions, 5 deletions
diff --git a/test/test_retry.py b/test/test_retry.py
index ee3c8d62..78ee7b21 100644
--- a/test/test_retry.py
+++ b/test/test_retry.py
@@ -11,10 +11,10 @@ class RetryTest(unittest.TestCase):
def test_string(self):
""" Retry string representation looks the way we expect """
retry = Retry()
- self.assertEqual(str(retry), 'Retry(count=0)')
+ self.assertEqual(str(retry), 'Retry(total=10, count=0)')
for _ in range(3):
retry = retry.increment()
- self.assertEqual(str(retry), 'Retry(count=3)')
+ self.assertEqual(str(retry), 'Retry(total=10, count=3)')
def test_retry_both_specified(self):
"""Total can win if it's lower than the connect value"""
diff --git a/urllib3/connectionpool.py b/urllib3/connectionpool.py
index 0bfe699e..d02d7a0f 100644
--- a/urllib3/connectionpool.py
+++ b/urllib3/connectionpool.py
@@ -573,7 +573,7 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods):
if not conn:
# Try again
- log.warning("Retrying (%s retries) after connection "
+ log.warning("Retrying (%s) after connection "
"broken by '%r': %s" % (retries, err, url))
return self.urlopen(method, url, body, headers, retries,
redirect, assert_same_host,
diff --git a/urllib3/util/retry.py b/urllib3/util/retry.py
index 3310b5c7..ac5ffa6b 100644
--- a/urllib3/util/retry.py
+++ b/urllib3/util/retry.py
@@ -151,6 +151,11 @@ class Retry(object):
self.raise_on_redirect = raise_on_redirect
self.observed_errors = observed_errors # XXX: use .history instead?
+ @property
+ def count(self):
+ # XXX: This is wrong right now.
+ return self.observed_errors
+
def new(self, total=None, connect=3, read=0, redirect=3, observed_errors=0):
return type(self)(
total=total,
@@ -279,5 +284,5 @@ class Retry(object):
cls=type(self), self=self)
def __str__(self):
- return '{cls.__name__}(count={count})'.format(
- cls=type(self), count=self.observed_errors)
+ return '{cls.__name__}(total={total}, count={count})'.format(
+ cls=type(self), total=self.total+self.count, count=self.count)