jupyter-request-idle-received-p -> jupyter-request-idle-p

but first...

* jupyter-base.el: ...idle-received-p -> idle-p for jupyter-request objects

* jupyter-client.el: ...then, do it.

* test/jupyter-test.el: Do it.
This commit is contained in:
Nathaniel Nicandro 2020-04-14 23:18:46 -05:00
parent 7ca3344c1b
commit c3fae7d7df
3 changed files with 14 additions and 14 deletions

View file

@ -462,7 +462,7 @@ following fields:
through calls to `jupyter-add-callback' on the request."
(id "")
(time (current-time))
(idle-received-p nil)
(idle-p nil)
(last-message nil)
(inhibited-handlers nil)
(callbacks))

View file

@ -545,7 +545,7 @@ back."
;; "last-sent" is an alias for the other.
(or (> (hash-table-count requests) 2)
(when-let* ((last-sent (gethash "last-sent" requests)))
(not (jupyter-request-idle-received-p last-sent))))))
(not (jupyter-request-idle-p last-sent))))))
(defsubst jupyter-last-sent-request (client)
"Return the most recent `jupyter-request' made by CLIENT."
@ -557,7 +557,7 @@ back."
(cl-check-type client jupyter-kernel-client)
(maphash (lambda (k v)
(unless (or (equal k "last-sent")
(jupyter-request-idle-received-p v))
(jupyter-request-idle-p v))
(funcall function v)))
(oref client requests)))
@ -672,7 +672,7 @@ multiple callbacks you would do
:execute-reply (lambda (msg) ...)
:execute-result (lambda (msg) ...))"
(declare (indent 1))
(if (jupyter-request-idle-received-p req)
(if (jupyter-request-idle-p req)
(error "Request already received idle message")
(while (and msg-type cb)
(cl-check-type cb function "Callback should be a function")
@ -739,7 +739,7 @@ within TIMEOUT. Note that if no TIMEOUT is given, it defaults to
If PROGRESS-MSG is non-nil, it is a message string to display for
reporting progress to the user while waiting."
(or (jupyter-request-idle-received-p req)
(or (jupyter-request-idle-p req)
(jupyter-wait-until req :status
#'jupyter-message-status-idle-p timeout progress-msg)))
@ -796,7 +796,7 @@ received for it and it is not the most recently sent request."
(cl-loop
with last-sent = (gethash "last-sent" requests)
for req in (hash-table-values requests)
when (and (jupyter-request-idle-received-p req)
when (and (jupyter-request-idle-p req)
(not (eq req last-sent)))
do (unwind-protect
(jupyter-drop-request client req)
@ -928,7 +928,7 @@ completed, requests from CLIENT's request table."
;; coming in out of order, e.g. before their respective reply
;; messages.
(jupyter--drop-idle-requests client)
(setf (jupyter-request-idle-received-p req) t)))))
(setf (jupyter-request-idle-p req) t)))))
(t
(when (and (or (jupyter-get client 'jupyter-include-other-output)
;; Always handle a startup message
@ -1883,7 +1883,7 @@ Run FUN when the completions are available."
(- (point) (length prefix)) (point)
(completion-table-dynamic
(lambda (_)
(when (and req (not (jupyter-request-idle-received-p req))
(when (and req (not (jupyter-request-idle-p req))
(not (eq (jupyter-message-type
(jupyter-request-last-message req))
:complete-reply)))

View file

@ -100,7 +100,7 @@
(let ((req (jupyter-send-execute-request client :code "foo")))
(ert-info ("Blocking callbacks")
(jupyter-wait-until-idle req)
(should (jupyter-request-idle-received-p req)))
(should (jupyter-request-idle-p req)))
(ert-info ("Error after idle message has been received")
(should-error (jupyter-add-callback req :status #'identity))))))
@ -929,7 +929,7 @@
(should (memq r2 mapped))
(setq mapped nil)
(setf (jupyter-request-idle-received-p r2) t)
(setf (jupyter-request-idle-p r2) t)
(jupyter-map-pending-requests client
(lambda (req) (push req mapped)))
(should (= (length mapped) 1))
@ -942,16 +942,16 @@
:tags '(client hook)
(jupyter-test-with-python-client client
(let ((req (jupyter-send-execute-request client :code "1 + 1")))
(should-not (jupyter-request-idle-received-p req))
(should-not (jupyter-request-idle-p req))
(jupyter-idle-sync req)
(should (jupyter-request-idle-received-p req)))
(should (jupyter-request-idle-p req)))
(let ((req (jupyter-send-execute-request client :code "1 + 1")))
(should (null jupyter-test-idle-sync-hook))
(jupyter-add-idle-sync-hook 'jupyter-test-idle-sync-hook req)
(should-not (null jupyter-test-idle-sync-hook))
(should-not (jupyter-request-idle-received-p req))
(should-not (jupyter-request-idle-p req))
(run-hooks 'jupyter-test-idle-sync-hook)
(should (jupyter-request-idle-received-p req))
(should (jupyter-request-idle-p req))
(should (null jupyter-test-idle-sync-hook)))))
;;; IOloop