Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!ecngs!feeder2.ecngs.de!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.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.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'socket': 0.07; 'urllib2': 0.07; 'python': 0.11; '"python': 0.16; 'seconds.': 0.16; 'subject:issue': 0.16; 'all.': 0.16; 'server,': 0.19; 'thanks.': 0.20; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'script': 0.25; 'suggested': 0.26; 'tried': 0.27; "i'm": 0.30; 'run': 0.32; 'received:fr': 0.33; '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; 'from:charset:utf-8': 0.61; 'results': 0.69; 'difference.': 0.84 To: Subject: urllib2 timeout issue X-PHP-Originating-Script: 0:main.inc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: Wed, 16 Oct 2013 11:21:00 +0200 From: =?UTF-8?Q?J=C3=A9r=C3=B4me?= X-Sender: jerome@jolimont.fr User-Agent: Roundcube Webmail/0.7.2 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: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381915633 news.xs4all.nl 15901 [2001:888:2000:d::a6]:42733 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56876 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. -- Jérôme