I wrote a Python application that uses Tkinter for a GUI. It has a second thread for TCP/IP communication (XMLRPC actually, allowing labview to connect and make some calls). The two threads communicate with a pair of thread safe queues. After running for a couple of days, it the crashes. I don't get a full trace back. So far the best I got was "Tcl_AppendFormatToObj called with shared object
" Evidently, this comes from the following Tcl function:
Tcl_AppendFormatToObj(..)
{
...
if (Tcl_IsShared(appendObj)) {
Tcl_Panic("%s called with shared object", "Tcl_AppendFormatToObj");
}
Something about formatting a string if causing a problem. Any advice? I'm running the script on Windows 7 under the winpdb now and waiting and hoping for a useful trace when the "panic" happens again.
It turns out that one of the queues was not thread safe. The Tk even queue is not thread safe. So using tk's root.after() to put something on tk's even queue, from another thread, cause intermittent problems. Instead, create a real queue, and make the non tk loop thread stuff something into the queue, and make code in the tk thread monitor the other side of the queue. So in the tk loop, write a function that empties the real queue ( and do something based on what it found). Make that function call itself with after().