Hi all,
[EMAIL PROTECTED] wrote: > Hi Amit, > > >> 1. I created a global variable named "QuitThread" on my main module. >> 2. I initially set it to "False". >> 3. When clicking on the "Run" button of my GUI (defined in the main >> module), a new thread starts using start_new_thread, where QuitThread is >> one of the variables in its tuple. >> > > This sounds wrong. You don't need QuitThread as a parameter to > start_new_thread. > > Fixed that. No errors yet. >> 4. This new thread runs a function from a second module. In this >> module I also added "import thread". >> 5. This function runs a loop in which it checks every iteration >> whether QuitThread is True or False. >> 6. If it is True, it executes "thread.exit()". >> 7. Nothing happens. The thread continues on running. >> > > has your problem been solved in the mean time? > If not two things to check/try: > - thread.exit works by throwing an exception. Make sure you don't > catch it by accident. > In my function (in the second module), the loops runs in a "try:" and I added the following exception: except QuitThread == 1: thread.exit() Now, it crashes with the following error message NameError: global name 'QuitThread' is not defined and it points to the above exception as the source of the error. This is strange, since QuitThread is definitely defined as a global variable in the main module. > - Print/log value of QuitThread on every access in both threads. > By the way, it *doesn't* crash when I comment out the "print QuitThread" line inside the loop. Thanks for you help, Amit. > > Cheers, > ------------------------------------------------------------------------------ > Matthias Kievernagel Software development > mkiever/at/web/dot/de http://mkiever.home.tlink.de > ------------------------------------------------------------------------------ > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss@python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss >
_______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss