Kernel Stops Executing Subsequent Code After input() Call (and thus no output) with Custom WebSocket Client

Hi

I’m developing a custom web IDE client that connects to Jupyter Kernel Gateway via WebSockets. My client correctly sends execute_request, handles input_request, and sends input_reply.

The Problem:

When my client sends code that includes an input() call, the kernel executes the code before input(). After input_reply is sent by my client and received by Kernel Gateway, the kernel appears to stop executing any subsequent code. Consequently, no further iopub messages (like stream, display_data, or execute_result) are sent back to my client.

Example Code:print("Part 1: This output works.")
my_input = input("Enter something: ")
print(f"Part 2: This output is NEVER seen.") # Kernel never executes this line
2 + 2 # Kernel never executes this line either

Key Observations:

  • Initial print() statements before input() work fine.

  • My client successfully receives input_request and sends input_reply (confirmed by Kernel Gateway logs).

  • Kernel Gateway logs confirm the input_reply is received, but show no further activity (no stream, display_data, or execute_result messages) after this point.

  • The exact same code executes completely (including all subsequent output) when run in Jupyter Notebook/Lab connected to the same Kernel Gateway.

This strongly suggests the issue is that the kernel ceases execution after processing input_reply specifically from my custom client.

Relevant Logs: (Provide your concise KG logs here, showing execute_request, initial outputs, input_reply, and then nothing else related to output/execution from the kernel.)

[15:10:26] [KernelGatewayApp] INFO: Kernel interrupted: 20b83b26-63dd-4823-a6d5-a9f268565e54
[I 250730 15:10:26 web:2407] 204 POST /api/kernels/20b83b26-63dd-4823-a6d5-a9f268565e54/interrupt (95.141.32.101) 1.79ms
[15:10:26] [KernelGatewayApp] DEBUG: activity on 20b83b26-63dd-4823-a6d5-a9f268565e54: error
[IPKernelApp] WARNING | Unknown message type: 'input_reply'
[15:10:26] [KernelGatewayApp] DEBUG: activity on 20b83b26-63dd-4823-a6d5-a9f268565e54: status (idle)
[15:10:26] [KernelGatewayApp] DEBUG: activity on 20b83b26-63dd-4823-a6d5-a9f268565e54: status (idle)
[15:10:26] [KernelGatewayApp] DEBUG: activity on 20b83b26-63dd-4823-a6d5-a9f268565e54: status (idle)
[15:10:40] [KernelGatewayApp] WARNING: No channel specified, assuming shell: {'header': {'msg_id': '74592e17-edc8-4e34-95ae-1461812c4531', 'session': '20b83b26-63dd-4823-a6d5-a9f268565e54', 'date': '2025-07-30T15:10:39.880Z', 'msg_type': 'execute_request', 'version': '5.3'}, 'parent_header': {}, 'metadata': {}, 'content': {'code': 'print("Part 1: This output works.")\nmy_input = input("Enter something: ")\nprint(f"Part 2: This output is NEVER seen.") \n2 + 2', 'silent': False, 'store_history': True, 'user_expressions': {}, 'allow_stdin': True, 'stop_on_error': True}, 'buffers': []}
[15:10:40] [KernelGatewayApp] DEBUG: activity on 20b83b26-63dd-4823-a6d5-a9f268565e54: status (busy)
[15:10:40] [KernelGatewayApp] DEBUG: activity on 20b83b26-63dd-4823-a6d5-a9f268565e54: execute_input
[15:10:40] [KernelGatewayApp] DEBUG: activity on 20b83b26-63dd-4823-a6d5-a9f268565e54: stream
[15:10:45] [KernelGatewayApp] WARNING: No channel specified, assuming shell: {'header': {'msg_id': '0a3e314a-9eb9-4dd7-bf4b-1418887f1013', 'session': '20b83b26-63dd-4823-a6d5-a9f268565e54', 'date': '2025-07-30T15:10:44.963Z', 'msg_type': 'input_reply', 'version': '5.3'}, 'parent_header': {'msg_id': '241b5b2e-7a30bccd8f19f9a864a4de24_4603_22'}, 'metadata': {}, 'content': {'value': 'Python', 'status': 'ok'}, 'buffers': []}

Question: Why would the kernel stop executing code after receiving an input_reply from a custom WebSocket client, when the same behavior does not occur with official Jupyter clients? Is there a specific protocol expectation or session management aspect that might be causing the kernel to halt execution? How to solve this problem?

link to my IDE

jupyter_kernel_gateway_config.py

c.KernelGatewayApp.allow_origin = ‘*’

c.KernelGatewayApp.allow_headers = ‘Content-Type,Authorization’

c.KernelGatewayApp.allow_credentials = ‘True’

c.KernelGatewayApp.allow_methods = ‘GET,POST,PUT,DELETE,OPTIONS’

c.KernelGatewayApp.allow_origin_pat = r"^(https?://)?(null|shakhbanov\.org|www\.shakhbanov\.org|python\.shakhbanov\.org|www\.python\.shakhbanov\.org)$"

c.KernelGatewayApp.allow_stdin = ‘True’

c.KernelGatewayApp.api = ‘kernel_gateway.jupyter_websocket’

c.KernelGatewayApp.ip = ‘0.0.0.0’

c.KernelGatewayApp.port = 8888

c.KernelGatewayApp.log_level = ‘DEBUG’

c.KernelGatewayApp.kernel_manager_class.kernel_args = [‘–ipython-dir=/tmp/ipython’, ‘–log-level=DEBUG’]