From 31bd04fa96b2729a48c3e7728873409d9c473ca5 Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Mon, 8 Feb 2016 10:07:26 -0800 Subject: [PATCH] Added ability to set the timeout value --- sendgrid/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sendgrid/client.py b/sendgrid/client.py index 6b220b50c..6a389de29 100644 --- a/sendgrid/client.py +++ b/sendgrid/client.py @@ -35,6 +35,7 @@ def __init__(self, apikey, **opts): self.host = opts.get('host', 'https://api.sendgrid.com') # urllib cannot connect to SSL servers using proxies self.proxies = opts.get('proxies', None) + self.timeout = opts.get('timeout', 10) self.apikeys = APIKeys(self) self.asm_groups = ASMGroups(self) @@ -66,7 +67,7 @@ def _build_request(self, url, json_header=False, method='GET', data=None): if data: response = urllib_request.urlopen(req, json.dumps(data)) else: - response = urllib_request.urlopen(req, timeout=10) + response = urllib_request.urlopen(req, timeout=self.timeout) except HTTPError as e: if 400 <= e.code < 500: raise SendGridClientError(e.code, e.read())