Michele Petrazzo wrote: > I have a wxpython application (the main program) and a lot of external > modules (import mymodule) that use always 2 thread (one is my > application and one is twisted with new threadselectreactor). > Sometime when I close my app, I receive a thread error that I want to > redirect to a file (I don't know why this error occur, but this is > another problem...).
This looks like it must be an exception in a *daemon* thread that is still running even as the Python interpreter dismantles itself at application exit. > This is the exception: > > Unhandled exception in thread started by <bound method > Thread.__bootstrap of <Thread(Thread-1, stopped daemon)>> > Traceback (most recent call last): > File "C:\Python23\lib\threading.py", line 451, in __bootstrap > self.__stop() > File "C:\Python23\lib\threading.py", line 460, in __stop > self.__block.notifyAll() > File "C:\Python23\lib\threading.py", line 256, in notifyAll > self.notify(len(self.__waiters)) > File "C:\Python23\lib\threading.py", line 238, in notify > currentThread() # for side-effect > TypeError: 'NoneType' object is not callable One of the steps the interpreter takes is to go through all modules and rebind all globals to None. I suspect currentThread is a global in the above (although I thought that particular issue was fixed in Python 2.4... are you running an older version?). The "simplest" thing to do is to ignore this exception because it's spurious". One way to ignore it is simply to wrap that particular daemon thread's "run" method with a "try/except: pass" so that all exceptions are swallowed quietly. Often that's not preferable, however, since it will of course swallow real exceptions too. The "safest" thing to do is to terminate that daemon thread before the application exits. That basically means setting it to be a daemon thread is sort of pointless, but there's not really a much better solution. A google search for "python interpreter thread bind global none" or something awful like that will probably turn up some background material, likely written by Tim Peters. :-) -Peter -- http://mail.python.org/mailman/listinfo/python-list