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


Groups > comp.lang.python > #21951

Re: urllib.urlretrieve never returns??? [SOLVED] - workaround

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <gandalf@shopzeus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.036
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'debug': 0.03; 'wxpython': 0.07; 'finally:': 0.09; 'def': 0.13; 'c.close()': 0.16; 'demo:': 0.16; 'except:': 0.16; 'fout': 0.16; 'fout.close()': 0.16; 'installs': 0.16; 'test()': 0.16; 'thread.': 0.16; 'maybe': 0.21; 'header:In-Reply-To:1': 0.22; 'replacing': 0.23; 'smallest': 0.23; 'code': 0.26; 'somebody': 0.28; 'separate': 0.28; 'subject:skip:u 10': 0.29; 'class': 0.29; 'problem': 0.29; 'header:User-Agent:1': 0.33; 'someone': 0.34; 'try:': 0.34; 'thank': 0.35; 'to:addr :python-list': 0.35; 'be.': 0.35; 'core': 0.36; 'example,': 0.37; 'help!': 0.37; 'but': 0.37; 'skip:" 10': 0.37; 'skip:_ 10': 0.38; "i'll": 0.38; 'received:192': 0.38; 'some': 0.38; 'except': 0.39; 'to:addr:python.org': 0.40; 'your': 0.61; 'received:62': 0.70; 'skip:w 50': 0.73; 'console,': 0.84; 'modes:': 0.84; 'received:192.168.13': 0.84; 'received:62.179': 0.84; 'received:62.179.121': 0.84; 'received:upcmail.net': 0.84
X-SourceIP 80.99.162.160
Date Tue, 20 Mar 2012 21:42:28 +0100
From Laszlo Nagy <gandalf@shopzeus.com>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version 1.0
To python-list@python.org
Subject Re: urllib.urlretrieve never returns??? [SOLVED] - workaround
References <4F649BFC.1080601@shopzeus.com> <jk2khh$e36$1@dough.gmane.org> <4F66E687.2050008@shopzeus.com> <mailman.815.1332185597.3037.python-list@python.org> <4f67c09b$0$29981$c3e8da3$5496439d@news.astraweb.com> <4F682CDC.5000703@shopzeus.com> <4F68E49C.2060000@shopzeus.com>
In-Reply-To <4F68E49C.2060000@shopzeus.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.843.1332276159.3037.python-list@python.org> (permalink)
Lines 54
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1332276159 news.xs4all.nl 6936 [2001:888:2000:d::a6]:42729
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:21951

Show key headers only | View raw


> I'll be experimenting with pyCurl now.
By replacing the GetThumbnail method with this brainless example, taken 
from the pyCurl demo:


     def GetThumbnail(self,imgurl):
         class Test:
             def __init__(self):
                 self.contents = ''

             def body_callback(self, buf):
                 self.contents = self.contents + buf

         self.Log("#1: "+repr(imgurl))
         try:
             t = Test()
             c = pycurl.Curl()
             c.setopt(c.URL, imgurl)
             c.setopt(c.WRITEFUNCTION, t.body_callback)
             self.Log("#2")
             c.perform()
             self.Log("#3")
             c.close()
             self.Log("#4")
             fpath = os.path.join(os.environ["TEMP"],"thumbnail.jpg")
             fout = open(fpath,"wb+")
             self.Log("#5: "+repr(fpath))
             try:
                 fout.write(t.contents)
             finally:
                 fout.close()
             self.Log("#6")
         except:
             self.Log(traceback.format_exc())
             return
         self.Log("#7")
         wx.CallAfter(self.imgProduct.SetPage,"""<html><body><img 
src="%s"></body></html>"""%fpath)
         self.Log("#8")

Everything works perfectly, in all modes: console, no console, started 
directly and started in separate thread.

So the problem with urllib must be. Maybe wxPython installs some except 
hooks, or who knows? If somebody feels up to it, I can start narrowing 
down the problem to the smallest possible application. But only if 
someone knows how to debug core code because I don't. Otherwise I'll 
just use pyCURL.

Thank you for your help!

    Laszlo

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


Thread

Re: urllib.urlretrieve never returns??? Laszlo Nagy <gandalf@shopzeus.com> - 2012-03-19 20:32 +0100
  Re: urllib.urlretrieve never returns??? Jon Clements <joncle@googlemail.com> - 2012-03-19 16:04 -0700
  Re: urllib.urlretrieve never returns??? Jon Clements <joncle@googlemail.com> - 2012-03-19 16:04 -0700
  Re: urllib.urlretrieve never returns??? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-19 23:26 +0000
    Re: urllib.urlretrieve never returns??? Laszlo Nagy <gandalf@shopzeus.com> - 2012-03-20 08:08 +0100
    Re: urllib.urlretrieve never returns??? Laszlo Nagy <gandalf@shopzeus.com> - 2012-03-20 21:12 +0100
    Re: urllib.urlretrieve never returns??? [SOLVED] - workaround Laszlo Nagy <gandalf@shopzeus.com> - 2012-03-20 21:42 +0100
    RE: urllib.urlretrieve never returns??? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-20 20:52 +0000
    Re: urllib.urlretrieve never returns??? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-03-20 17:14 -0400
    RE: urllib.urlretrieve never returns??? [SOLVED] - workaround "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-20 21:25 +0000
    RE: urllib.urlretrieve never returns??? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-20 21:26 +0000
    RE: urllib.urlretrieve never returns??? [SOLVED] - workaround "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-20 21:01 +0000
    Re: urllib.urlretrieve never returns??? Laszlo Nagy <gandalf@shopzeus.com> - 2012-03-21 13:38 +0100
    RE: urllib.urlretrieve never returns??? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-22 15:25 +0000

csiph-web