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

Laszlo Nagy gandalf at shopzeus.com
Tue Mar 20 16:42:28 EDT 2012


> 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




More information about the Python-list mailing list