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

Adding timeout to TwilioHttpClient constructor #485

Merged
merged 4 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ We'd like to thank the following people who have contributed to the
- Evan Cooke
- tysonholub
- Brodan
- Kyle Jones <kylejones1310@outlook.com>
5 changes: 3 additions & 2 deletions twilio/http/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ class TwilioHttpClient(HttpClient):
"""
General purpose HTTP Client for interacting with the Twilio API
"""
def __init__(self, pool_connections=True, request_hooks=None):
def __init__(self, pool_connections=True, request_hooks=None, timeout=None):
self.session = Session() if pool_connections else None
self.last_request = None
self.last_response = None
self.request_hooks = request_hooks or hooks.default_hooks()
self.timeout = timeout

def request(self, method, url, params=None, data=None, headers=None, auth=None, timeout=None,
allow_redirects=False):
Expand Down Expand Up @@ -65,7 +66,7 @@ def request(self, method, url, params=None, data=None, headers=None, auth=None,
response = session.send(
prepped_request,
allow_redirects=allow_redirects,
timeout=timeout,
timeout=timeout if timeout is not None else self.timeout,
eshanholtz marked this conversation as resolved.
Show resolved Hide resolved
)

_logger.info('{method} Response: {status} {text}'.format(method=method, status=response.status_code, text=response.text))
Expand Down