Commit 6446ff08 authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

guix-jupyter-kernel: Use 'serve-kernels'.

* guix-jupyter-kernel.scm (heartbeat-handler, start-kernel): Remove.
(general-handler): Adjust prototype to match what 'serve-kernels'
expects.
<top level>: Use 'serve-kernels'.
parent 150c006f
......@@ -84,21 +84,17 @@ acts as a proxy to an actual kernel."
;; Handlers.
;;
(define (heartbeat-handler kernel)
(let ((message (zmq-message-receive-bytevector (kernel-heartbeat kernel)
(zmq-msg-init))))
(zmq-message-send-bytevector (kernel-heartbeat kernel) message))
(heartbeat-handler kernel))
(define (general-handler kernel containers count)
(let* ((message (read-message kernel))
(handler (dispatch (message-type message))))
(pub-busy kernel message)
(let-values (((containers count)
(handler kernel message containers count)))
(pub-idle kernel message)
(general-handler kernel containers count))))
(define (general-handler kernel kind message state)
"Handle MESSAGE, which was sent by KERNEL, a client of ours, on KIND (one
of 'kernel-shell', 'kernel-stdin', etc.)"
(match state
((containers count)
(let ((handler (dispatch (message-type message))))
(pub-busy kernel message)
(let-values (((containers count)
(handler kernel message containers count)))
(pub-idle kernel message)
(list containers count))))))
;; Unknown request type, ignore it.
(define (ignore-request kernel message containers count)
......@@ -287,12 +283,6 @@ MESSAGE."
%namespaces 1
exec)))
(define (start-kernel pid kernel)
(let ((default-container (alist->vhash
`(("default" .
,(new-container-connect "default" pid))))))
(general-handler kernel default-container 0)))
(define (exit-handler kernel)
(lambda _
......@@ -304,5 +294,11 @@ MESSAGE."
connection-file->kernel)))
(sigaction SIGTERM (exit-handler kernel))
(sigaction SIGINT (exit-handler kernel))
(start-kernel (start-container kernel "default" '())
kernel))
(let* ((pid (start-container kernel "default" '()))
(containers (vhash-cons "default"
(new-container-connect "default" pid)
vlist-null)))
(serve-kernels (list kernel)
general-handler
(list containers 0))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment