I’m working on Python foreign function interface for Elisp.
Python methods are called in separated pthread with PyObject_Call.
I’m creating sub-interpreters to isolate Elisp packages from each other.
I want user to be able to interrupt long running python methods in same manner as we can press control-C in interactive interpreter.
Speculatively, you could install a signal handler and then use PyThreadState_SetAsyncExc to send a KeyboardInterrupt to the interpreter, but I suspect you’ll run into some interesting edge cases.
But GIL is needed for bothPyThreadState_SetAsyncExc and PyObject_Call, no?
I’m a bit confused because documentation for PyObject_Call doesnt say anything about GIL but i got crash when i released GIL before call to it.
A long time ago there used to be a callback in the ceval code that you could hook into. I was using it for a while. No idea if that hook is still in the code.
Suggest you read the code of the evaluation loop and see if it is still there.
I used the hook to simulate a KeyboardInterrupt to prevent the python code from locking up the app.