python / python/cpython

`select.BaseSelector.select` do not conform to documentation with regard to signal handling

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

Nadie ha tomado este issue todavía.

topic-socket type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

Bug report

Bug description:

According to documentation in https://docs.python.org/3/library/selectors.html#selectors.BaseSelector.select:

      .. versionchanged:: 3.5
         The selector is now retried with a recomputed timeout when interrupted
         by a signal if the signal handler did not raise an exception (see
         :pep:`475` for the rationale), instead of returning an empty list
         of events before the timeout.

However, as of writing this issue, selectors.SelectSelector.select and co can't differentiate between InterruptedError and timeout, as this exceptions is caught in in those methods.

While select.select shouldn't raise InterruptedError, such exception could be raised in a signal handler, therefore causing selectors.SelectSelector.select to return an empty list (instead of the raised exception), as-if it was a timeout.

The behaviour that I would expect has been implemented in https://github.com/python/cpython/commit/f70e1ca0fc30426d12aa8fc6684764ee11a66777, however it has been reverted in a following commit https://github.com/python/cpython/commit/90ecfe65e68#diff-671465c62a2c7c951b397550dc8f2f1c03860af4c089299e6edea29347cf6018 . It is unclear to me if it is an oversight, or if this revert was expected.

I only tested this for selectors.SelectSelector, but looking at the sources, I would expect the same behaviour exist for all select.*Selector classes

CPython versions tested on:

3.12, CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-120002

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 con selectors.SelectSelector.select y compara su tratamiento de las interrupciones de señales con el comportamiento documentado de BaseSelector.select. Revisa el PR vinculado gh-120002 y los commits referenciados para comprender la resolución prevista; después, verifica si las clases select.*Selector necesitan un tratamiento coherente y cobertura de regresión.

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

Evaluación

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

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.