Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse connections when making API calls #14

Merged
merged 1 commit into from
May 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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