1 /***********************************************************************
4 * Python extension implementing the interrupt module.
6 **********************************************************************/
11 #define PyDoc_VAR(name) static char name[]
12 #define PyDoc_STR(str) str
13 #define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
16 /* module documentation */
18 PyDoc_STRVAR(module_doc
,
19 "Provide a way to interrupt the main thread from a subthread.\n\n\
20 In threaded Python code the KeyboardInterrupt is always directed to\n\
21 the thread which raised it. This extension provides a method,\n\
22 interrupt_main, which a subthread can use to raise a KeyboardInterrupt\n\
23 in the main thread.");
25 /* module functions */
28 setinterrupt(PyObject
* self
, PyObject
* args
)
35 /* registration table */
37 static struct PyMethodDef methods
[] = {
38 {"interrupt_main", setinterrupt
, METH_VARARGS
,
39 PyDoc_STR("Interrupt the main thread")},
43 /* module initialization */
48 (void) Py_InitModule3("interrupt", methods
, module_doc
);