stdout and threads

kyosohma at gmail.com kyosohma at gmail.com
Tue May 29 09:25:08 EDT 2007


On May 28, 4:54 am, "Troels Thomsen" <nej tak ...> wrote:
> Hello All
>
> I have trouble printing to stdout from a thread and main program.
>
> Not only will it look strange when they try to print at the same time, that
> is ok, but i think i see lock-ups. (strange exceptions in Tkinker etc) Or is
> it an issue with IDLE ?
>
> Should I implement a lock'ed / queued version and hook it into the
> sys.stdout ?
>
> (sorry if this has been answered recently in this group)
>
> using
> Python 2.5 (r25:51908
> Idle 1.2
>
> tpt

I've read in multiple sites/books that running Tkinter from IDLE can
cause screwy errors and I've seen a little bit of that behavior
myself. This website mentions the problem: http://www.ferg.org/thinking_in_tkinter/index.html

>From what I've read in Lutz's book, Programming Python, it sounds like
using the Queue module for messages is a good way to go, using
producer and consumer threads. Then just check the queue from time to
time to grab the messages and print them out, maybe to a separate
text widget.

Mike




More information about the Python-list mailing list