urllib2 timeout issue

Ervin Hegedüs airween at gmail.com
Thu Oct 17 09:55:06 EDT 2013


Hello,

On Thu, Oct 17, 2013 at 03:34:05PM +0200, Jérôme wrote:
> Hi.
> 
> Thank you all for your answers.
> 
> --------------------------------------------------
> Context:
> 
> The problem I want to address is the code being stuck too long when the
> network is down.
> 
> I'm working on a software gateway running on a Raspberry Pi, that forwards
> data received through a radio link to the network.
> 
> https://github.com/Jerome-github/oem_gateway
> 
> This can be sending HTTP requests every 3 seconds, so a 10 secondes timeout
> is an issue.
> --------------------------------------------------
> 
> I was not at home when I wrote my last message. Now back home, I could try on
> my own Debian Jessie machine (Python 2.7.5+) and I get the same results as
> with the RaspberryPi (long timeout). So there seems to be something going on
> with the router/modem.

Has your router/modem any HTTP proxy feature? If yes, maybe the
proxy gives the late answer.

Anyway, if you don't have proxy, and the DNS error cames from
local system, you can try to decrease it via resolv.conf:

nameserver 1.2.3.4
options timeout:2

It's just an idea... but maybe...

Note that the 2 seconds for DNS timeout in resolv.conf may sound crazy,
because the _real_slow_ DNS answers will be timeouted for any
application - just take a test with it.


Cheers,
Ervin




More information about the Python-list mailing list