Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #56876 > unrolled thread
| Started by | Jérôme <jerome@jolimont.fr> |
|---|---|
| First post | 2013-10-16 11:21 +0200 |
| Last post | 2013-10-16 07:58 -0400 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
urllib2 timeout issue Jérôme <jerome@jolimont.fr> - 2013-10-16 11:21 +0200
Re: urllib2 timeout issue Piet van Oostrum <piet@vanoostrum.org> - 2013-10-16 07:58 -0400
| From | Jérôme <jerome@jolimont.fr> |
|---|---|
| Date | 2013-10-16 11:21 +0200 |
| Subject | urllib2 timeout issue |
| Message-ID | <mailman.1110.1381915633.18130.python-list@python.org> |
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.
--
Jérôme
[toc] | [next] | [standalone]
| From | Piet van Oostrum <piet@vanoostrum.org> |
|---|---|
| Date | 2013-10-16 07:58 -0400 |
| Message-ID | <m2iowxfmv2.fsf@cochabamba.vanoostrum.org> |
| In reply to | #56876 |
Jérôme <jerome@jolimont.fr> writes:
> 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 ?
>
I would guess the difference to be caused by DNS. Maybe the DNS configuration on the RPi is not optimal.
--
Piet van Oostrum <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web