Commit 22e7d33f authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

kernels: 'run-kernel' no longer requires a UUID parameter.

* jupyter/kernels.scm (run-kernel): Remove 'uuid' parameter and add
 #:identity parameter.  Do not set ZMQ_IDENTITY on SOCKET-SHELL when
 #:identity is #f.
* guix-jupyter-container.scm (reply-execute-request): Pass #:identity to
* tests/kernels.scm (%kernel-uuid): Remove.
("run-kernel python3"): Remove %KERNEL-UUID argument from 'run-kernel'
("execute_request"): Remove #:recipient argument to 'send-message'.
Remove reference to %KERNEL-UUID.
parent 22b789fc
;;; Guix-kernel -- Guix kernel for Jupyter
;;; Copyright (C) 2018 Evgeny Panfilov <>
;;; Copyright (C) 2018 Pierre-Antoine Rouby <>
;;; Copyright (C) 2018 Ludovic Courtès <>
;;; Copyright (C) 2018, 2019 Ludovic Courtès <>
;;; This program is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
......@@ -239,8 +239,9 @@ KEY for signing."
(string->utf8 name) message)
(values kernels (+ count 1)))
(let* ((new-kernel (run-kernel context name
(string->utf8 name)
(string->utf8 name)))
(kernel (socket->kernel socket notebook-key))
(new-kernels (register-kernel kernels new-kernel)))
(relay-message (kernel-shell new-kernel) kernel
......@@ -200,7 +200,7 @@ return its PID."
(apply execl command arguments)))
(define (run-kernel context name uuid key)
(define* (run-kernel context name key #:key identity)
(let* ((socket-control (zmq-create-socket context ZMQ_DEALER))
(socket-shell (zmq-create-socket context ZMQ_DEALER))
(socket-stdin (zmq-create-socket context ZMQ_DEALER))
......@@ -235,9 +235,15 @@ return its PID."
#:standard-input socket-stdin
#:heartbeat socket-heartbeat
#:iosub socket-iosub)))
(zmq-set-socket-option socket-iosub ZMQ_SUBSCRIBE "")
(zmq-set-socket-option socket-shell ZMQ_IDENTITY (utf8->string uuid))
;; <> says
;; that ZeroMQ "generate[s] a 5 byte identity by default", so usually we
;; don't need to provide our own identity.
(when identity
(zmq-set-socket-option socket-shell ZMQ_IDENTITY
(utf8->string identity)))
;; Sub socket connection.
(zmq-connect socket-control (addr-p port-control))
......@@ -25,7 +25,6 @@
(define %context
(define %kernel-uuid #vu8(1 2 3 4 5 6 7 8 9 0))
(define %kernel-key "secretkey")
(define %kernel #f)
......@@ -36,7 +35,7 @@
(unless (find-kernel-by-name "python3") (test-skip 1))
(test-assert "run-kernel python3"
(let ((kernel (run-kernel %context "python3" %kernel-uuid %kernel-key)))
(let ((kernel (run-kernel %context "python3" %kernel-key)))
(set! %kernel kernel)
(and (kernel? (pk 'kernel kernel))
(kill (kernel-pid kernel) 0))))
......@@ -47,11 +46,9 @@
'((code . "40 + 2\n")
(silent . #f))))))
(send-message %kernel request
#:recipient %kernel-uuid)
(send-message %kernel request)
(let ((reply (pk 'reply (read-message %kernel))))
(and (message? reply)
(bytevector=? (message-sender reply) %kernel-uuid)
(equal? (message-parent-header reply)
(message-header request))
(string=? (message-type reply) "execute_reply")
Supports Markdown
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