mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-05 07:41:37 -05:00
Introduce jupyter-wait-until-startup
This commit is contained in:
parent
c86ab40514
commit
af82c55b1c
2 changed files with 29 additions and 5 deletions
|
@ -612,6 +612,34 @@ that if no TIMEOUT is given, it defaults to
|
|||
(declare (indent 1))
|
||||
(jupyter-wait-until req msg-type #'identity timeout))
|
||||
|
||||
;; TODO: Check if kernel has already started. This doesn't seem possible at
|
||||
;; first glance since a client can connect to a kernel at any time. We may be
|
||||
;; able to check if client has a kernel manager parent instance.
|
||||
;;
|
||||
;; TODO: Global message callbacks, i.e. messages callbacks for all messages of
|
||||
;; a channel instead of just for a particular request. It would remove the need
|
||||
;; for `jupyter-missing-request'. It also seems like channel callbacks should
|
||||
;; be a feature anyways.
|
||||
(defun jupyter-wait-until-startup (client &optional timeout)
|
||||
"Wait until CLIENT receives a status: starting message.
|
||||
Return the startup message if received by CLIENT within TIMEOUT
|
||||
seconds otherwise return nil. TIMEOUT defaults to 1 s. Note that
|
||||
there are no checks to determine if the kernel CLIENT is
|
||||
connected to has already been started."
|
||||
(cl-check-type client jupyter-kernel-client)
|
||||
(prog1 (jupyter-wait-until
|
||||
;; TODO: Better name than missing-request. Something like headless
|
||||
;; request seems more accurate since a starting message has no
|
||||
;; parent header, but it still seems like you need to know more
|
||||
;; about it.
|
||||
(jupyter-missing-request client) :status
|
||||
(lambda (msg) (equal (jupyter-message-get msg :execution_state)
|
||||
"starting"))
|
||||
timeout)
|
||||
;; Remove the callback since the `jupyter-missing-request' does not go
|
||||
;; through the normal request code path
|
||||
(setf (jupyter-request-callbacks (jupyter-missing-request client)) nil)))
|
||||
|
||||
(defun jupyter--drop-idle-requests (client)
|
||||
(cl-loop
|
||||
with requests = (oref client requests)
|
||||
|
|
|
@ -303,11 +303,7 @@ listening and the heartbeat channel un-paused."
|
|||
(jupyter-start-kernel km)
|
||||
(condition-case nil
|
||||
(progn
|
||||
;; Wait for the startup message
|
||||
(jupyter-wait-until-received :status (jupyter-missing-request kc) 10)
|
||||
;; Remove the callback since the `jupyter-missing-request' does not go
|
||||
;; through the normal request code path in `jupyter-kernel-client'
|
||||
(setf (jupyter-request-callbacks (jupyter-missing-request kc)) nil)
|
||||
(jupyter-wait-until-startup kc 10)
|
||||
(let ((info (jupyter-wait-until-received :kernel-info-reply
|
||||
(jupyter-request-inhibit-handlers
|
||||
(jupyter-kernel-info-request kc))
|
||||
|
|
Loading…
Add table
Reference in a new issue