urllib.urlretrieve never returns???

Laszlo Nagy gandalf at shopzeus.com
Sat Mar 17 18:31:33 CET 2012


2012.03.17. 17:34 keltezéssel, Chris Angelico wrote
> 2012/3/18 Laszlo Nagy<gandalf at shopzeus.com>:
>> In the later case, "log.txt" only contains "#1" and nothing else. If I look
>> at pythonw.exe from task manager, then its shows +1 thread every time I
>> click the button, and "#1" is appended to the file.
>          try:
>              fpath = urllib.urlretrieve(imgurl)[0]
>          except:
>              self.Log(traceback.format_exc())
>              return
>
>
> Just a stab in the dark, but I'm wondering if something's throwing an
> exception when it's running without a GUI? Your except clause
> references 'traceback' which I don't see anywhere else - or is that
> part of the code you can't share? Anyway, my guess is that something
> perhaps tries to write to the console and can't, and it gets stuck
> inside format_exc(). Is that testable?
You are right, I should have added "import traceback". However, I tried 
this:

         try:
             fpath = urllib.urlretrieve(imgurl)[0]
         except:
             self.Log("Exception")
             return


and still nothing was logged. Another proof is that the number of 
threads is increased every time I press the button. So I'm 100% sure 
that urlretrieve does not return from the call.





More information about the Python-list mailing list