configure 'time out' time for urllib

Andreas Dahl dahl at
Thu Feb 26 12:24:33 CET 2004


I use urllib to retrieve data via HTTP. Unfortunately my program crashes
after a while (after some loops) because the connection timed out.

raise socket.error, msg
IOError: [Errno socket error] (60, 'Connection timed out')

I am not so familiar with python, but is there a possibility to
configure the 'waiting time'? Or how can I handle such an event? To skip
that query and go to the next one would also work.

Many thanks in advance, Andreas

    params = urllib.urlencode({'rs': rs})
        file =
urllib.urlopen("" %
    except IOError, message: # file open failed
        print >> sys.stderr, "File could not be opend:", message
    data = file.readlines() # array with html-doc-content

More information about the Python-list mailing list