TK + cmd.cmdloop() in threads (was Re: howdoI: Exception in thread - terminating the program?

Aahz Maruch aahz at panix.com
Thu Jul 19 05:56:57 CEST 2001


In article <yox1yneojvi.fsf_-_ at karhu.tp.spt.fi>,
Ville Vainio  <vvainio at karhu.tp.spt.fi> wrote:
>
>I haven't done any UI stuff (apart from cmd and toy GTK/TK examples)
>in python yet, is it ok to have TK mainloop running in one thread and
>still perform normal cmd.cmdloop() operation in another? I can't
>quickly think of any reason why it wouldn't be, but I can't figure out
>why it hasn't been explicitly suggested... Having a TK window doing
>the data browsing/drawing while still having a straightforward,
>versatile cmd.cmdloop() running on a console sounds like an extremely
>potent combination. Anyone done it? Are there some subtle gotchas that
>make it a bad idea?

I don't know what cmd.cmdloop() does, but if it's a TK thingie, what
you're suggesting is a Bad Idea.  Generally speaking, it's safest to
have only one thread accessing any external resource (GUI, file handle,
DB connection, etc).
-- 
                      --- Aahz  <*>  (Copyright 2001 by aahz at pobox.com)

Hugs and backrubs -- I break Rule 6                 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista   

Fortune cookie: Watch your relations with other people carefully, be reserved.



More information about the Python-list mailing list