summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2003-06-13 21:59:45 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2003-06-13 21:59:45 (GMT)
commita11e84613579e2487bcb3967d3a2edbd0665343a (patch)
treedb4233ac70a7132ed81d35cb43b1982ef04da7cc /Modules
parentefad5880bae4508e456d85a7a664222e22d0d8a5 (diff)
downloadcpython-a11e84613579e2487bcb3967d3a2edbd0665343a.zip
cpython-a11e84613579e2487bcb3967d3a2edbd0665343a.tar.gz
cpython-a11e84613579e2487bcb3967d3a2edbd0665343a.tar.bz2
Add interrupt_main() to thread module.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/threadmodule.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/Modules/threadmodule.c b/Modules/threadmodule.c
index 8b174b3..2145977 100644
--- a/Modules/threadmodule.c
+++ b/Modules/threadmodule.c
@@ -278,6 +278,21 @@ PyDoc_STRVAR(exit_doc,
This is synonymous to ``raise SystemExit''. It will cause the current\n\
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
static PyObject *
thread_PyThread_exit_prog(PyObject *self, PyObject *args)
@@ -340,6 +355,8 @@ static PyMethodDef thread_methods[] = {
METH_NOARGS, exit_doc},
{"exit", (PyCFunction)thread_PyThread_exit_thread,
METH_NOARGS, exit_doc},
+ {"interrupt_main", (PyCFunction)sys_interrupt_main,
+ METH_NOARGS, interrupt_doc},
{"get_ident", (PyCFunction)thread_get_ident,
METH_NOARGS, get_ident_doc},
#ifndef NO_EXIT_PROG