@@ -400,47 +400,42 @@ the callbacks."
400400 (let ((id (jupyter-request-id req)))
401401 (jupyter-publisher
402402 (lambda (msg )
403- (cond
404- ((and (jupyter-request-idle-p req)
405- ; ; A status message after a request goes idle
406- ; ; means there is a new request and there will,
407- ; ; theoretically, be no more messages for the
408- ; ; idle one.
409- ; ;
410- ; ; FIXME: Is that true? Figure out the difference
411- ; ; between a status: busy and a status: idle
412- ; ; message.
413- (string= (jupyter-message-type msg) " status" ))
414- ; ; What happens to the subscriber references of this
415- ; ; publisher after it unsubscribes? They remain until
416- ; ; the publisher itself is no longer accessible.
417- (jupyter-unsubscribe))
418- ; ; TODO: `jupyter-message-parent-id' -> `jupyter-parent-id'
419- ; ; and the like.
420- ((string= id (jupyter-message-parent-id msg))
421- (setf (jupyter-request-last-message req) msg)
422- (cl-callf nconc (jupyter-request-messages req) (list msg))
423- (when (or (jupyter-message-status-idle-p msg)
424- ; ; Jupyter protocol 5.1, IPython
425- ; ; implementation 7.5.0 doesn't give
426- ; ; status: busy or status: idle messages
427- ; ; on kernel-info-requests. Whereas
428- ; ; IPython implementation 6.5.0 does.
429- ; ; Seen on Appveyor tests.
430- ; ;
431- ; ; TODO: May be related
432- ; ; jupyter/notebook#3705 as the problem
433- ; ; does happen after a kernel restart
434- ; ; when testing.
435- (string= (jupyter-message-type msg) " kernel_info_reply" )
436- ; ; No idle message is received after a
437- ; ; shutdown reply so consider REQ as
438- ; ; having received an idle message in
439- ; ; this case.
440- (string= (jupyter-message-type msg) " shutdown_reply" ))
441- (setf (jupyter-request-idle-p req) t ))
442- (jupyter-content
443- (cl-list* :parent-request req msg))))))))
403+ (pcase (jupyter-message-type msg)
404+ ; ; A status message after a request goes idle means there is
405+ ; ; a new request and there will, theoretically, be no more
406+ ; ; messages for the idle one.
407+ ; ;
408+ ; ; FIXME: Is that true? Figure out the difference between a
409+ ; ; status: busy and a status: idle message.
410+ ((and type (guard (jupyter-request-idle-p req))
411+ (guard (string= type " status" )))
412+ (jupyter-unsubscribe))
413+ ; ; TODO: `jupyter-message-parent-id' -> `jupyter-parent-id'
414+ ; ; and the like.
415+ ((guard (string= id (jupyter-message-parent-id msg)))
416+ (setf (jupyter-request-last-message req) msg)
417+ (cl-callf nconc (jupyter-request-messages req) (list msg))
418+ (when (or (jupyter-message-status-idle-p msg)
419+ ; ; Jupyter protocol 5.1, IPython
420+ ; ; implementation 7.5.0 doesn't give
421+ ; ; status: busy or status: idle messages
422+ ; ; on kernel-info-requests. Whereas
423+ ; ; IPython implementation 6.5.0 does.
424+ ; ; Seen on Appveyor tests.
425+ ; ;
426+ ; ; TODO: May be related
427+ ; ; jupyter/notebook#3705 as the problem
428+ ; ; does happen after a kernel restart
429+ ; ; when testing.
430+ (string= (jupyter-message-type msg) " kernel_info_reply" )
431+ ; ; No idle message is received after a
432+ ; ; shutdown reply so consider REQ as
433+ ; ; having received an idle message in
434+ ; ; this case.
435+ (string= (jupyter-message-type msg) " shutdown_reply" ))
436+ (setf (jupyter-request-idle-p req) t ))
437+ (jupyter-content
438+ (cl-list* :parent-request req msg))))))))
444439
445440(defvar jupyter-inhibit-handlers )
446441
0 commit comments