urllib.urlretrieve never returns???

Chris Angelico rosuav at gmail.com
Sat Mar 17 17:34:05 CET 2012


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? For instance, replace the
"fpath=" line with "fpath = 1/0" to raise WhatKindOfIdiotAreYouError
(it's spelled differently, but that's what the computer thinks of
people who ask it to divide by zero) - see what that does. Or maybe
add self.log("#1.5") at the beginning of the except: clause.

Without all your code, I can't actually run it to test, so it's
entirely possible that I'm completely wrong here.

ChrisA



More information about the Python-list mailing list