From: phd at sun.med.ru (Oleg Broytmann)
Date: Mon, 26 Apr 1999 11:38:50 +0400 (MSD)
Subject: timeout on urllib.urlopen?
In-Reply-To: <7g0r7c$gn9$1@nnrp1.dejanews.com>
Message-ID: <Pine.SOL2.3.96.SK.990426113554.2168K-100000@sun.med.ru>
X-UID: 713                                                  

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.





