abort python script from trace function
David.Stark at intusurg.com
Fri Jul 15 18:00:54 EDT 2011
I have a multithreaded application that uses embedded python extensively. The main thread creates python objects that interface test equipment, and users execute their own python scripts that run in a separate thread. The users need to be able to pause/resume/abort a script that is currently running. I registered a Py_tracefunc to check the state of the pause/abort buttons from the GUI, and pause/resume are working great. The trouble is that I cannot figure out how to implement an abort in my trace function. I can set exceptions use PyErr_SetString or PyThreadState_SetAsyncExc, but these just raise exceptions. If the script is in a block that defines a try/finally the exception will be caught, not what I want. In searching similar topics I saw references to PyErr_SetInterrupt, but this had no visible effect at all on my application. I don't want to call Py_Finalize and shut down the whole interpreter, because I would lose the Python objects created in the main thread. An uncatchable exception would be ideal.
My embedded python version is:
'2.6.5 (r265:79063, Mar 20 2010, 14:22:52) [MSC v.1500 32 bit (Intel)]'
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list