Py_AddPendingCall can't signal background threads!!!
Warren Postma
embed at NO_SPAM_PLEASE.geocities.com
Thu Jan 4 14:58:12 EST 2001
"Fredrik Lundh" <fredrik at effbot.org> wrote:
> something like this might work:
>
> static int
> getoutofhere(void *unused)
> {
> PyErr_SetNone(PyExc_KeyboardInterrupt);
> return -1;
> }
>
> Py_AddPendingCall(getoutofhere, NULL);
>
Thanks, Fredrik. That would work except that the main thread is not the one
executing the user-provided code. Instead, there are background threads
doing that.
I noticed that Py_MakePendingCalls() doesn't do anything to help us here,
because you can't signal a background thread and tell it to stop.
What would we do if we were in the main thread, and wanted to kill a
background thread?
I suppose I could actually have a Keyboard-Interrupt-Signal hack happen in
Py_MakePendingCalls() to handle if a background thread was being told to
"die", but thus far i have avoided making changes to my own embedded python
1.5.2 that would make it somehow incompatible with a stock Python system.
However it appears that truly signalling a thread is not allowed in Python.
Warren
More information about the Python-list
mailing list