urllib hangs

Jay Donnell jaydonnell at yahoo.com
Mon Aug 23 19:02:06 CEST 2004

This is a basic version of my code

for url in urls:
    fp = urllib.urlopen(url)
    lines = fp.readlines()

    #print lines
    for line in lines:
        #print line
            print 'found'
            return 1
            print 'not found'
            return 0

this hangs occasionally for some certain url's. If I do a ctrl-c
(linux) it will move on to the next url. How can I get this to timeout
and move on to the next url.

More information about the Python-list mailing list