--- /usr/lib/python2.5/threading.py.orig 2008-02-04 13:58:18.000000000 -0600 +++ ./threading.py 2008-02-05 11:55:33.000000000 -0600 @@ -472,34 +472,18 @@ _sys.stderr.write("Exception in thread %s:\n%s\n" % (self.getName(), _format_exc())) else: - # Do the best job possible w/o a huge amt. of code to - # approximate a traceback (code ideas from - # Lib/traceback.py) - exc_type, exc_value, exc_tb = self.__exc_info() - try: - print>>self.__stderr, ( - "Exception in thread " + self.getName() + - " (most likely raised during interpreter shutdown):") - print>>self.__stderr, ( - "Traceback (most recent call last):") - while exc_tb: - print>>self.__stderr, ( - ' File "%s", line %s, in %s' % - (exc_tb.tb_frame.f_code.co_filename, - exc_tb.tb_lineno, - exc_tb.tb_frame.f_code.co_name)) - exc_tb = exc_tb.tb_next - print>>self.__stderr, ("%s: %s" % (exc_type, exc_value)) - # Make sure that exc_tb gets deleted since it is a memory - # hog; deleting everything else is just for thoroughness - finally: - del exc_type, exc_value, exc_tb + # If _sys is missing, then the interpreter is shutting + # down and the thread should no longer exist. If this + # happens, ignore the error and exit gracefully. + pass else: if __debug__: self._note("%s.__bootstrap(): normal return", self) finally: - self.__stop() + # Exceptions will also be raised during stop/delete if the + # interpreter is shutting down. Ignore these as well. try: + self.__stop() self.__delete() except: pass