Timeouts with urllib2

Skip Montanaro skip at pobox.com
Tue Mar 16 17:03:14 EST 2004


    Fazer> I was wondering what's the best way of setting timeouts when
    Fazer> working with urllib2.
    >> 
    >> Using 2.3+:
    >> 
    >> >>> import socket
    >> >>> socket.setdefaulttimeout(3)
    >> >>> import urllib2
    >> >>> urllib2.urlopen("http://www.musi-cal.com/search?performers=Greg+Brown")
    ...

    Fazer> Any idea how I can accomplish this in Python 2.2 versions?

Google for timeoutsocket.  There's also timeout_socket.  Two different
implementations of timeouts.

Skip





More information about the Python-list mailing list