[Python-Dev] threading bug? (original) (raw)
Guido van Rossum guido@python.org
Fri, 05 Oct 2001 15:09:43 -0400
- Previous message: [Python-Dev] threading bug?
- Next message: [Python-Dev] threading bug?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> > Unhandled exception in thread: > > Traceback (most recent call last): _> > File "c:\python21\lib\threading.py", line 393, in bootstrap _> > self.stop() _> > File "c:\python21\lib\threading.py", line 399, in stop _> > self.block.notifyAll() > > File "c:\python21\lib\threading.py", line 235, in notifyAll _> > self.notify(len(self.waiters)) > > File "c:\python21\lib\threading.py", line 217, in notify > > me = currentThread() > > TypeError: object of type 'None' is not callable > > > > This traceback does not appear when I register an atexit > > function to stop the thread. > > > > Is this a bug? Aren't daemon threads supposed to clean up > > themselves?
> This is probably a result of the destructive module finalization. > When PyFinalize() is called, threads that are still running are not > killed. But PyFinalize() replaces the values of all globals in > modules with None (it could just clear the module's dictionary but > there was some reason for doing it this way) and that is what you are > probably seeing. > > If there was a primitive to kill a thread, we might use it in > PyFinalize() -- but there isn't (it's been requested but it's hard to > see how to do it safely).
But it seems the system is trying to stop the thread(s), maybe too late. In my case, atexit.register(self.stop) makes a clean shutdown. My point is: should the threading module do this? I can easily live with doing it myself - I just don't know if this is intended or required.
Python doesn't attempt to stop daemon threads at all. Note that the __stop() call is in a finally clause. This probably gets hit because some other exception happened (caused by the same problem of globals being replaced by None).
--Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] threading bug?
- Next message: [Python-Dev] threading bug?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]