Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #57041

Re: urllib2 timeout issue

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.datemas.de!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jerome@jolimont.fr>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'urllib2': 0.07; 'escape': 0.09; 'explanation': 0.09; 'function,': 0.09; 'http': 0.09; 'parameter': 0.09; 'skip:/ 10': 0.09; 'topic:': 0.09; 'bug': 0.12; 'expect,': 0.16; 'header:X-Face:1': 0.16; 'proxy,': 0.16; 'simplest': 0.16; 'subject:issue': 0.16; 'timeout': 0.16; 'urllib2,': 0.16; 'all.': 0.16; 'so.': 0.16; 'discussion': 0.18; 'thu,': 0.19; 'meant': 0.20; 'solution.': 0.20; 'error': 0.23; 'config': 0.24; 'proxy': 0.24; 'satisfying': 0.24; 'question': 0.24; "i've": 0.25; 'options': 0.25; '+0200': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'gives': 0.31; 'software,': 0.31; 'that.': 0.31; 'yes.': 0.31; 'there.': 0.32; 'not.': 0.33; 'received:fr': 0.33; 'maybe': 0.34; "i'd": 0.34; 'anywhere': 0.35; 'something': 0.35; 'late': 0.35; 'test': 0.35; 'but': 0.35; 'add': 0.35; 'really': 0.36; 'shorter': 0.36; "didn't": 0.36; 'seconds': 0.37; 'application': 0.37; 'system,': 0.38; 'machines': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'rather': 0.38; 'anything': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'according': 0.40; 'even': 0.60; 'skip:u 10': 0.60; 'solve': 0.60; 'from:charset:utf-8': 0.61; 'received:62': 0.63; 'myself': 0.63; 'answer.': 0.68; 'sound': 0.68; 'besides,': 0.93; '2013': 0.98
X-Spam-Checker-Version SpamAssassin 3.3.1 (2010-03-16) on jeftof
X-Spam-Level
X-Spam-Status No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable version=3.3.1
Date Fri, 18 Oct 2013 13:19:07 +0200
From Jérôme <jerome@jolimont.fr>
To python-list@python.org
Subject Re: urllib2 timeout issue
In-Reply-To <20131017135505.GA7386@arxnet.hu>
References <acf47c27e418951eae9d050f8d3ccfba@jolimont.fr> <20131017153405.3703a916@bouzin.lan> <20131017135505.GA7386@arxnet.hu>
X-Mailer Claws Mail 3.9.2 (GTK+ 2.24.21; x86_64-pc-linux-gnu)
X-Face "kBB1-!wF@,"j_&tJ&7; T,t)PeQkZg5?.:{p,s>/,+?b6pN5!yxZy^nRXA=*?W+|J9OG!W[rdx^VA^Sx`R"g,; +MzhAq"tZFg27W4qX+ZXvLX=%piZ6c.7@oSDHyQ0Mff#HGx<{
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1218.1382095070.18130.python-list@python.org> (permalink)
Lines 58
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1382095070 news.xs4all.nl 15986 [2001:888:2000:d::a6]:48576
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57041

Show key headers only | View raw


Thu, 17 Oct 2013 15:55:06 +0200
Ervin Hegedüs a écrit:

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

I don't think so. I didn't find anything like this in the config.
 
> 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.

Yes. See my former message :

> I found this on my server's config:
> 
> options timeout:1
> 
> I added it to /etc/resolv.conf on my Pi and PC and I get a much shorter
> timeout, yet still longer than the value I enter, longer than I expect, and
> longer that what I have on other machines (instantaneous).
> 
> But at least I see something happening.

This was not a really satisfying solution.

Besides, I'd rather solve the issue in the software, so that it works
anywhere without the user having to play with DNS config and all. Even if the
discussion on my DNS config is interesting, my question was about
urllib2.urlopen() timeout. I thought the timeout parameter was meant to
escape those long delays. Apparently, it is not.

According to this SO topic:

http://stackoverflow.com/questions/14127115/python-2-6-urlib2-timeout-issue

urllib2 does not do that.

Some workarounds are suggested.

Perhaps the simplest solution for me would be to create my own urlopen()
function, that would call urllib2's, and add a timeout in there.

I don't get the logic, here. I would call it a bug in urllib2, but I won't
allow myself to do that until I've understood the explanation on SO.

-- 
Jérôme

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: urllib2 timeout issue Jérôme <jerome@jolimont.fr> - 2013-10-18 13:19 +0200

csiph-web