[issue11077] Tkinter is not thread safe

Serhiy Storchaka report at bugs.python.org
Sat Jul 12 09:49:23 CEST 2014


Serhiy Storchaka added the comment:

I can't reproduce the bug on 2.7.8+, but on 2.7.3 I sometimes got messages like "Exception in thread Thread-26 (most likely raised during interpreter shutdown):" or:

  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2204, in create_line
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2184, in _create
<type 'exceptions.TypeError'>: 'NoneType' object is not callable

This points to shutdown issue. When TkinterCrash2.py call quit(), other threads are still work. And when modules (including Tkinter and __main__) are cleaned, they try to call global functions which are set to None. After fixing TkinterCrash2.py to not invoke any code during shutdown, error messages on 2.7.3 gone.

I don't see any bugs in Tkinter exposed by this script, only a bug in the script itself.

Here is a script with quick and dirty fix. This solution is not perfect, there is small chance of race conditions (happened once in about 500 runs). Correct solution should be more complicated. If there no other errors in TkinterCrash2-2.py, this issue can be closed.

----------
Added file: http://bugs.python.org/file35927/TkinterCrash2-2.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11077>
_______________________________________


More information about the Python-bugs-list mailing list