jupyter-kernel-process: Add connect-p slot

This is used to distinguish between a connection made to an already
existing kernel vs one that is launched by us.
This commit is contained in:
Nathaniel Nicandro 2023-01-28 16:53:11 -06:00
parent ded0306403
commit 97dcb49e46
2 changed files with 11 additions and 4 deletions

View file

@ -53,7 +53,8 @@ exist are deleted.")
;;; Kernel definition
(cl-defstruct (jupyter-kernel-process
(:include jupyter-kernel)))
(:include jupyter-kernel))
connect-p)
(cl-defmethod jupyter-process ((kernel jupyter-kernel-process))
"Return the process of KERNEL.
@ -111,8 +112,10 @@ Call the next method if ARGS does not contain a :spec or
;;; Client connection
(cl-defmethod jupyter-zmq-io ((kernel jupyter-kernel-process))
(jupyter-launch kernel)
(let* ((session (jupyter-kernel-session kernel))
(unless (jupyter-kernel-process-connect-p kernel)
(jupyter-launch kernel))
(let* ((session (or (jupyter-kernel-session kernel)
(error "A session is needed to connect to a kernel's I/O")))
(channels '(:shell :iopub :stdin))
(ch-group (let ((endpoints (jupyter-session-endpoints session)))
(cl-loop

View file

@ -2139,7 +2139,11 @@ like the symbol `jupyter-repl-client', which is the default. "
(or client-class (setq client-class 'jupyter-repl-client))
(jupyter-error-if-not-client-class-p client-class 'jupyter-repl-client)
(jupyter-bootstrap-repl
(jupyter-client (jupyter-kernel :conn-info file) client-class)
(jupyter-client
(jupyter-kernel
:conn-info file
:connect-p t)
client-class)
repl-name associate-buffer display))
(provide 'jupyter-repl)