diff --git a/sendgrid/sendgrid.py b/sendgrid/sendgrid.py index d222f2a9a..dd08d23cb 100644 --- a/sendgrid/sendgrid.py +++ b/sendgrid/sendgrid.py @@ -51,6 +51,7 @@ def __init__(self, username_or_apikey, password=None, **opts): self.endpoint = opts.get('endpoint', '/api/mail.send.json') self.mail_url = self.host + ':' + self.port + self.endpoint self._raise_errors = opts.get('raise_errors', False) + self.timeout = opts.get('timeout', 10) # urllib cannot connect to SSL servers using proxies self.proxies = opts.get('proxies', None) @@ -109,7 +110,7 @@ def _make_request(self, message): # Using API key req.add_header('Authorization', 'Bearer ' + self.password) - response = urllib_request.urlopen(req, timeout=10) + response = urllib_request.urlopen(req, timeout = self.timeout) body = response.read() return response.getcode(), body