mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
Add PyThreadState_SetAsyncExc(long, PyObject *).
A new API (only accessible from C) to interrupt a thread by sending it an exception. This is not always effective, but might help some people. Requested by Just van Rossum and Alex Martelli. It is intentional that you have to write your own C extension to call it from Python. Docs will have to wait.
This commit is contained in:
parent
90a2041ffd
commit
b8b6d0c2c6
3 changed files with 51 additions and 1 deletions
|
@ -74,6 +74,9 @@ typedef struct _ts {
|
|||
int tick_counter;
|
||||
int gilstate_counter;
|
||||
|
||||
PyObject *async_exc; /* Asynchronous exception to raise */
|
||||
long thread_id; /* Thread id where this tstate was created */
|
||||
|
||||
/* XXX signal handlers should also be here */
|
||||
|
||||
} PyThreadState;
|
||||
|
@ -93,6 +96,7 @@ PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
|
|||
PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void);
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *);
|
||||
PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void);
|
||||
PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *);
|
||||
|
||||
|
||||
/* Variable and macro for in-line access to current thread state */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue