Skip to content

Commit 31bd04f

Browse files
Added ability to set the timeout value
1 parent a5de16e commit 31bd04f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

sendgrid/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def __init__(self, apikey, **opts):
3535
self.host = opts.get('host', 'https://api.sendgrid.com')
3636
# urllib cannot connect to SSL servers using proxies
3737
self.proxies = opts.get('proxies', None)
38+
self.timeout = opts.get('timeout', 10)
3839

3940
self.apikeys = APIKeys(self)
4041
self.asm_groups = ASMGroups(self)
@@ -66,7 +67,7 @@ def _build_request(self, url, json_header=False, method='GET', data=None):
6667
if data:
6768
response = urllib_request.urlopen(req, json.dumps(data))
6869
else:
69-
response = urllib_request.urlopen(req, timeout=10)
70+
response = urllib_request.urlopen(req, timeout=self.timeout)
7071
except HTTPError as e:
7172
if 400 <= e.code < 500:
7273
raise SendGridClientError(e.code, e.read())

0 commit comments

Comments
 (0)