Comment 2 for bug 869492

Revision history for this message
Scott Moser (smoser) wrote :

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.