mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-06 07:51:39 -05:00
Add jupyter--get-channel
This commit is contained in:
parent
aa054178b7
commit
95a5cfbd74
1 changed files with 14 additions and 22 deletions
|
@ -518,6 +518,16 @@ in CLIENT."
|
||||||
(jupyter-stop-channel (oref client hb-channel))
|
(jupyter-stop-channel (oref client hb-channel))
|
||||||
(oset client ioloop nil))))
|
(oset client ioloop nil))))
|
||||||
|
|
||||||
|
(defun jupyter--get-channel (client ctype)
|
||||||
|
"Get CLIENT's channel based on CTYPE."
|
||||||
|
(cl-find-if
|
||||||
|
(lambda (channel) (eq (oref channel type) ctype))
|
||||||
|
(mapcar (lambda (sym) (slot-value client sym))
|
||||||
|
'(hb-channel
|
||||||
|
stdin-channel
|
||||||
|
shell-channel
|
||||||
|
iopub-channel))))
|
||||||
|
|
||||||
(defun jupyter--ioloop-filter (client event)
|
(defun jupyter--ioloop-filter (client event)
|
||||||
"The process filter for CLIENT's ioloop subprocess.
|
"The process filter for CLIENT's ioloop subprocess.
|
||||||
EVENT will be an s-expression emitted from the function returned
|
EVENT will be an s-expression emitted from the function returned
|
||||||
|
@ -539,33 +549,15 @@ by `jupyter--ioloop'."
|
||||||
(jupyter-message-type msg)
|
(jupyter-message-type msg)
|
||||||
(jupyter-message-parent-id msg)
|
(jupyter-message-parent-id msg)
|
||||||
(jupyter-message-content msg)))
|
(jupyter-message-content msg)))
|
||||||
(let ((channel (cl-loop
|
(let ((channel (jupyter--get-channel client ctype)))
|
||||||
for c in '(stdin-channel
|
|
||||||
shell-channel
|
|
||||||
iopub-channel)
|
|
||||||
for channel = (slot-value client c)
|
|
||||||
when (eq (oref channel type) ctype)
|
|
||||||
return channel)))
|
|
||||||
(if (not channel) (warn "No handler for channel type (%s)" ctype)
|
(if (not channel) (warn "No handler for channel type (%s)" ctype)
|
||||||
(jupyter-queue-message channel (cons idents msg))
|
(jupyter-queue-message channel (cons idents msg))
|
||||||
(run-with-timer 0.0001 nil #'jupyter-handle-message client channel))))
|
(run-with-timer 0.0001 nil #'jupyter-handle-message client channel))))
|
||||||
(`(start-channel ,ctype)
|
(`(start-channel ,ctype)
|
||||||
(let ((channel (cl-loop
|
(let ((channel (jupyter--get-channel client ctype)))
|
||||||
for c in '(stdin-channel
|
|
||||||
shell-channel
|
|
||||||
iopub-channel)
|
|
||||||
for channel = (slot-value client c)
|
|
||||||
when (eq (oref channel type) ctype)
|
|
||||||
return channel)))
|
|
||||||
(oset channel status 'running)))
|
(oset channel status 'running)))
|
||||||
(`(stop-channel ,ctype)
|
(`(stop-channel ,ctype)
|
||||||
(let ((channel (cl-loop
|
(let ((channel (jupyter--get-channel client ctype)))
|
||||||
for c in '(stdin-channel
|
|
||||||
shell-channel
|
|
||||||
iopub-channel)
|
|
||||||
for channel = (slot-value client c)
|
|
||||||
when (eq (oref channel type) ctype)
|
|
||||||
return channel)))
|
|
||||||
(oset channel status 'stopped)))
|
(oset channel status 'stopped)))
|
||||||
('(quit)
|
('(quit)
|
||||||
;; Cleanup handled in sentinel
|
;; Cleanup handled in sentinel
|
||||||
|
@ -598,7 +590,7 @@ would have to pass a nil value for the channel's key. As an
|
||||||
example, to prevent the control channel from starting you would
|
example, to prevent the control channel from starting you would
|
||||||
call this function like so
|
call this function like so
|
||||||
|
|
||||||
(jupyter-start-channels client :control nil)
|
(jupyter-start-channels client :stdin nil)
|
||||||
|
|
||||||
In addition to calling `jupyter-start-channel', a subprocess is
|
In addition to calling `jupyter-start-channel', a subprocess is
|
||||||
created for each channel which monitors the channel's socket for
|
created for each channel which monitors the channel's socket for
|
||||||
|
|
Loading…
Add table
Reference in a new issue