I can reproduce this from inside this instance with the following program: #!/usr/bin/python import urllib2, sys, socket def doget(iurl, timeout): reason = None try: req = urllib2.Request(iurl) resp = urllib2.urlopen(req, timeout=timeout) except urllib2.HTTPError as e: reason = "http error [%s]" % e.code except urllib2.URLError as e: reason = "url error [%s]" % e.reason except socket.timeout as e: reason = "socket timeout [%s]" % e if reason: print "Fail: %s" % reason
doget(sys.argv[1],float(sys.argv[2]))
I run it and see the following output: $ ./test-timeout.py http://169.254.169.254/latest/meta-data/instance-id 1 Fail: socket timeout [timed out]
It seams that urllib2 does not catch socket timeouts, so we'll have to add that catch, and I think we should probably up the default timeout.
I can reproduce this from inside this instance with the following program: Request( iurl) urlopen( req, timeout=timeout)
#!/usr/bin/python
import urllib2, sys, socket
def doget(iurl, timeout):
reason = None
try:
req = urllib2.
resp = urllib2.
except urllib2.HTTPError as e:
reason = "http error [%s]" % e.code
except urllib2.URLError as e:
reason = "url error [%s]" % e.reason
except socket.timeout as e:
reason = "socket timeout [%s]" % e
if reason:
print "Fail: %s" % reason
doget(sys. argv[1] ,float( sys.argv[ 2]))
I run it and see the following output: 169.254. 169.254/ latest/ meta-data/ instance- id 1
$ ./test-timeout.py http://
Fail: socket timeout [timed out]
It seams that urllib2 does not catch socket timeouts, so we'll have to add that catch, and I think we should probably up the default timeout.