diff --git a/s3iam.py b/s3iam.py index 169cdf6..2325ef0 100755 --- a/s3iam.py +++ b/s3iam.py @@ -233,9 +233,9 @@ def get_role(self): "http://169.254.169.254", "/latest/meta-data/iam/security-credentials/" )) - + try: - response = urllib2.urlopen(request) + response = urllib2.urlopen(request, timeout=1) self.iamrole = (response.read()) except Exception: response = None @@ -257,7 +257,7 @@ def get_credentials(self): ), self.iamrole)) try: - response = urllib2.urlopen(request) + response = urllib2.urlopen(request, timeout=1) data = json.loads(response.read()) self.access_key = data['AccessKeyId'] self.secret_key = data['SecretAccessKey'] @@ -315,7 +315,7 @@ def get_instance_region(self): response = None try: - response = urllib2.urlopen(request) + response = urllib2.urlopen(request, timeout=1) data = response.read() finally: if response: @@ -345,7 +345,7 @@ def urlgrab(self, url, filename=None, **kwargs): out = open(filename, 'w+') while retries > 0: try: - response = urllib2.urlopen(request) + response = urllib2.urlopen(request, timeout=1) buff = response.read(BUFFER_SIZE) while buff: out.write(buff)