jupyter-kernel-process: Handle fatal signals of a kernel process more cleanly

In the process sentinel, only consider the process dying as unexpected
when the process object still has a :kernel property.
This commit is contained in:
Nathaniel Nicandro 2023-01-28 17:38:38 -06:00
parent 97dcb49e46
commit 37c3187f8f

View file

@ -362,17 +362,18 @@ See also https://jupyter-client.readthedocs.io/en/stable/kernels.html#kernel-spe
(lambda (process _)
(pcase (process-status process)
('signal
;; If a kernel dies unexpectedly, run the shutdown
;; procedure on it.
(jupyter-shutdown (process-get process :kernel))))))))
(let ((kernel (process-get process :kernel)))
(when kernel
(warn "Kernel died unexpectedly")
(jupyter-shutdown kernel)))))))))
(cl-call-next-method))
(cl-defmethod jupyter-shutdown ((kernel jupyter-kernel-process))
"Shutdown KERNEL by killing its process unconditionally."
(let ((process (jupyter-process kernel)))
(when process
(delete-process process)
(setf (process-get process :kernel) nil))
(setf (process-get process :kernel) nil)
(delete-process process))
(cl-call-next-method)))
;; TODO