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


Groups > comp.lang.python > #56877 > unrolled thread

Re: urllib2 timeout issue

Started byVincent Vande Vyvre <vincent.vandevyvre@swing.be>
First post2013-10-16 12:04 +0200
Last post2013-10-16 09:06 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: urllib2 timeout issue Vincent Vande Vyvre <vincent.vandevyvre@swing.be> - 2013-10-16 12:04 +0200
    Re: urllib2 timeout issue Tobiah <toby@tobiah.org> - 2013-10-16 09:06 -0700

#56877 — Re: urllib2 timeout issue

FromVincent Vande Vyvre <vincent.vandevyvre@swing.be>
Date2013-10-16 12:04 +0200
SubjectRe: urllib2 timeout issue
Message-ID<mailman.1111.1381918324.18130.python-list@python.org>
Le 16/10/2013 11:21, Jérôme a écrit :
> Hi all.
>
> I'm having troubles with urllib2 timeout.
>
> See the following script :
>
> ----------------------------
> import urllib2
> result = urllib2.urlopen("http://dumdgdfgdgmyurl.com/")
> print result.readline()
> ----------------------------
>
> If run on my Debian Wheezy computer, or on my Debian Squeeze server,
> the answer is instantaneous :
>
> [...]
> urllib2.URLError: <urlopen error [Errno -2] Name or service not known>
>
> When run on my Raspberry Pi with Raspian Wheezy, the answer is
> identical but it takes 10 seconds.
>
> I tried
>
>      result = urllib2.urlopen("http://dumdgdfgdgmyurl.com/", timeout=5)
>
> but I get the same results : instantaneous on Debian, 10 secondes on
> RPi.
>
> I also added this, as suggested on some StackOverflow pages :
>
>      import socket
>      socket.setdefaulttimeout(5)
>
> and it didn't make any difference.
>
> In both cases, Python version is "Python 2.7.3".
>
> Am I missing something ?
>
> Thanks.
>
The url "dumdgdfgdgmyurl.com/" is just an example ?

If not, the result  <urlopen error [Errno -2] Name or service not known> 
is normal.
-- 
Vincent V.V.
Oqapy <https://launchpad.net/oqapy> . Qarte 
<https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager>

[toc] | [next] | [standalone]


#56884

FromTobiah <toby@tobiah.org>
Date2013-10-16 09:06 -0700
Message-ID<9Qy7u.25401$eE7.10473@fx21.iad>
In reply to#56877
>> If run on my Debian Wheezy computer, or on my Debian Squeeze server,
>> the answer is instantaneous :
>>
>> [...]
>> urllib2.URLError: <urlopen error [Errno -2] Name or service not known>
>>
>> When run on my Raspberry Pi with Raspian Wheezy, the answer is
>> identical but it takes 10 seconds.

What happens when you use ping to resolve that address.  Do you get
the same results?  If so, I'd say you have a DNS problem.  Maybe
you have two DNS servers listed in /etc/resolv.conf or similar, and
the first one is unavailable, so it takes 10 seconds to fail over
to the second working server.

Tobiah

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web