summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2022-08-17 16:58:36 -0700
committerTim Burke <tim.burke@gmail.com>2022-08-18 12:12:35 -0700
commita1d2f31131d79d7c551dbac4fc1e9c4d177d2df5 (patch)
treef307a7a9540ff6ceb23d0c938afed449dcb3d76a
parent9eee29d2e46e774eb08acb76c3317a58856f3f71 (diff)
downloadpython-swiftclient-a1d2f31131d79d7c551dbac4fc1e9c4d177d2df5.tar.gz
Enable retry_on_ratelimit by default
UpgradeImpact ============= The Connection class now enables retry_on_ratelimit by default. If you need to return to the old behavior, explicitly pass retry_on_ratelimit=False as a keyword arg. The SwiftService class will now enables the retry_on_ratelimit option by default. If you need to return to the old behavior, explicitly set it to false in your options dict. Change-Id: I3221fda84f0b8031c50128aa600e2c19deb5b102
-rw-r--r--swiftclient/client.py8
-rw-r--r--swiftclient/service.py3
-rw-r--r--test/unit/test_swiftclient.py3
3 files changed, 9 insertions, 5 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py
index a9130ab..8415db2 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -1654,7 +1654,7 @@ class Connection:
starting_backoff=1, max_backoff=64, tenant_name=None,
os_options=None, auth_version="1", cacert=None,
insecure=False, cert=None, cert_key=None,
- ssl_compression=True, retry_on_ratelimit=False,
+ ssl_compression=True, retry_on_ratelimit=True,
timeout=None, session=None, force_auth_retry=False):
"""
:param authurl: authentication URL
@@ -1686,9 +1686,9 @@ class Connection:
will be made. This may provide a performance
increase for https upload/download operations.
:param retry_on_ratelimit: by default, a ratelimited connection will
- raise an exception to the caller. Setting
- this parameter to True will cause a retry
- after a backoff.
+ retry after a backoff. Setting this
+ parameter to False will cause an exception
+ to be raised to the caller.
:param timeout: The connect timeout for the HTTP connection.
:param session: A keystoneauth session object.
:param force_auth_retry: reset auth info even if client got unexpected
diff --git a/swiftclient/service.py b/swiftclient/service.py
index 9d9fc59..545ea47 100644
--- a/swiftclient/service.py
+++ b/swiftclient/service.py
@@ -155,6 +155,7 @@ def _build_default_global_options():
"user": environ.get('ST_USER'),
"key": environ.get('ST_KEY'),
"retries": 5,
+ "retry_on_ratelimit": True,
"force_auth_retry": False,
"os_username": environ.get('OS_USERNAME'),
"os_user_id": environ.get('OS_USER_ID'),
@@ -270,10 +271,12 @@ def get_conn(options):
"""
Return a connection building it from the options.
"""
+ options = dict(_default_global_options, **options)
return Connection(options['auth'],
options['user'],
options['key'],
timeout=options.get('timeout'),
+ retry_on_ratelimit=options['retry_on_ratelimit'],
retries=options['retries'],
auth_version=options['auth_version'],
os_options=options['os_options'],
diff --git a/test/unit/test_swiftclient.py b/test/unit/test_swiftclient.py
index ad2af50..436245d 100644
--- a/test/unit/test_swiftclient.py
+++ b/test/unit/test_swiftclient.py
@@ -2149,7 +2149,8 @@ class TestConnection(MockHttpTest):
c.http_connection = self.fake_http_connection(
200, 498,
headers=auth_resp_headers)
- conn = c.Connection('http://www.test.com/auth/v1.0', 'asdf', 'asdf')
+ conn = c.Connection('http://www.test.com/auth/v1.0', 'asdf', 'asdf',
+ retry_on_ratelimit=False)
with self.assertRaises(c.ClientException) as exc_context:
conn.head_account()
self.assertIn('Account HEAD failed', str(exc_context.exception))