]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-111964: Implement stop-the-world pauses (gh-112471)
authorSam Gross <colesbury@gmail.com>
Tue, 23 Jan 2024 18:08:23 +0000 (13:08 -0500)
committerGitHub <noreply@github.com>
Tue, 23 Jan 2024 18:08:23 +0000 (11:08 -0700)
commit441affc9e7f419ef0b68f734505fa2f79fe653c7
tree1c7771190fffc7927ab70f485500521a96de7938
parent5f1997896d9c3ecf92e9863177c452b468a6a2c8
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.
Include/cpython/pystate.h
Include/internal/pycore_ceval.h
Include/internal/pycore_interp.h
Include/internal/pycore_llist.h
Include/internal/pycore_pystate.h
Include/internal/pycore_runtime.h
Include/internal/pycore_runtime_init.h
Include/pymacro.h
Python/ceval_gil.c
Python/pystate.c