Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.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: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url:launchpad': 0.05; 'socket': 0.07; 'urllib2': 0.07; 'python': 0.11; '"python': 0.16; 'from:addr:swing.be': 0.16; 'from:addr:vincent.vandevyvre': 0.16; 'from:name:vincent vande vyvre': 0.16; 'message-id:@swing.be': 0.16; 'oqapy': 0.16; 'paqager': 0.16; 'received:mobistar.be': 0.16; 'seconds.': 0.16; 'subject:issue': 0.16; 'url:oqapy': 0.16; 'url:paqager': 0.16; 'url:qarte': 0.16; 'v.v.': 0.16; 'all.': 0.16; 'server,': 0.19; 'not,': 0.20; 'thanks.': 0.20; 'example': 0.22; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'script': 0.25; 'suggested': 0.26; 'skip:" 20': 0.27; 'header:In- Reply-To:1': 0.27; 'tried': 0.27; "i'm": 0.30; 'run': 0.32; 'something': 0.35; 'but': 0.35; 'version': 0.36; "didn't": 0.36; 'skip:- 20': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'normal.': 0.68; 'results': 0.69; 'difference.': 0.84 Date: Wed, 16 Oct 2013 12:04:22 +0200 From: Vincent Vande Vyvre User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: urllib2 timeout issue References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381918324 news.xs4all.nl 15986 [2001:888:2000:d::a6]:53178 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56877 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: > > 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 is normal. -- Vincent V.V. Oqapy . Qarte . PaQager