summaryrefslogtreecommitdiff
path: root/swiftclient/client.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-04-24 01:18:49 +0000
committerGerrit Code Review <review@openstack.org>2015-04-24 01:18:49 +0000
commitea6d2bf74d8cf7f5faeff3d3052265db717db99e (patch)
tree5c42a8c916bc919d336230b6892a4062cbe01d60 /swiftclient/client.py
parent3105cdc4f815788dc6939e6e2866342d01866773 (diff)
parentf5a473edfc03bebcd429766f76299bc9e132250c (diff)
downloadpython-swiftclient-ea6d2bf74d8cf7f5faeff3d3052265db717db99e.tar.gz
Merge "Add socket-level read timeout parameter"
Diffstat (limited to 'swiftclient/client.py')
-rw-r--r--swiftclient/client.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py
index 67977ed..b18241d 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -140,7 +140,8 @@ def encode_meta_headers(headers):
class HTTPConnection(object):
def __init__(self, url, proxy=None, cacert=None, insecure=False,
- ssl_compression=False, default_user_agent=None):
+ ssl_compression=False, default_user_agent=None,
+ timeout=None):
"""
Make an HTTPConnection or HTTPSConnection
@@ -160,6 +161,8 @@ class HTTPConnection(object):
may be overridden on a per-request basis by
explicitly setting the user-agent header on
a call to request().
+ :param timeout: socket read timeout value, passed directly to
+ the requests library.
:raises ClientException: Unable to handle protocol scheme
"""
self.url = url
@@ -190,6 +193,8 @@ class HTTPConnection(object):
default_user_agent = \
'python-swiftclient-%s' % swiftclient_version.version_string
self.default_user_agent = default_user_agent
+ if timeout:
+ self.requests_args['timeout'] = timeout
def _request(self, *arg, **kwarg):
""" Final wrapper before requests call, to be patched in tests """
@@ -1155,7 +1160,7 @@ class Connection(object):
starting_backoff=1, max_backoff=64, tenant_name=None,
os_options=None, auth_version="1", cacert=None,
insecure=False, ssl_compression=True,
- retry_on_ratelimit=False):
+ retry_on_ratelimit=False, timeout=None):
"""
:param authurl: authentication URL
:param user: user name to authenticate as
@@ -1208,6 +1213,7 @@ class Connection(object):
self.ssl_compression = ssl_compression
self.auth_end_time = 0
self.retry_on_ratelimit = retry_on_ratelimit
+ self.timeout = timeout
def close(self):
if (self.http_conn and isinstance(self.http_conn, tuple)
@@ -1231,7 +1237,8 @@ class Connection(object):
return http_connection(url if url else self.url,
cacert=self.cacert,
insecure=self.insecure,
- ssl_compression=self.ssl_compression)
+ ssl_compression=self.ssl_compression,
+ timeout=self.timeout)
def _add_response_dict(self, target_dict, kwargs):
if target_dict is not None and 'response_dict' in kwargs: