From: Peter H. <pe...@en...> - 2005-12-02 15:33:02
|
T. S. Ferreira wrote: > I installed version 2.1.0 and ran the test suite. Everything went fine > but at the end I got the message: > ----------------------------------- > Unhandled exception in thread started by > Error in sys.excepthook: > > Original exception was: > ----------------------------------- > > My system is Linux Fedora Core 4, and Python 2.4.1. > > Any hints? This looks very much like the (not widely) known problem of shutting down the python interpreter while a daemon thread is still running. What happens is the main thread exits (because only daemon threads are left running), and then the interpreter walks through everything in sys.modules and rebinds all module global names to None. While it's doing this (a process which is pretty quick, but not instantaneous), the daemon thread(s) might have a chance to run again for a moment, and if the running one tries to access one of its globals, it usually raise an exception because of the None-substitution. One alternative for you is to close your eyes briefly after the test completes, type "clear" or "cls", re-open your eyes and carry on as though nothing happened. I do that most of the time. Another solution is to modify the code so that threads are properly terminated. Depending on the code in question this can be either trivial (e.g. a simple "time.sleep()" *might* be enough, but only if the daemon threads are already on their way to stopping themselves but just need a little extra time), or it can be quite a lot of work (modifying lots of code to replace the threads with your own StoppableThread class, or whatever...). In the end, this sort of thing is basically harmless, although an annoying wart. -Peter |