urllib2 occasionally hanging

Dave Brueck dave at pythonapocrypha.com
Tue Nov 5 11:20:49 EST 2002


On Mon, 4 Nov 2002, Ron Alford [KB0NUV] wrote:

> I have a python program running on a win2k machine (python version 2.2.1).
> The specific part of the program that I'm concerned with is a simple
> urlopen that runs every 5 minutes or so. The line reads: 
> 
> furl = urllib2.urlopen(updateURL)
> 
> Every so often, this call will go out, and never, ever return.  It doesn't
> seem to leave a trace in the web server's log.  I have a deep suspicion
> that this is a syscall that's getting hung up and never returning.
> 
> Anyone have a cute trick around this?

Try using the timeoutsocket module (find it via Goodle). Also, Python 2.3 
has socket timeouts built-in.

-Dave





More information about the Python-list mailing list