Skip to content

Commit

Permalink
Makes use of requests.Session
Browse files Browse the repository at this point in the history
This allows better connection pooling and may improve performances.

Change-Id: I69e986b7387dd3ac281731b8355a3eec34a537f8
  • Loading branch information
Tristan Cacqueray committed Apr 16, 2014
1 parent aaa563c commit fa20e7f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion swiftclient/client.py
Expand Up @@ -166,6 +166,7 @@ def __init__(self, url, proxy=None, cacert=None, insecure=False,
self.host = self.parsed_url.netloc
self.port = self.parsed_url.port
self.requests_args = {}
self.request_session = requests.Session()
if self.parsed_url.scheme not in ('http', 'https'):
raise ClientException("Unsupported scheme")
self.requests_args['verify'] = not insecure
Expand All @@ -190,7 +191,7 @@ def __init__(self, url, proxy=None, cacert=None, insecure=False,

def _request(self, *arg, **kwarg):
""" Final wrapper before requests call, to be patched in tests """
return requests.request(*arg, **kwarg)
return self.request_session.request(*arg, **kwarg)

def request(self, method, full_path, data=None, headers=None, files=None):
""" Encode url and header, then call requests.request """
Expand Down

0 comments on commit fa20e7f

Please sign in to comment.