diff --git a/deployment/update/update.py b/deployment/update/update.py index e62a2f32f..686283636 100644 --- a/deployment/update/update.py +++ b/deployment/update/update.py @@ -141,6 +141,6 @@ def ping_newrelic(ctx): try: request = urllib2.Request('https://api.newrelic.com/deployments.xml', data, headers) - urllib2.urlopen(request) + urllib2.urlopen(request, timeout=30) except urllib2.URLError as exp: print 'Error notifying New Relic: {0}'.format(exp) diff --git a/treeherder/etl/classification_mirroring.py b/treeherder/etl/classification_mirroring.py index dc36350e5..3430aee6a 100644 --- a/treeherder/etl/classification_mirroring.py +++ b/treeherder/etl/classification_mirroring.py @@ -74,7 +74,7 @@ class ElasticsearchDocRequest(object): es_url = "".join([es_host, es_endpoint]) logger.info("Sending data to %s: %s", es_url, self.body) headers = {'Content-Type': 'text/plain', 'Connection': 'close'} - r = requests.post(es_url, data=json.dumps(self.body), headers=headers) + r = requests.post(es_url, data=json.dumps(self.body), headers=headers, timeout=settings.TREEHERDER_REQUESTS_TIMEOUT) try: r.raise_for_status() except requests.exceptions.HTTPError: @@ -165,7 +165,7 @@ class BugzillaCommentRequest(object): credentials = {'login': settings.TBPLBOT_EMAIL, 'password': settings.TBPLBOT_PASSWORD} headers = {'Accept': 'application/json', 'Content-Type': 'application/json'} logger.info("Sending data to %s: %s", api_url, self.body) - r = requests.post(api_url, params=credentials, data=json.dumps(self.body), headers=headers) + r = requests.post(api_url, params=credentials, data=json.dumps(self.body), headers=headers, timeout=settings.TREEHERDER_REQUESTS_TIMEOUT) try: r.raise_for_status() except requests.exceptions.HTTPError: diff --git a/treeherder/etl/mixins.py b/treeherder/etl/mixins.py index c422c0629..6db100bcc 100644 --- a/treeherder/etl/mixins.py +++ b/treeherder/etl/mixins.py @@ -31,7 +31,7 @@ class JsonExtractorMixin(object): req.add_header('Accept', 'application/json') req.add_header('Content-Type', 'application/json') try: - handler = urllib2.urlopen(req) + handler = urllib2.urlopen(req, timeout=settings.TREEHERDER_REQUESTS_TIMEOUT) encoding = handler.info().get('Content-Encoding') if encoding and 'gzip' in encoding: buf = StringIO(handler.read()) @@ -52,7 +52,7 @@ class JsonLoaderMixin(object): req.add_header('Content-Type', 'application/json') if not data: data = None - return urllib2.urlopen(req, json.dumps(data)) + return urllib2.urlopen(req, json.dumps(data), timeout=settings.TREEHERDER_REQUESTS_TIMEOUT) class ObjectstoreLoaderMixin(JsonLoaderMixin):