Skip to content

Commit 28a963e

Browse files
authored
Add messaging docs for optional features and kernel subshells (#1045)
* Add messaging docs for optional features and kernel subshells * Use ID rather than id in text * Review comment
1 parent 80c6367 commit 28a963e

File tree

1 file changed

+116
-11
lines changed

1 file changed

+116
-11
lines changed

docs/messaging.rst

Lines changed: 116 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Message Header
9797
--------------
9898

9999
The message ``header`` contains information about the message,
100-
such as unique identifiers for the originating session and the actual message id,
100+
such as unique identifiers for the originating session and the actual message ID,
101101
the type of message, the version of the Jupyter protocol,
102102
and the date the message was created.
103103
In addition, there is a username field, e.g. for the process that generated the
@@ -118,27 +118,34 @@ so that frontends can label the various messages in a meaningful way.
118118
"msg_type": str,
119119
# the message protocol version
120120
"version": "5.0",
121+
# Optional subshell_id
122+
"subshell_id": str | None,
121123
}
122124

123125
.. note::
124126

125-
The ``session`` id in a message header identifies a unique entity with state,
127+
The ``session`` ID in a message header identifies a unique entity with state,
126128
such as a kernel process or client process.
127129

128-
A client session id, in message headers from a client, should be unique among
130+
A client session ID, in message headers from a client, should be unique among
129131
all clients connected to a kernel. When a client reconnects to a kernel, it
130-
should use the same client session id in its message headers. When a client
131-
restarts, it should generate a new client session id.
132+
should use the same client session ID in its message headers. When a client
133+
restarts, it should generate a new client session ID.
132134

133-
A kernel session id, in message headers from a kernel, should identify a
134-
particular kernel process. If a kernel is restarted, the kernel session id
135+
A kernel session ID, in message headers from a kernel, should identify a
136+
particular kernel process. If a kernel is restarted, the kernel session ID
135137
should be regenerated.
136138

137-
The session id in a message header can be used to identify the sending entity.
139+
The session ID in a message header can be used to identify the sending entity.
138140
For example, if a client disconnects and reconnects to a kernel, and messages
139-
from the kernel have a different kernel session id than prior to the disconnect,
141+
from the kernel have a different kernel session ID than prior to the disconnect,
140142
the client should assume that the kernel was restarted.
141143

144+
The ``subshell_id`` is only used in shell messages of kernels that support
145+
subshells (:ref:`kernel_subshells`). If it is not included or is ``None`` then the
146+
shell message is handled by the parent subshell (main shell), if it is a string
147+
subshell ID then it is handled by the subshell with that ID.
148+
142149
.. versionchanged:: 5.0
143150

144151
``version`` key added to the header.
@@ -150,6 +157,10 @@ so that frontends can label the various messages in a meaningful way.
150157
so implementers are strongly encouraged to include it.
151158
It will be mandatory in 5.1.
152159

160+
.. versionchanged:: 5.5
161+
162+
``subshell_id`` added to the header.
163+
153164
Parent header
154165
-------------
155166

@@ -913,7 +924,7 @@ Message type: ``comm_info_reply``::
913924
# 'ok' if the request succeeded or 'error', with error information as in all other replies.
914925
'status' : 'ok',
915926

916-
# A dictionary of the comms, indexed by uuids.
927+
# A dictionary of the comms, indexed by UUIDs.
917928
'comms': {
918929
comm_id: {
919930
'target_name': str,
@@ -997,14 +1008,20 @@ Message type: ``kernel_info_reply``::
9971008
'banner': str,
9981009

9991010
# A boolean flag which tells if the kernel supports debugging in the notebook.
1000-
# Default is False
1011+
# Default is False.
1012+
# Deprecated as replaced by 'supported_features'=['debugger'] (see below).
10011013
'debugger': bool,
10021014

10031015
# Optional: A list of dictionaries, each with keys 'text' and 'url'.
10041016
# These will be displayed in the help menu in the notebook UI.
10051017
'help_links': [
10061018
{'text': str, 'url': str}
10071019
],
1020+
1021+
# Optional: A list of optional features such as 'debugger' and
1022+
# 'kernel subshells'. Introduced by Jupyter Enhancement Proposal 92
1023+
# https://github.com/jupyter/enhancement-proposals/pull/92
1024+
'supported_features': [str]
10081025
}
10091026

10101027
Refer to the lists of available `Pygments lexers <http://pygments.org/docs/lexers/>`_
@@ -1031,6 +1048,10 @@ and `codemirror modes <http://codemirror.net/mode/index.html>`_ for those fields
10311048

10321049
``language`` moved to ``language_info.name``
10331050

1051+
.. versionchanged:: 5.5
1052+
1053+
``supported_features`` added and ``debugger`` deprecated.
1054+
10341055
Messages on the Control (ROUTER/DEALER) channel
10351056
===============================================
10361057

@@ -1313,6 +1334,86 @@ of the debugger to the ``global`` scope to inspect it after debug session.
13131334

13141335
.. versionadded:: 5.5
13151336

1337+
.. _kernel_subshells:
1338+
1339+
Kernel subshells
1340+
----------------
1341+
1342+
Kernel subshells are separate threads of execution within the same kernel process that
1343+
were introduced by
1344+
`Jupyter Enhancement Proposal 91 <https://github.com/jupyter/enhancement-proposals/pull/91>`_.
1345+
Kernels supporting subshells must include ``'kernel subshells'`` in ``'supported_features'``
1346+
in :ref:`kernel info <msging_kernel_info>` reply messages.
1347+
1348+
Create subshell
1349+
~~~~~~~~~~~~~~~
1350+
1351+
In a kernel that supports subshells, this creates a new subshell (running in a separate thread)
1352+
and returns its unique ID. In a kernel that does not support subshells an error is logged and
1353+
no reply is sent.
1354+
1355+
Message type: ``create_subshell_request``::
1356+
1357+
content = {
1358+
}
1359+
1360+
Message type: ``create_subshell_reply``::
1361+
1362+
content = {
1363+
# 'ok' if the request succeeded or 'error', with error information as in all other replies.
1364+
'status' : 'ok',
1365+
1366+
# The ID of the subshell, unique within the kernel.
1367+
'subshell_id': str,
1368+
}
1369+
1370+
.. versionadded:: 5.5
1371+
1372+
Delete subshell
1373+
~~~~~~~~~~~~~~~
1374+
1375+
In a kernel that supports subshells, this deletes a subshell identified by its unique ID.
1376+
In a kernel that does not support subshells an error is logged and no reply is sent.
1377+
1378+
Message type: ``delete_subshell_request``::
1379+
1380+
content = {
1381+
# The ID of the subshell.
1382+
'subshell_id': str
1383+
}
1384+
1385+
Message type: ``delete_subshell_reply``::
1386+
1387+
content = {
1388+
# 'ok' if the request succeeded or 'error', with error information as in all other replies.
1389+
'status': 'ok',
1390+
}
1391+
1392+
.. versionadded:: 5.5
1393+
1394+
List subshell
1395+
~~~~~~~~~~~~~
1396+
1397+
In a kernel that supports subshells, this returns a list of the IDs of all subshells that exist
1398+
in that kernel. In a kernel that does not support subshells an error is logged and no reply is sent.
1399+
1400+
Message type: ``list_subshell_request``::
1401+
1402+
content = {
1403+
}
1404+
1405+
Message type: ``list_subshell_reply``::
1406+
1407+
content = {
1408+
# 'ok' if the request succeeded or 'error', with error information as in all other replies.
1409+
'status': 'ok',
1410+
1411+
# A list of subshell IDs.
1412+
'subshell_id': [str]
1413+
}
1414+
1415+
.. versionadded:: 5.5
1416+
13161417
Messages on the IOPub (PUB/SUB) channel
13171418
=======================================
13181419

@@ -1755,6 +1856,10 @@ Changelog
17551856

17561857
- Added ``debug_request/reply`` messages
17571858
- Added ``debug_event`` message
1859+
- Added ``supported_features`` in :ref:`kernel info <msging_kernel_info>` reply messages.
1860+
- Deprecated ``debugger`` in :ref:`kernel info <msging_kernel_info>` reply messages as
1861+
replaced with ``supported_features``.
1862+
- Added ``create_subshell``, ``delete_subshell`` and ``list_subshell`` messages.
17581863

17591864
5.4
17601865
---

0 commit comments

Comments
 (0)