diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2013-01-11 21:56:24 -0800 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2013-01-18 19:11:24 -0800 |
commit | d2edaab531d0b452802851b077f9a0110bfa4b69 (patch) | |
tree | 20f6910c5240fb0529ba59ff9c9a937475c848e6 /keystoneclient/client.py | |
parent | e9ec399e66a737dd04fed79a2ba23ec34263cca2 (diff) | |
download | python-keystoneclient-d2edaab531d0b452802851b077f9a0110bfa4b69.tar.gz |
Allow request timeout to be specified.
Add a new cli argument (--timeout) which
is by default 600 seconds which will be
set in the requests library so that timeouts
can occur correctly.
Change-Id: I845c55dfb6f6b8345663ccdb5b150a2655f20026
Diffstat (limited to 'keystoneclient/client.py')
-rw-r--r-- | keystoneclient/client.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/keystoneclient/client.py b/keystoneclient/client.py index 6f2d1a4..c46dec6 100644 --- a/keystoneclient/client.py +++ b/keystoneclient/client.py @@ -60,6 +60,11 @@ class HTTPClient(object): cert=None, insecure=False, original_ip=None, debug=False, auth_ref=None, use_keyring=False, force_new_token=False, stale_duration=None): + """Construct a new http client + + @param: timeout the request libary timeout in seconds (default None) + + """ self.version = 'v2.0' # set baseline defaults self.username = None @@ -69,6 +74,10 @@ class HTTPClient(object): self.token = None self.auth_token = None self.management_url = None + if timeout is not None: + self.timeout = float(timeout) + else: + self.timeout = None # if loading from a dictionary passed in via auth_ref, # load values from AccessInfo parsing that dictionary self.auth_ref = access.AccessInfo(**auth_ref) if auth_ref else None @@ -320,6 +329,8 @@ class HTTPClient(object): del request_kwargs['body'] if self.cert: request_kwargs['cert'] = self.cert + if self.timeout is not None: + request_kwargs.setdefault('timeout', self.timeout) self.http_log_req((url, method,), request_kwargs) resp = requests.request( |