<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html style="direction: ltr;">
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body style="direction: ltr;" bgcolor="#ffffff" text="#000000">
<p style="margin-bottom: 0cm; margin-top: 0pt;">Hi all,<br>
</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;"><br>
</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;"><a class="moz-txt-link-abbreviated" href="mailto:mkieverpy@tlink.de">mkieverpy@tlink.de</a>
wrote:</p>
<blockquote cite="mid20080405150520.DFB37BBF9@mail.terralink.de"
 type="cite">
  <pre wrap="">Hi Amit,

  </pre>
  <blockquote type="cite">
    <pre wrap="">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.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
This sounds wrong. You don't need QuitThread as a parameter to
start_new_thread.

  </pre>
</blockquote>
Fixed that. No errors yet.<br>
<blockquote cite="mid20080405150520.DFB37BBF9@mail.terralink.de"
 type="cite">
  <pre wrap=""></pre>
  <blockquote type="cite">
    <pre wrap="">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.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
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.
  </pre>
</blockquote>
In my function (in the second module), the loops runs in a "try:" and I
added the following exception:<br>
<br>
&nbsp;&nbsp;&nbsp; except QuitThread == 1:&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; thread.exit()<br>
<br>
Now, it crashes with the following error message<br>
<br>
&nbsp;&nbsp;&nbsp; NameError: global name 'QuitThread' is not defined<br>
<br>
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. <br>
<br>
<blockquote cite="mid20080405150520.DFB37BBF9@mail.terralink.de"
 type="cite">
  <pre wrap="">- Print/log value of QuitThread on every access in both threads.
  </pre>
</blockquote>
By the way, it *doesn't* crash when I comment out the "print
QuitThread" line inside the loop.<br>
<br>
Thanks for you help,<br>
<br>
Amit.
<blockquote cite="mid20080405150520.DFB37BBF9@mail.terralink.de"
 type="cite">
  <pre wrap="">

Cheers,
------------------------------------------------------------------------------
Matthias Kievernagel                                      Software development
mkiever/at/web/dot/de                             <a class="moz-txt-link-freetext" href="http://mkiever.home.tlink.de">http://mkiever.home.tlink.de</a>
------------------------------------------------------------------------------
_______________________________________________
Tkinter-discuss mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Tkinter-discuss@python.org">Tkinter-discuss@python.org</a>
<a class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/tkinter-discuss">http://mail.python.org/mailman/listinfo/tkinter-discuss</a>
  </pre>
</blockquote>
<br>
</body>
</html>