Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sailthru/sailthru-python-client
Browse files Browse the repository at this point in the history
  • Loading branch information
peterzal committed Jul 26, 2018
2 parents 0cd5b62 + b042638 commit 22aa39b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions sailthru/sailthru_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ class SailthruClient(object):
client = SailthruClient(api_key, api_secret)
"""

def __init__(self, api_key, secret, api_url=None):
def __init__(self, api_key, secret, api_url=None, request_timeout=10):
self.api_key = api_key
self.secret = secret
self.api_url = api_url if api_url else 'https://api.sailthru.com'
self.request_timeout = request_timeout
self.last_rate_limit_info = {}

def send(self, template, email, _vars=None, options=None, schedule_time=None, limit=None):
Expand Down Expand Up @@ -762,7 +763,7 @@ def _api_request(self, action, data, request_type, headers=None):
def _http_request(self, action, data, method, file_data=None, headers=None):
url = self.api_url + '/' + action
file_data = file_data or {}
response = sailthru_http_request(url, data, method, file_data, headers)
response = sailthru_http_request(url, data, method, file_data, headers, self.request_timeout)
if (action in self.last_rate_limit_info):
self.last_rate_limit_info[action][method] = response.get_rate_limit_headers()
else:
Expand Down
4 changes: 2 additions & 2 deletions sailthru/sailthru_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def flatten(hash_table, brackets=True):
return f
return flatten(hash_table, False)

def sailthru_http_request(url, data, method, file_data=None, headers=None):
def sailthru_http_request(url, data, method, file_data=None, headers=None, request_timeout=10):
"""
Perform an HTTP GET / POST / DELETE request
"""
Expand All @@ -41,7 +41,7 @@ def sailthru_http_request(url, data, method, file_data=None, headers=None):
else:
headers = sailthru_headers
try:
response = requests.request(method, url, params=params, data=data, files=file_data, headers=headers, timeout=10)
response = requests.request(method, url, params=params, data=data, files=file_data, headers=headers, timeout=request_timeout)
return SailthruResponse(response)
except requests.HTTPError as e:
raise SailthruClientError(str(e))
Expand Down

0 comments on commit 22aa39b

Please sign in to comment.