wxPython and threading issue

sjdevnull at yahoo.com sjdevnull at yahoo.com
Fri Sep 29 13:19:44 EDT 2006


Patrick Smith wrote:
> > Well, the problem is that you can't simply kill a thread--it shares
> > memory with other threads that it could be leaving in an inconsistent
> > state.  Imagine that it was, say, holding a lock when it was forceably
> > killed.  Now any other thread that tries to acquire that lock will
> > block forever.
> >
> > You really do need the thread's cooperation so that it only exits when
> > everything is in a kosher state.  Can you dig into the incredibly long
> > function and change it to do the flag-checking and exiting safely?
> >
> > I second the notion to consider using subprocesses instead of threads;
> > that's almost always a good idea unless you're really sharing a lot of
> > complex data structures.
> >
>
> Hi,
> Thanks again for your replies.
>
> The way this was originally working was actually using a subprocess,
> however, the people who this program is for were having problems that when
> the application was closed, the subprocess was still around in the system,

Have the main process kill the subprocess when it exits; this should be
fine unless you use kill -9 or the windows equivalent (e.g terminating
from the task manager), in which case you can kill the subproc manually
as well.

> Also, the people who I am doing this for need something ASAP and for now are
> fine with the cancel button completely closing the entire program.  Is there
> at least a nice way to do this?

maybe os.abort or os._exit depending on what you want and how they
behave on your platform?




More information about the Python-list mailing list