mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-111964: Implement stop-the-world pauses (gh-112471)
The `--disable-gil` builds occasionally need to pause all but one thread. Some examples include: * Cyclic garbage collection, where this is often called a "stop the world event" * Before calling `fork()`, to ensure a consistent state for internal data structures * During interpreter shutdown, to ensure that daemon threads aren't accessing Python objects This adds the following functions to implement global and per-interpreter pauses: * `_PyEval_StopTheWorldAll()` and `_PyEval_StartTheWorldAll()` (for the global runtime) * `_PyEval_StopTheWorld()` and `_PyEval_StartTheWorld()` (per-interpreter) (The function names may change.) These functions are no-ops outside of the `--disable-gil` build.
This commit is contained in:
parent
5f1997896d
commit
441affc9e7
10 changed files with 336 additions and 29 deletions
|
|
@ -205,6 +205,7 @@ void _PyEval_FrameClearAndPop(PyThreadState *tstate, _PyInterpreterFrame *frame)
|
|||
#define _PY_CALLS_TO_DO_BIT 2
|
||||
#define _PY_ASYNC_EXCEPTION_BIT 3
|
||||
#define _PY_GC_SCHEDULED_BIT 4
|
||||
#define _PY_EVAL_PLEASE_STOP_BIT 5
|
||||
|
||||
/* Reserve a few bits for future use */
|
||||
#define _PY_EVAL_EVENTS_BITS 8
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue