From: Tim B. <tb...@bi...> - 2004-09-10 18:07:29
|
I just solved a problem I was having with a py2exe windows standalone whereby the windows process never terminated after closing the app. As you might suspect, this involved a thread in my app that didn't terminate gracefully. I found in the PythonCard samples several examples of using threads and in each case, the thread's daemon flag was set to 1 to make it daemonic so that it is cleaned up when the non-daemonic thread (my Main GUI thread) exits. This solved my problem. However, until I found this solution, I was trying another solution. Let's pretend for a second that thread.setDaemon wouldn't work and we have to make my secondary thread explicitly "killable" by having its run function do: def run(self): while self._running: # do stuff pass and its stop func do: def stop(self): self._running =3D False so that my Pythoncard app can call this thread's stop function to explicitly kill it. But where and when should this be called? I can handle the reqests to close the app via a file menu exit callback, but what about for "X"ing the application or other sorts of ungraceful termination? I see that self.Close() gets called. I guess what I am asking is what is EVT_CLOSE bound to? Where can I place cleanup statements like thread stopping, etc?=20 Thanks, Tim |