MagicStack / MagicStack/uvloop

Idea: changing libuv not to install a signal handler

Abierto
#582 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Cython
Estrellas
11.9k
Forks
616
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Hi,

So I've been having problems with a python-uvloop process which is run from a container and spawns child processes. If those child processes spawn their own children which lose their parents (eg. via demonize()) then there's no way to reap them (as PID1 is honour-bound to do). I had been addressing this by patching libuv to do something analagous to FastChildWatcher - ie. reap all process in SIGCHLD handler. But this isn't really safe and can interfere with other libraries or modules (eg. a synchronous process start in another python module).

In the mean time, Python itself has deprecated child-watchers and is now using pidfd on Linux, and a dedicated wait() thread in all other cases.

This means that PID-1 programs can just install their own SIGCHLD handler to reap orphaned processes.

I was wondering if my proposal over on libuv/libuv#4179 might be of interest here? The idea would be to pass a special flag to libuv to tell it not to install a signal handler, and then use the python child watchers to handle reaping of libuv spawned processes.

Without this, a python process which sets up a SIGCHLD handler is going to break if switching from asyncio to uvloop (ie. the switch is no longer transparent, as of python 3.12)

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

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 el cambio propuesto en libuv/libuv#4179 y cómo uvloop utiliza actualmente libuv para la gestión de procesos hijo y señales. Compara ese comportamiento con los child watchers de Python, la compatibilidad con pidfd en Linux y los hilos de espera dedicados en otros lugares; la tarea se consideraría terminada cuando exista un diseño de integración decidido y seguro con las pruebas adecuadas.

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

Evaluación

Stack tecnológico
linux, python
Área
backend, operating-systems
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.