python / python/cpython

Some Runtime Finalization Constraints Are Not Enforced Nor Documented

Abierto
#120,838 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

3.12 3.13 3.14 docs interpreter-core topic-C-API type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
36k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

Bug report

Bug description:

There are a few technical constraints on calling Py_Finalize() currently aren't enforced, well-documented, or widely recognized. This is partly due to the relatively small number of embedders and the even smaller number of them that might violate the constraints through the use of threads or subinterpreters.

The constraints are:

  • should be called only in the main thread
  • should be called only with the main interpreter active
  • should be called only using the same thread state used for Py_Initialize()

(That last one is potentially less critical.)

There are several reasons these matter:

  • the main thread of the main interpreter has a special role in the runtime's lifecycle
  • the main thread of the main interpreter has unique responsibilities that must be synchronized with finalization
  • conceptually, runtime lifecycle is an app-level function, and the app is typically driven through the "main" thread

The constraints should be documented, tested, and (possibly) enforced.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs
  • gh-120839
  • gh-120840
  • gh-120841
  • gh-120852
  • gh-120853
  • gh-121010
  • gh-121013
  • gh-121063

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza rastreando el punto de entrada Py_Finalize() y revisa los PR enlazados gh-120839, gh-120840, gh-120841, gh-120852, gh-120853, gh-121010, gh-121013 y gh-121063. Se considera completado cuando las restricciones del hilo principal, del intérprete principal y del estado del hilo de inicialización estén documentadas, cubiertas por pruebas y posiblemente se hagan cumplir.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
backend
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
20/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.