Add rule to detect potential bug caused by unheld references to asyncio.create_task
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Feature
Hi there,
I wanted to suggest adding a rule to MyPy to help detect a potential bug that can occur when using asyncio.create_task. If a developer doesn't hold a reference to the task object returned by create_task, the task may disappear without warning when Python runs garbage collection. This can lead to unpredictable failures in the code, which can be extremely difficult to debug.
References:
https://textual.textualize.io/blog/2023/02/11/the-heisenbug-lurking-in-your-async-code/
https://news.ycombinator.com/item?id=34754276
Pitch
I think adding a rule to MyPy that flags code which creates an asyncio task but doesn't hold a reference to it would be very helpful in preventing this bug from occurring. It would alert developers to the fact that they need to make sure they're holding a reference to the task object if they want to avoid this problem.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza revisando el manejo existente de asyncio.create_task por parte de mypy y los informes vinculados que describen tareas que no se conservan. Define qué patrones de referencias no conservadas debe señalar la regla propuesta, cómo deben aparecer los diagnósticos y qué casos de prueba demuestran que la regla está completa.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- tooling
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 25/100