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

Set timeout for requests #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion africastalking/Service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import threading
import requests

TIMEOUT = 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felixcheruiyot Why use 10 seconds as the default?


def validate_currency(currency_str):
return len(currency_str) == 3
Expand Down Expand Up @@ -81,7 +82,7 @@ def _init_service(self):

@staticmethod
def __make_get_request(url, headers, data, params, callback=None):
res = requests.get(url=url, headers=headers, params=params, data=data)
res = requests.get(url=url, headers=headers, params=params, data=data, timeout=TIMEOUT)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felixcheruiyot would it not be better to have the timeout value come all the way from the exposed methods? e.g.

....
sms.send("Hello Message!", ["+2547xxxxxx"],  connectionOptions = { "timeoutSeconds": 10 })


if callback is None or callback == {}:
return res
Expand All @@ -95,6 +96,7 @@ def __make_post_request(url, headers, data, params, callback=None):
headers=headers,
params=params,
data=data,
timeout=TIMEOUT
)
if callback is None or callback == {}:
return res
Expand Down