@@ -108,6 +108,12 @@ function complete_types(comps)
108108 return typeMap
109109end
110110
111+ """
112+ complete_request(socket, msg)
113+
114+ Handle a [completion
115+ request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion).
116+ """
111117function complete_request (socket, msg)
112118 code = msg. content[" code" ]
113119 cursor_chr = msg. content[" cursor_pos" ]
@@ -153,6 +159,12 @@ function complete_request(socket, msg)
153159 " cursor_end" => cursor_end)))
154160end
155161
162+ """
163+ kernel_info_request(socket, msg)
164+
165+ Handle a [kernel info
166+ request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info).
167+ """
156168function kernel_info_request (socket, msg)
157169 send_ipython (socket,
158170 msg_reply (msg, " kernel_info_reply" ,
@@ -179,21 +191,34 @@ function kernel_info_request(socket, msg)
179191 " status" => " ok" )))
180192end
181193
194+ """
195+ connect_request(socket, msg)
196+
197+ Handle a [connect
198+ request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#connect).
199+ """
182200function connect_request (socket, msg)
183201 send_ipython (requests[],
184202 msg_reply (msg, " connect_reply" ,
185203 Dict (" shell_port" => profile[" shell_port" ],
186- " iopub_port" => profile[" iopub_port" ],
187- " stdin_port" => profile[" stdin_port" ],
188- " hb_port" => profile[" hb_port" ])))
204+ " iopub_port" => profile[" iopub_port" ],
205+ " stdin_port" => profile[" stdin_port" ],
206+ " hb_port" => profile[" hb_port" ])))
189207end
190208
209+ """
210+ shutdown_request(socket, msg)
211+
212+ Handle a [shutdown
213+ request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-shutdown). After
214+ sending the reply this will exit the process.
215+ """
191216function shutdown_request (socket, msg)
192217 # stop heartbeat thread by closing the context
193218 close (heartbeat_context[])
194219
195220 send_ipython (requests[], msg_reply (msg, " shutdown_reply" ,
196- msg. content))
221+ msg. content))
197222 sleep (0.1 ) # short delay (like in ipykernel), to hopefully ensure shutdown_reply is sent
198223 exit ()
199224end
@@ -235,6 +260,12 @@ function get_token(code, pos)
235260 return code[startpos: endpos]
236261end
237262
263+ """
264+ inspect_request(socket, msg)
265+
266+ Handle a [introspection
267+ request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection).
268+ """
238269function inspect_request (socket, msg)
239270 try
240271 code = msg. content[" code" ]
@@ -256,6 +287,13 @@ function inspect_request(socket, msg)
256287 end
257288end
258289
290+ """
291+ history_request(socket, msg)
292+
293+ Handle a [history
294+ request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history). This
295+ is currently only a dummy implementation that doesn't actually do anything.
296+ """
259297function history_request (socket, msg)
260298 # we will just send back empty history for now, pending clarification
261299 # as requested in ipython/ipython#3806
@@ -264,6 +302,12 @@ function history_request(socket, msg)
264302 Dict (" history" => [])))
265303end
266304
305+ """
306+ is_complete_request(socket, msg)
307+
308+ Handle a [completeness
309+ request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-completeness).
310+ """
267311function is_complete_request (socket, msg)
268312 ex = Meta. parse (msg. content[" code" ], raise= false )
269313 status = Meta. isexpr (ex, :incomplete ) ? " incomplete" : Meta. isexpr (ex, :error ) ? " invalid" : " complete"
@@ -272,6 +316,13 @@ function is_complete_request(socket, msg)
272316 Dict (" status" => status, " indent" => " " )))
273317end
274318
319+ """
320+ interrupt_request(socket, msg)
321+
322+ Handle a [interrupt
323+ request](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-interrupt). This
324+ will throw an `InterruptException` to the currently executing request handler.
325+ """
275326function interrupt_request (socket, msg)
276327 @async Base. throwto (requests_task[], InterruptException ())
277328 send_ipython (socket, msg_reply (msg, " interrupt_reply" , Dict ()))
0 commit comments