From f534172049f2a169d6fba6d106da9368b373b179 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Fri, 8 May 2020 15:16:16 -0500 Subject: [PATCH] Remove `jupyter--kernel-died-process-sentinel` Replace with a function passed to `jupyter-launch` - Getting wrong number of argument errors on the method - Also mention that the `jupyter-kernel-died` function should have been called only when the process status is signal. --- jupyter-kernel-process.el | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/jupyter-kernel-process.el b/jupyter-kernel-process.el index 0e9025f..549cc6a 100644 --- a/jupyter-kernel-process.el +++ b/jupyter-kernel-process.el @@ -268,16 +268,6 @@ process is launched, also just before Emacs exits.") (push (list process conn-file) jupyter--kernel-processes) process)) -(defun jupyter--kernel-died-process-sentinel (kernel) - "Return a sentinel function calling KERNEL's `jupyter-kernel-died' method. -The method will be called when the process exits or receives a -fatal signal." - (let ((ref (jupyter-weak-ref kernel))) - (lambda (process _) - (when-let (kernel (and (memq (process-status process) '(exit signal)) - (jupyter-weak-ref-resolve ref))) - (jupyter-kernel-died kernel))))) - (cl-defmethod jupyter-launch :before ((kernel jupyter-kernel-process)) "Ensure KERNEL has a non-nil SESSION slot. A `jupyter-session' with random port numbers for the channels and @@ -305,16 +295,15 @@ slot. See also https://jupyter-client.readthedocs.io/en/stable/kernels.html#kernel-specs" (let ((process (jupyter-process kernel))) (unless (process-live-p process) - (setq process (jupyter--start-kernel-process - (jupyter-kernel-name kernel) spec - (jupyter-write-connection-file session))) - (setf (process-get process :kernel) kernel)) - (setf (process-sentinel process) - ;; TODO: Have the sentinel function do something like - ;; notify clients. It should also handle auto-restarting - ;; if that is wanted. - (jupyter--kernel-died-process-sentinel kernel)) - (setf (jupyter-kernel-process-process kernel) process))) + (pcase-let (((cl-struct jupyter-kernel-process spec session) kernel)) + (setq process (jupyter--start-kernel-process + (jupyter-kernel-name kernel) spec + (jupyter-write-connection-file session)))) + (setf (process-get process :kernel) kernel) + (setf (lambda (process _) + (pcase (process-status process) + ('signal + (jupyter-kernel-died (process-get process :kernel)))))))) (cl-call-next-method)) ;; TODO: Add restart argument