Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 146fc45

Browse files
committed
Use IPython 1.0-compatible "handshake"
IPython changed the way to start channel [1]. fixes #121 [1] see commit ipython/ipython@24dcb6b in ipython/ipython#3089
1 parent 0cc4943 commit 146fc45

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

lisp/ein-kernel.el

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,14 @@ See: https://github.com/ipython/ipython/pull/3307"
176176
The kernel will no longer be responsive.")))
177177

178178

179-
(defun ein:kernel-send-cookie (channel host)
179+
(defun ein:kernel-send-cookie (channel kernel)
180180
;; cookie can be an empty string for IPython server with no password,
181181
;; but something must be sent to start channel.
182-
(let ((cookie (ein:query-get-cookie host "/")))
183-
(ein:websocket-send channel cookie)))
182+
(let* ((url-or-port (ein:$kernel-url-or-port kernel))
183+
(host (if (stringp url-or-port) url-or-port ein:url-localhost))
184+
(cookie (ein:query-get-cookie host "/"))
185+
(session-id (ein:$kernel-session-id kernel)))
186+
(ein:websocket-send channel (format "%s:%s" session-id cookie))))
184187

185188

186189
(defun ein:kernel--ws-closed-callback (websocket kernel arg)
@@ -214,14 +217,9 @@ See: https://github.com/ipython/ipython/pull/3307"
214217
do (setf (ein:$websocket-onclose-args c) (list kernel onclose-arg))
215218
do (setf (ein:$websocket-onopen c)
216219
(lexical-let ((channel c)
217-
(kernel kernel)
218-
(host (let (url-or-port
219-
(ein:$kernel-url-or-port kernel))
220-
(if (stringp url-or-port)
221-
url-or-port
222-
ein:url-localhost))))
220+
(kernel kernel))
223221
(lambda ()
224-
(ein:kernel-send-cookie channel host)
222+
(ein:kernel-send-cookie channel kernel)
225223
;; run `ein:$kernel-after-start-hook' if both
226224
;; channels are ready.
227225
(when (ein:kernel-live-p kernel)

0 commit comments

Comments
 (0)