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." ...@@ -84,21 +84,17 @@ acts as a proxy to an actual kernel."
;; Handlers. ;; Handlers.
;; ;;
(define (heartbeat-handler kernel) (define (general-handler kernel kind message state)
(let ((message (zmq-message-receive-bytevector (kernel-heartbeat kernel) "Handle MESSAGE, which was sent by KERNEL, a client of ours, on KIND (one
(zmq-msg-init)))) of 'kernel-shell', 'kernel-stdin', etc.)"
(zmq-message-send-bytevector (kernel-heartbeat kernel) message)) (match state
(heartbeat-handler kernel)) ((containers count)
(let ((handler (dispatch (message-type message))))
(pub-busy kernel message)
(define (general-handler kernel containers count) (let-values (((containers count)
(let* ((message (read-message kernel)) (handler kernel message containers count)))
(handler (dispatch (message-type message)))) (pub-idle kernel message)
(pub-busy kernel message) (list containers count))))))
(let-values (((containers count)
(handler kernel message containers count)))
(pub-idle kernel message)
(general-handler kernel containers count))))
;; Unknown request type, ignore it. ;; Unknown request type, ignore it.
(define (ignore-request kernel message containers count) (define (ignore-request kernel message containers count)
...@@ -287,12 +283,6 @@ MESSAGE." ...@@ -287,12 +283,6 @@ MESSAGE."
%namespaces 1 %namespaces 1
exec))) 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) (define (exit-handler kernel)
(lambda _ (lambda _
...@@ -304,5 +294,11 @@ MESSAGE." ...@@ -304,5 +294,11 @@ MESSAGE."
connection-file->kernel))) connection-file->kernel)))
(sigaction SIGTERM (exit-handler kernel)) (sigaction SIGTERM (exit-handler kernel))
(sigaction SIGINT (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