8000 Add support for session pooling at the Client layer. Set default to True by pshafton · Pull Request #375 · twilio/twilio-python · GitHub
[go: up one dir, main page]

Skip to content

Add support for session pooling at the Client layer. Set default to True #375

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

Merged
merged 1 commit into from
Jul 14, 2017
Merged
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
13 changes: 11 additions & 2 deletions twilio/http/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ class TwilioHttpClient(HttpClient):
"""
General purpose HTTP Client for interacting with the Twilio API
"""
def __init__(self, connection_pool=True):
if connection_pool:
self.session = Session()
self.session.verify = get_cert_file()
else:
self.session = None

def request(self, method, url, params=None, data=None, headers=None, auth=None, timeout=None,
allow_redirects=False):
"""
Expand All @@ -26,8 +33,10 @@ def request(self, method, url, params=None, data=None, headers=None, auth=None,
:return: An http response
:rtype: A :class:`Response <twilio.rest.http.response.Response>` object
"""
session = Session()
session.verify = get_cert_file()
session = self.session
if session is None:
session = Session()
session.verify = get_cert_file()

request = Request(method.upper(), url, params=params, data=data, headers=headers, auth=auth)

Expand Down
0