[Idle-dev] Fw: Deadlocking IDLE under Win32

Mark Hammond mhammond@skippinet.com.au
Fri, 14 Apr 2000 12:56:32 +1000


This is from the main Python newsgroup.

In summary, it appears that under IDLE "print", via
OutputWindow.write(), via the Tk test.insert/see/update methods is
not thread safe.

Id like to fix this, but I need some Tk help WRT events,  If anyone
can help I would appreciate it!

The obvious (to me) fix is for the write method to use the Queue
module to save away the output, then to set some sort of event for
the main GUI thread.  This thread simply unqueues and prints the
output.

Is anyone able to tell me how to trigger this sort of event under
Tk?  Under Windows, each thread would simply perform a
"PostMessage()" with a custom message.  The main event loop would
then see and repsond to this message, giving me the required thread
affinity.  I have no idea what the Tkinter equivilent is...

Thanks,

Mark.

"David Fisher" <python@rose164.wuh.wustl.edu> wrote in message
news:<00aa01bfa53b$2fe73bc0$0201a8c0@spkydomain>...
>
> ----- Original Message -----
> From: "Mark Hammond" <mhammond@skippinet.com.au>
>
>
> > My guess is that the "print" under IDLE is not thread-safe.
Change the
> > program to not print (or to append items to a queue, which the
main thread
> > then prints) and see if this is the problem.
>
> You are correct sir.  Of course, your guess is a bit more educated
that most
> <wink>.  I ran into the problem printing from multiple threads in
IDLE a
> while ago, and just assumed it was something that everybody new
about
> already.  I'm pretty new to python.
>