Add timeout for URL queries

This commit is contained in:
Daniel Goldberg 2018-12-27 17:14:13 +02:00
parent 627f34f1f2
commit 796ac48c72
1 changed files with 1 additions and 1 deletions

View File

@ -6,7 +6,7 @@ __author__ = 'itay.mizeretz'
class AWS(object):
def __init__(self):
try:
self.instance_id = urllib2.urlopen('http://169.254.169.254/latest/meta-data/instance-id').read()
self.instance_id = urllib2.urlopen('http://169.254.169.254/latest/meta-data/instance-id', timeout=2).read()
except urllib2.URLError:
self.instance_id = None