Message30544
Python 2.4.3 on Windows 2000, though the code in
question seems unchanged in current SVN (r46919).
I'm using Python embedded in a multithreaded C++
application. When 'import threading' is first done in
some Python script that runs in thread A, I get the
following exception when a different thread B calls
Py_Finalize():
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "C:\Python24\lib\atexit.py", line 24, in
_run_exitfuncs
func(*targs, **kargs)
File "C:\Python24\lib\threading.py", line 636, in
__exitfunc
self._Thread__delete()
File "C:\Python24\lib\threading.py", line 522, in
__delete
del _active[_get_ident()]
KeyError: 680
Error in sys.exitfunc:
Traceback (most recent call last):
File "C:\Python24\lib\atexit.py", line 24, in
_run_exitfuncs
func(*targs, **kargs)
File "C:\Python24\lib\threading.py", line 636, in
__exitfunc
self._Thread__delete()
File "C:\Python24\lib\threading.py", line 522, in
__delete
del _active[_get_ident()]
KeyError: 680
The reason seems to be that the threading module uses
the thread ID of the calling thread as a key to store
its _MainThread instance on initialization, and again
the thread ID of the calling thread to delete it in its
exit function. If these two threads are not the same,
the described KeyError occurs.
I didn't study this in all detail, but it seems to me
that threading.Thread.__delete() does the wrong thing.
By doing 'del _active[_get_ident()]', it removes the
instance for the calling thread from the _active
dictionary. What it should be doing is removing *self*
from that dictionary. Is that correct? |
|
Date |
User |
Action |
Args |
2007-08-23 14:49:50 | admin | link | issue1596321 messages |
2007-08-23 14:49:50 | admin | create | |
|