Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Should kernel restart interrupt running code?

Abierto
#462 9 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

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

Línea de trabajo

Comienza con el reproducer de la celda del notebook incluido en el issue y compara reiniciar el kernel durante la ejecución con interrumpirlo primero. Sigue el comportamiento de reinicio y apagado del kernel para determinar si el intérprete en ejecución debería recibir SIGINT y, después, verifica si el controlador atexit elimina el archivo temporal cuando se completa la ruta de limpieza esperada.

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

Descripción

I'm not sure if this is a bug or intended behavior. AFAICT, if a user restarts a kernel while the interpreter is actively processing, no SIGINT is sent to the interpreter process, and eventually the process is SIGKILL'd. This can lead to atexit handlers never running.

This is causing issues in dask, where we use atexit handlers to ensure remote resources are reclaimed.

Here's a reproducer. Paste this into a notebook cell, run, then restart the kernel before the cell finishes executing.

import atexit
import os
import time

with open("temp-file", "w") as f:
    f.write("This file should be deleted by the exit handler")

@atexit.register
def exit_handler():
    os.unlink("temp-file")
    
time.sleep(1000)

# Restart the kernel, `temp-file` should be deleted but isn't.
# If you interrupt, then restart, then `temp-file` is deleted

If you instead interrupt the kernel then restart it, everything is cleaned up properly. Is this intended behavior (and the issue is user workflow, rather than a possible bug)?

Lenguaje dominante
Python
Estrellas
734
Forks
411
Merge medio
1 d 2 h
PR fusionados (30 d)
9

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.

Más de ipython/ipykernel

Todos los issues de ipython/ipykernel

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.