Commit 1abf4098 authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

kernels: 'read-message' no longer swallows heartbeat messages.

* jupyter/kernels.scm (read-message): Return heartbeat messages.
parent 0bd4ecd7
......@@ -260,9 +260,13 @@ return its PID."
;;
(define* (read-message kernel #:optional (timeout -1))
"Read one message from one of the sockets of KERNEL and return it. If
TIMEOUT is -1, wait indefinitely; otherwise wait that number of milliseconds.
If TIMEOUT expires before a message has been received, return #f."
"Read one message from one of the sockets of KERNEL and return it. If the
message is a \"regular\" JSON message, return it as an alist; if it's a
heartbeat message, return it as a bytevector.
If TIMEOUT is -1, wait indefinitely; otherwise wait that number of
milliseconds. If TIMEOUT expires before a message has been received, return
#f."
(define shell (kernel-shell kernel))
(define iopub (kernel-iopub kernel))
(define items
......@@ -277,11 +281,12 @@ If TIMEOUT expires before a message has been received, return #f."
#f)
((item rest ...)
(let ((socket (poll-item-socket item)))
(cond ((eq? socket (kernel-heartbeat kernel))
(loop rest))
(else
(parts->message
(zmq-get-msg-parts-bytevector socket)))))))))
;; Heartbeat messages are raw "bytestrings" that should be echoed
;; back right away.
(if (eq? socket (kernel-heartbeat kernel))
(zmq-get-msg-bytevector socket)
(parts->message
(zmq-get-msg-parts-bytevector socket))))))))
(define* (send-message kernel message
#:key
......
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