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