Q: PyErr_SetInterrupt, PyCrust
nfullagar
nfullagar at yahoo.com
Sat Dec 7 00:03:40 EST 2002
Hello Python Users,
I've been playing around with Python (2.2.2), wxPython (2.3) and
PyCrust (0.7.2) all embedded into a simple C application. The C
application uses python & wxPython to perform GUI stuff (including a
callback into c to do some opengl,) and PyCrust to expose a scripting
window. But if the user types "while 1: pass" in the scripting
window, of course this brings down the whole application in an
infinite loop. To make matters worse, windows blocks ctrl-break
signals (unless you have an attached console... not something I want)
To get around this, before calling python I set up a 2nd thread that
puts up a tiny window with a button that if pressed calls
PyErr_SetInterrupt(). This is all C code, similar to some pythonwin
sources I came across, but without MFC. After this is done, I call
Py_Initialize(), Py_InitModule(), PyRun_SimpleFile() and my python /
wxPython takes it from there, setting up the PyCrust window.
So far it works ok, and the button will interrupt a "while 1: pass"
running in PyCrust. However, if the button is pressed while the
cursor is waiting for input, my application crushes. I suspect python
and wxPython, which are driving my GUI, receive the KeyboardInterrupt
caused by PyErr_SetInterrupt() and bail. Really I only want PyCrust
to respond to it.
Do any of you know how I can tell the main python interpreter running
wxPython to totally ignore KeyboardError if the PyCrust shell is just
sitting at the command prompt? And on a related note, I noticed that
in C land PyErr_SetInterrupt() appears to be going away soon (that's
what the docs say,) to be replaced by another call. Anyone know what
this call is?
thanks in advance -nicholas
ps. other than this, everthing else is going great -- I love python!
More information about the Python-list
mailing list