From 5a7c0831690dd9ade8de00334abc2e57964d0288 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Wed, 14 Nov 2018 18:07:18 -0600 Subject: [PATCH] More reliably capture the startup message It still sometimes isn't caught but it is more reliable. This mainly affects testing. * jupyter-client.el (jupyter-start-channels): Add a small delay after starting channels. * jupyter-kernel-manager.el (jupyter-start-kernel): Remove superfluous delay. --- jupyter-client.el | 5 ++++- jupyter-kernel-manager.el | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/jupyter-client.el b/jupyter-client.el index 3632dd6..5efadb8 100644 --- a/jupyter-client.el +++ b/jupyter-client.el @@ -542,7 +542,10 @@ necessary." (:shell . ,shell) (:iopub . ,iopub) (:stdin . ,stdin)) - when start do (jupyter-start-channel client channel))) + when start do (jupyter-start-channel client channel)) + ;; Needed for reliability. Sometimes we are not fast enough to capture the + ;; startup message of a kernel. + (sleep-for 0.3)) (cl-defmethod jupyter-stop-channels ((client jupyter-kernel-client)) "Stop any running channels of CLIENT." diff --git a/jupyter-kernel-manager.el b/jupyter-kernel-manager.el index a3e9e7e..6c2664a 100644 --- a/jupyter-kernel-manager.el +++ b/jupyter-kernel-manager.el @@ -189,8 +189,6 @@ kernel. Starting a kernel involves the following steps: (let ((json-encoding-pretty-print t)) (with-temp-file conn-file (insert (json-encode-plist conn-info)))) - ;; This is needed for reliability - (sleep-for 0.5) ;; Start the process (let ((atime (nth 4 (file-attributes conn-file))) (proc (jupyter--start-kernel