I often use this in my OnExit:
# make sure that all is closed
for item in wx.GetTopLevelWindows():
if not isinstance(item, CaptureFrame):
if isinstance(item, wx.Dialog):
item.Destroy()
item.Close()
"CaptureFrame" is in this case my MainFrame, don't close that otherwise
IIRC you get a py dead error.
Werner
Gadget/Steve
Maybe time for a small runnable sample.
Werner
Creating a new process just so you can have a clean exit seems like
trying to kill a mosquito with a grenade, IOW way too much overkill.
The things to double-check are:
1. As others have mentioned, if you have any other TLWs remaining then
the MainLoop will not exit normally, but even so ExitMainLoop should
have taken care of that for you as long as you're not currently in a
nested event loop.
2. Are you using a TaskBarIcon? If so then it should be Destroyed.
3. Are you using other threads (or multiprocessing processes) that have
not terminated or been set to be daemon threads? If your MainLoop() is
exiting but Python is not exiting then this is probably the problem.
Python itself will not exit while there are non-daemon threads still
running.
If all else fails you should be able to use wx.Exit() to force it, but
if you can figure it out it would be better to find out why the normal
termination is not happening and fix it, just to make sure you are
properly cleaning up any resources you are creating or modifying. Can
you reproduce the problem in a small, simple standalone program? If so
that will probably point you to the source of the issue.
--
Robin Dunn
Software Craftsman
http://wxPython.org
As a Java developer who enjoys Python, I have to ask if there are any
tools for Python like jps and jstack? When I have a thread that isn't
terminating in Java, I can use these tools to get more insight into what
the VM is still running and track it down that way.
Greg
On Tue, Jan 10, 2012 at 7:50 AM, Greg Hasseler <ghas...@gmail.com> wrote:
You can use a debugger such as WinPdb to view the threads and
callstack. Only issue is if the code is stuck outside of the Python
code (i.e down a the C/C++ library a python debugger may not be of
much use.)
Also see the PyStudio plugin for Editra which has WinPdb integration
(http://code.google.com/p/editra-plugins/wiki/PyStudio)
Cody
https://github.com/alonho/pystuck
As I haven't personally used the latter I can not say how useful it might be but it sounds like exactly what you need.
Gadget/Steve