summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Cacqueray <tristan.cacqueray@enovance.com>2014-02-18 18:11:58 +0100
committerTristan Cacqueray <tristan.cacqueray@enovance.com>2014-04-16 16:00:17 +0000
commitfa20e7f6850a4793f8fb18400263269c24eda2ed (patch)
tree6315de30d5ea9696bf70978a20329b2b19476cfa
parentaaa563c74916bc40e2f8d5b560030b4e4ce9c08d (diff)
downloadpython-swiftclient-fa20e7f6850a4793f8fb18400263269c24eda2ed.tar.gz
Makes use of requests.Session
This allows better connection pooling and may improve performances. Change-Id: I69e986b7387dd3ac281731b8355a3eec34a537f8
-rw-r--r--swiftclient/client.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py
index 2766461..675fe2e 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -166,6 +166,7 @@ class HTTPConnection:
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
@@ -190,7 +191,7 @@ class HTTPConnection:
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 """