[EMAIL PROTECTED] wrote:
More generally you may wish to use the timeout features of TCP sockets. These were introduced in Python 2.3, though Tim O'Malley's module "timeoutsocket" (which was the inspiration for the 2.3 upgrade) was available for earlier versions.#import urllib, sys #pages = ['http://www.python.org', 'http://xxx'] #for i in pages: # try: # u = urllib.urlopen(i) # print u.geturl() # except Exception, e: # print >> sys.stderr, '%s: %s' % (e.__class__.__name__, e) will print an error if a page fails opening, rest opens fine
You will need to import the socket module and then call socket.setdefaulttimeout() to ensure that communication with non-responsive servers results in a socket exception that you can trap.
regards Steve -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list