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())