On Fri, Aug 29, 2014 at 2:23 AM, Chris Kaynor <ckay...@zindagigames.com> wrote: > If what you want is to make sure the error is not printed to stderr, you'll > just need to make sure the thread's run function does not exit with an > exception. The simpliest way to do that would be to wrap the entire thread's > run function in a try...catch statement, like so: > > class Thread(threading.Thread) > ... > except Exception as err:
This is actually something where it may be appropriate to catch BaseException, since you are terminating the thread immediately anyway. If you get a KeyboardInterrupt or something, you'll catch it, log it, and end the thread. Note, though, that retaining the actual error object risks resource leakage. You glom onto all sorts of locals, via the backtrace. Unless you're going to handle the exception and then dispose of the whole thread object, I'd advise caution; maybe consider taking a textual snapshot of the backtrace. ChrisA -- https://mail.python.org/mailman/listinfo/python-list