disabling TCP connections, just for one script
Adam Monsen
haircut at gmail.com
Fri Sep 9 17:03:58 EDT 2005
More information about the Python-list mailing list
Fri Sep 9 17:03:58 EDT 2005
- Previous message (by thread): disabling TCP connections, just for one script
- Next message (by thread): disabling TCP connections, just for one script
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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/
- Previous message (by thread): disabling TCP connections, just for one script
- Next message (by thread): disabling TCP connections, just for one script
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list