Skip to content

Commit efbb295

Browse files
committed
Make stdin messaging docs not IPython specific
Closes jupyter/notebook#1585
1 parent c5bcb82 commit efbb295

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

docs/messaging.rst

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,17 +1087,27 @@ Message type: ``clear_output``::
10871087
The selective clearing keys are ignored in v4 and the default behavior remains the same,
10881088
so v4 clear_output messages will be safely handled by a v4.1 frontend.
10891089

1090+
.. _stdin_messages:
10901091

10911092
Messages on the stdin ROUTER/DEALER sockets
10921093
===========================================
10931094

10941095
This is a socket where the request/reply pattern goes in the opposite direction:
1095-
from the kernel to a *single* frontend, and its purpose is to allow
1096-
``raw_input`` and similar operations that read from ``sys.stdin`` on the kernel
1097-
to be fulfilled by the client. The request should be made to the frontend that
1098-
made the execution request that prompted ``raw_input`` to be called. For now we
1099-
will keep these messages as simple as possible, since they only mean to convey
1100-
the ``raw_input(prompt)`` call.
1096+
from the kernel to a *single* frontend. Its purpose is to allow code to prompt
1097+
the user for a line of input, which would normally be read from stdin in a
1098+
terminal.
1099+
1100+
Many programming languages provide a function which displays a prompt, blocks
1101+
until the user presses return, and returns the text they typed before pressing
1102+
return. In Python 3, this is the ``input()`` function; in R it is called
1103+
``readline()``. If the :ref:`execute_request <execute>` message has
1104+
``allow_stdin==True``, kernels may implement these functions so that they send
1105+
an ``input_request`` message and wait for a corresponding ``input_reply``. The
1106+
frontend is responsible for displaying the prompt and getting the user's input.
1107+
1108+
If ``allow_stdin`` is False, the kernel must not send ``stdin_request``. The
1109+
kernel may decide what to do instead, but it's most likely that calls to the
1110+
'prompt for input' function should fail immediately in this case.
11011111

11021112
Message type: ``input_request``::
11031113

@@ -1114,7 +1124,10 @@ Message type: ``input_reply``::
11141124
content = { 'value' : str }
11151125

11161126

1117-
When ``password`` is True, the frontend should not echo the input as it is entered.
1127+
When ``password`` is True, the frontend should not show the input as it is entered.
1128+
Different frontends may obscure it in different ways; e.g. showing each
1129+
character entered as the same neutral symbol, or not showing anything at all as
1130+
the user types.
11181131

11191132
.. versionchanged:: 5.0
11201133

@@ -1130,14 +1143,10 @@ When ``password`` is True, the frontend should not echo the input as it is enter
11301143

11311144
.. note::
11321145

1133-
We do not explicitly try to forward the raw ``sys.stdin`` object, because in
1134-
practice the kernel should behave like an interactive program. When a
1135-
program is opened on the console, the keyboard effectively takes over the
1136-
``stdin`` file descriptor, and it can't be used for raw reading anymore.
1137-
Since the IPython kernel effectively behaves like a console program (albeit
1138-
one whose "keyboard" is actually living in a separate process and
1139-
transported over the zmq connection), raw ``stdin`` isn't expected to be
1140-
available.
1146+
This model of requesting user input is quite different from how stdin works
1147+
at a lower level. The Jupyter protocol does not support everything code
1148+
running in a terminal can do with stdin, but we believe that this enables the
1149+
most common use cases.
11411150

11421151
.. _kernel_heartbeat:
11431152

0 commit comments

Comments
 (0)