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

Conversation

felixcheruiyot
Copy link

It is important to set timeout for requests.post and requests.get to avoid blocking other requests in case AT takes time to respond

@@ -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?

@@ -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 })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants