зеркало из https://github.com/mozilla/treeherder.git
Merge pull request #537 from MikeLing/bugfix-1160873
Bug 1160873 - Add timeout to requests that are missing them
This commit is contained in:
Коммит
57af1d7e2d
|
@ -140,6 +140,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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -29,7 +29,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())
|
||||
|
@ -50,7 +50,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):
|
||||
|
|
Загрузка…
Ссылка в новой задаче