python / python/cpython

Allow Interpreter.prepare_main() Even If the Interpreter Is Running?

Abierto
#139,523 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

3.14 3.15 stdlib topic-subinterpreters type-feature
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

Feature or enhancement

Proposal:

Currently Interpreter.prepare_main() (from concurrent.interpreters) fails if the interpreter is running. (See Interpreter.is_running(). It may make sense to relax this restriction.

For example, it might make sense for a subinterpreter to call prepare_main() on the main interpreter to share a cross-interpreter Queue. Currently that fails because the main interpreter is always considered to be "running".
The answer for now is "make sure the main interpreter creates any queues it needs to share" and that might be good enough.

It's something I hadn't considered before and I'm not exactly sure yet that allowing it would be the right thing. The problem is that it isn't intuitively obvious to users (or me) how externally modifying an interpreter's __main__ module may affect code running there in a different thread.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

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 revisando concurrent.interpreters.Interpreter.prepare_main() e Interpreter.is_running(), centrándote en por qué se rechaza la preparación para un intérprete en ejecución. Determina si permitir cambios externos en main es seguro entre hilos y subintérpretes, y define después el comportamiento y las pruebas necesarios antes de cambiar la restricción.

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

Evaluación

Stack tecnológico
python
Área
backend
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.