Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4285 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2011-04-29 11:48 +1000 |
| Last post | 2011-04-29 11:48 +1000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
Aborting Python from C code Chris Angelico <rosuav@gmail.com> - 2011-04-29 11:48 +1000
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-04-29 11:48 +1000 |
| Subject | Aborting Python from C code |
| Message-ID | <mailman.974.1304041735.9059.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web