Commit 0b32d2a8 authored by Kurt B. Kaiser's avatar Kurt B. Kaiser

Add interrupt_main() to thread module.

parent a0a1d7b1
...@@ -278,6 +278,21 @@ PyDoc_STRVAR(exit_doc, ...@@ -278,6 +278,21 @@ PyDoc_STRVAR(exit_doc,
This is synonymous to ``raise SystemExit''. It will cause the current\n\ This is synonymous to ``raise SystemExit''. It will cause the current\n\
thread to exit silently unless the exception is caught."); thread to exit silently unless the exception is caught.");
static PyObject *
sys_interrupt_main(PyObject * self, PyObject * args)
{
PyErr_SetInterrupt();
Py_INCREF(Py_None);
return Py_None;
}
PyDoc_STRVAR(interrupt_doc,
"interrupt_main()\n\
\n\
Raise a KeyboardInterrupt in the main thread.\n\
A subthread can use this method to interrupt the main thread."
);
#ifndef NO_EXIT_PROG #ifndef NO_EXIT_PROG
static PyObject * static PyObject *
thread_PyThread_exit_prog(PyObject *self, PyObject *args) thread_PyThread_exit_prog(PyObject *self, PyObject *args)
...@@ -340,6 +355,8 @@ static PyMethodDef thread_methods[] = { ...@@ -340,6 +355,8 @@ static PyMethodDef thread_methods[] = {
METH_NOARGS, exit_doc}, METH_NOARGS, exit_doc},
{"exit", (PyCFunction)thread_PyThread_exit_thread, {"exit", (PyCFunction)thread_PyThread_exit_thread,
METH_NOARGS, exit_doc}, METH_NOARGS, exit_doc},
{"interrupt_main", (PyCFunction)sys_interrupt_main,
METH_NOARGS, interrupt_doc},
{"get_ident", (PyCFunction)thread_get_ident, {"get_ident", (PyCFunction)thread_get_ident,
METH_NOARGS, get_ident_doc}, METH_NOARGS, get_ident_doc},
#ifndef NO_EXIT_PROG #ifndef NO_EXIT_PROG
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment