blocking forever with urllib

Oleg Broytmann phd at phd.pp.ru
Fri Aug 31 06:44:33 EDT 2001


On Fri, 31 Aug 2001, Alex Martelli wrote:
> > > However, urllib.urlopen() takes forever to return.
> > >
> > >     Is there a way to specify a timeout for this library? I can't find a
> way
> > > in the documentation.
> >
> >    There is no. This is actually TCP/IP problem. There are many solutions:
> > signals (unfortunately, signals are sinchronous in Python),
> multiprocessing
> > (forking or threading), non-blocking sockets (select/poll, asyncore).
>
> Probably the best solution in Python is using
> http://www.timo-tasi.org/python/timeoutsocket.py

   Arguable. Among my robots is one based on the timeoutsocket.py - and it
reports more timeouts then forking robot (both robot uses 15 minutes
timeout). So I prefer fork+timeout.

Oleg.
----
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list