Add interrupt_main() to thread module. · python/cpython@a11e846 (original) (raw)

`@@ -278,6 +278,21 @@ PyDoc_STRVAR(exit_doc,

`

278

278

``` This is synonymous to ``raise SystemExit''. It will cause the current\n\

```

279

279

`thread to exit silently unless the exception is caught.");

`

280

280

``

``

281

`+

static PyObject *

`

``

282

`+

sys_interrupt_main(PyObject * self, PyObject * args)

`

``

283

`+

{

`

``

284

`+

PyErr_SetInterrupt();

`

``

285

`+

Py_INCREF(Py_None);

`

``

286

`+

return Py_None;

`

``

287

`+

}

`

``

288

+

``

289

`+

PyDoc_STRVAR(interrupt_doc,

`

``

290

`+

"interrupt_main()\n\

`

``

291

`+

\n\

`

``

292

`+

Raise a KeyboardInterrupt in the main thread.\n\

`

``

293

`+

A subthread can use this method to interrupt the main thread."

`

``

294

`+

);

`

``

295

+

281

296

`#ifndef NO_EXIT_PROG

`

282

297

`static PyObject *

`

283

298

`thread_PyThread_exit_prog(PyObject *self, PyObject *args)

`

`@@ -340,6 +355,8 @@ static PyMethodDef thread_methods[] = {

`

340

355

`METH_NOARGS, exit_doc},

`

341

356

` {"exit", (PyCFunction)thread_PyThread_exit_thread,

`

342

357

`METH_NOARGS, exit_doc},

`

``

358

`+

{"interrupt_main", (PyCFunction)sys_interrupt_main,

`

``

359

`+

METH_NOARGS, interrupt_doc},

`

343

360

` {"get_ident", (PyCFunction)thread_get_ident,

`

344

361

`METH_NOARGS, get_ident_doc},

`

345

362

`#ifndef NO_EXIT_PROG

`