timeout on urllib.urlopen?

Oleg Broytmann phd at sun.med.ru
Mon Apr 26 03:38:50 EDT 1999


Hello!

On Mon, 26 Apr 1999, Kevin L wrote:
> I'm trying to use urllib.urlopen() on a big list of urls, some of which are
> dead (they don't return a 404, just no response). And the function just waits.
> Is there any way to specify a timeout period for this function? thanks,

   this is well-known problem with sockets. No, there is no simple way to
specify timeout. You should rewrite your program to use either fork() or
threads.
   One thread (or parent process, if you use fork()) controlls another, and
after timeout kill watching thread/process. Recently I rewrote my URL
checker to use fork() (the very checker is under debuggung and soon to be
published).

> Kevin

Oleg.
---- 
    Oleg Broytmann  National Research Surgery Centre  http://sun.med.ru/~phd/
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list