Another solution is using a deliberately misconfigured proxy:
import socket
socket.setdefaulttimeout(1)
import urllib
proxies = {'http': 'http://www.example.com:3128'}
url = 'http://www.google.com/'
opener = urllib.FancyURLopener(proxies)
f = opener.open(url)
print f.read()>From this code I get the following exception: "IOError: [Errno socket error] timed out" ...and that fits my needs nicely. -- Adam Monsen http://adammonsen.com/ -- http://mail.python.org/mailman/listinfo/python-list
