[Python-bugs-list] [ python-Bugs-502236 ] Need way to exit application

noreply@sourceforge.net noreply@sourceforge.net
Fri, 11 Jan 2002 00:46:44 -0800


Bugs item #502236, was opened at 2002-01-11 00:46
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=502236&group_id=5470

Category: Extension Modules
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: paul rubin (phr)
Assigned to: Nobody/Anonymous (nobody)
Summary: Need way to exit application

Initial Comment:
I may be missing something but there doesn't seem to
be any easy, correct way to exit a Python application
and shut down the interpreter.  sys.exit() raises
the SysExit exception in the current thread but other
threads keep running, so the application doesn't stop.
You can do something brutal like os.kill() your
process, but then cleanup actions (finally clauses)
don't get run.  Or you can create some elaborate
application-specific framework for propagating an
exit flag from one thread to all the rest.  That's
incredibly lame.  

What's needed is a simple function (maybe sys.allexit)
that raises SysExit in all the threads of the
application (it might have to first stop all the 
threads using the GIL or something like that).  

I'm surprised there isn't already something like this, 
but there's been some c.l.py discussion about it and 
it really seems to not be there.  Is there some 
problem with the idea?  I don't see one but I can't be 
sure.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=502236&group_id=5470