[Python-bugs-list] [ python-Bugs-502236 ] Need way to exit application
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 11 Jan 2002 07:46:23 -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.
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-01-11 07:46
Message:
Logged In: YES
user_id=6380
I'm struggling with this in a threaded distributed app we're
developing for Zope Corp, so I agree that something like
this would be nice. I think for starters, there should be a
way to raise an asynchronous exception in a specific thread;
all threads is easy then.
There are plenty of implementation problems with this,
however: if a thread is blocked in I/O, there's no portable
way to get it to bail out of that I/O operation.
There are also plenty of application-level issues: if
asynchronous exceptions are common, maybe it is necessary to
provide a way to temporarily block such exceptions in order
to provide safety in some situations.
Etc., etc. So please spare us your surprise and help looking
for a mechanism that can be implemented.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=502236&group_id=5470