Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4285
| Date | 2011-04-29 11:48 +1000 |
|---|---|
| Subject | Aborting Python from C code |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.974.1304041735.9059.python-list@python.org> (permalink) |
In our sandboxed Python environment, I would like to be able to
trigger an abort of the currently-running Python script (from a signal
handler or another thread). Currently, I use PyErr_SetInterrupt()
which raises KeyboardInterrupt in the script; this works for the most
part, but can be bypassed with a script like:
while True:
try:
while True:
pass
except:
pass
I want to be able to administratively order Python to stop executing.
Is it possible to make KeyboardInterrupt non-catchable from Python?
Alternatively, can I use Py_AddPendingCall to do this? I'd rather not
use setjmp/longjmp if I can help it, as they seem a tad brutal, but
I'm thinking in terms of a call that, in effect, doesn't return.
Any ideas would be appreciated!
Chris Angelico
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Aborting Python from C code Chris Angelico <rosuav@gmail.com> - 2011-04-29 11:48 +1000
csiph-web