diff options
| author | Guido van Rossum <guido@python.org> | 2003-04-29 10:23:27 +0000 |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 2003-04-29 10:23:27 +0000 |
| commit | 57cd21fde285d25021ee978cd09ed58159166bf8 (patch) | |
| tree | 57936b5a729c1219ae080d518832b9e17aa219ec /Tools/idle/interruptmodule.c | |
| parent | 19691360c7a8c203d1a94f6074036e810a6f0527 (diff) | |
| download | cpython-git-57cd21fde285d25021ee978cd09ed58159166bf8.tar.gz | |
Checking in IDLEFORK exactly as it appears in the idlefork CVS.
On a branch, for now.
Diffstat (limited to 'Tools/idle/interruptmodule.c')
| -rw-r--r-- | Tools/idle/interruptmodule.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Tools/idle/interruptmodule.c b/Tools/idle/interruptmodule.c new file mode 100644 index 0000000000..8e18d5af90 --- /dev/null +++ b/Tools/idle/interruptmodule.c @@ -0,0 +1,49 @@ +/*********************************************************************** + * interruptmodule.c + * + * Python extension implementing the interrupt module. + * + **********************************************************************/ + +#include "Python.h" + +#ifndef PyDoc_STR +#define PyDoc_VAR(name) static char name[] +#define PyDoc_STR(str) str +#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) +#endif + +/* module documentation */ + +PyDoc_STRVAR(module_doc, +"Provide a way to interrupt the main thread from a subthread.\n\n\ +In threaded Python code the KeyboardInterrupt is always directed to\n\ +the thread which raised it. This extension provides a method,\n\ +interrupt_main, which a subthread can use to raise a KeyboardInterrupt\n\ +in the main thread."); + +/* module functions */ + +static PyObject * +setinterrupt(PyObject * self, PyObject * args) +{ + PyErr_SetInterrupt(); + Py_INCREF(Py_None); + return Py_None; +} + +/* registration table */ + +static struct PyMethodDef methods[] = { + {"interrupt_main", setinterrupt, METH_VARARGS, + PyDoc_STR("Interrupt the main thread")}, + {NULL, NULL} +}; + +/* module initialization */ + +void +initinterrupt(void) +{ + (void) Py_InitModule3("interrupt", methods, module_doc); +} |
