reg - timer........

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Feb 26 20:45:30 EST 2008


En Fri, 22 Feb 2008 04:11:56 -0200, Manikandan R <mani.agape at gmail.com>  
escribió:

>         url = 'http:\\username:password at webpage.com'
>         urllib.urlopen(url)
>
>        It opens fine when its correct web page else it hangs there....   
> So I
> have planned to start a timer when i launch the web page, if time  
> exceeds it
> will exit the thread. But I don't know how to do this can U please help  
> me.

Sockets have a .settimeout() method, but it's hard to obtain the socket  
object used by urlopen *before* the connection attempt. So it may be  
easier to set a global timeout with socket.setdefaulttimeout(...)

The in-development version of urlopen.py has timeout support. You might  
try to download and use it; probably requires httplib.py and socket.py too.

http://svn.python.org/view/python/trunk/Lib/urllib.py?view=markup

-- 
Gabriel Genellina




More information about the Python-list mailing list