minutæ: port ClientException tweaks from swiftclient; dict .pop
openstack/python-swiftclient@5ae4b423 changed python-swiftclient's ClientException to have its http_status attribute default to None (rather than 0) and to use super in its __init__ method. For consistency's sake, it's nice for Swift's inlined copy of ClientException to receive the same patch. Also, the retry function in direct_client (a major user of ClientException) was using a somewhat awkward conditional-assignment-and-delete construction where the .pop method of dictionaries would be more idiomatic. Change-Id: I70a12f934f84f57549617af28b86f7f5637bd8fa
This commit is contained in:
parent
6a9b868ae6
commit
1ba7641c79
@ -513,14 +513,8 @@ def retry(func, *args, **kwargs):
|
||||
:returns: result of func
|
||||
:raises ClientException: all retries failed
|
||||
"""
|
||||
retries = 5
|
||||
if 'retries' in kwargs:
|
||||
retries = kwargs['retries']
|
||||
del kwargs['retries']
|
||||
error_log = None
|
||||
if 'error_log' in kwargs:
|
||||
error_log = kwargs['error_log']
|
||||
del kwargs['error_log']
|
||||
retries = kwargs.pop('retries', 5)
|
||||
error_log = kwargs.pop('error_log', None)
|
||||
attempts = 0
|
||||
backoff = 1
|
||||
while attempts <= retries:
|
||||
|
@ -214,9 +214,9 @@ class APIVersionError(SwiftException):
|
||||
class ClientException(Exception):
|
||||
|
||||
def __init__(self, msg, http_scheme='', http_host='', http_port='',
|
||||
http_path='', http_query='', http_status=0, http_reason='',
|
||||
http_path='', http_query='', http_status=None, http_reason='',
|
||||
http_device='', http_response_content='', http_headers=None):
|
||||
Exception.__init__(self, msg)
|
||||
super(ClientException, self).__init__(msg)
|
||||
self.msg = msg
|
||||
self.http_scheme = http_scheme
|
||||
self.http_host = http_host
|
||||
|
Loading…
Reference in New Issue
Block a user