Skip to content

Commit

Permalink
Merge pull request #14 from usabilla/reuse-connections
Browse files Browse the repository at this point in the history
Reuse connections when making API calls
  • Loading branch information
stevenjm authored May 16, 2018
2 parents 77f25ad + 8a80f77 commit a83948f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Changelog

Here you find a full list of changes.

Version 2.0.1
-------------

- Reuse HTTP connections between requests

Version 2.0.0
-------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
except ImportError:
from distutils.core import setup

VERSION = '2.0.0'
VERSION = '2.0.1'

setup(
name='usabilla-api',
Expand Down
4 changes: 3 additions & 1 deletion usabilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class APIClient(object):
host = 'data.usabilla.com'
host_protocol = 'https://'

session = requests.Session()

def __init__(self, client_key, secret_key):
"""Initialize an APIClient object."""
self.query_parameters = ''
Expand Down Expand Up @@ -237,7 +239,7 @@ def send_signed_request(self, scope):

# Send the request.
request_url = self.host + scope + '?' + canonical_querystring
r = requests.get(self.host_protocol + request_url, headers=headers)
r = self.session.get(self.host_protocol + request_url, headers=headers)
r.raise_for_status()

return r.json()
Expand Down

0 comments on commit a83948f

Please sign in to comment.