@@ -1087,17 +1087,29 @@ Message type: ``clear_output``::
1087
1087
The selective clearing keys are ignored in v4 and the default behavior remains the same,
1088
1088
so v4 clear_output messages will be safely handled by a v4.1 frontend.
1089
1089
1090
+ .. _stdin_messages :
1090
1091
1091
1092
Messages on the stdin ROUTER/DEALER sockets
1092
1093
===========================================
1093
1094
1094
- 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.
1095
+ With the stdin ROUTER/DEALER socket, the request/reply pattern goes in the
1096
+ opposite direction of most kernel communication.
1097
+ With the stdin socket, the kernel makes the request, and the single frontend
1098
+ provides the response.
1099
+ This pattern allows code to prompt the user for a line of input,
1100
+ which would normally be read from stdin in a terminal.
1101
+
1102
+ Many programming languages provide a function which displays a prompt, blocks
1103
+ until the user presses return, and returns the text they typed before pressing
1104
+ return. In Python 3, this is the ``input() `` function; in R it is called
1105
+ ``readline() ``. If the :ref: `execute_request <execute >` message has
1106
+ ``allow_stdin==True ``, kernels may implement these functions so that they send
1107
+ an ``input_request `` message and wait for a corresponding ``input_reply ``. The
1108
+ frontend is responsible for displaying the prompt and getting the user's input.
1109
+
1110
+ If ``allow_stdin `` is False, the kernel must not send ``stdin_request ``. The
1111
+ kernel may decide what to do instead, but it's most likely that calls to the
1112
+ 'prompt for input' function should fail immediately in this case.
1101
1113
1102
1114
Message type: ``input_request ``::
1103
1115
@@ -1114,7 +1126,10 @@ Message type: ``input_reply``::
1114
1126
content = { 'value' : str }
1115
1127
1116
1128
1117
- When ``password `` is True, the frontend should not echo the input as it is entered.
1129
+ When ``password `` is True, the frontend should not show the input as it is entered.
1130
+ Different frontends may obscure it in different ways; e.g. showing each
1131
+ character entered as the same neutral symbol, or not showing anything at all as
1132
+ the user types.
1118
1133
1119
1134
.. versionchanged :: 5.0
1120
1135
@@ -1130,14 +1145,10 @@ When ``password`` is True, the frontend should not echo the input as it is enter
1130
1145
1131
1146
.. note ::
1132
1147
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.
1148
+ This pattern of requesting user input is quite different from how stdin works
1149
+ at a lower level. The Jupyter protocol does not support everything code
1150
+ running in a terminal can do with stdin, but we believe that this enables the
1151
+ most common use cases.
1141
1152
1142
1153
.. _kernel_heartbeat :
1143
1154
0 commit comments