[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: reg - timer........

Gabriel Genellina

2/27/2008 1:46:00 AM

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

> url = 'http:\\username:password@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?v...

--
Gabriel Genellina