A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Correct input channel direction for IPC sandbox mode (#7973)
Trevor Manz9e9879d22a9e
diff --git a/.gitignore b/.gitignoreindex cad29aefbe..1d09aa93a9 100644--- a/.gitignore+++ b/.gitignore@@ -116,6 +116,7 @@ marimo/_lsp/.vscode.vercel.idea+.claude.marimo.toml.mypy_cache/diff --git a/marimo/_ipc/connection.py b/marimo/_ipc/connection.pyindex 55b3f8c0db..7e5e37244d 100644--- a/marimo/_ipc/connection.py+++ b/marimo/_ipc/connection.py@@ -131,7 +131,7 @@ class Connection:win32_interrupt=(Channel.Push(context) if sys.platform == "win32" else None),- input=Channel.Pull(context, maxsize=1),+ input=Channel.Push(context, maxsize=1),stream=Channel.Pull(context),)info = ConnectionInfo(@@ -170,7 +170,7 @@ class Connection:win32_interrupt=Channel.Pull(context)if connection_info.win32_interruptelse None,- input=Channel.Push(context, maxsize=1),+ input=Channel.Pull(context, maxsize=1),stream=Channel.Push(context),)diff --git a/tests/_session/managers/test_ipc.py b/tests/_session/managers/test_ipc.pyindex 5bbf8c5ca7..946456a9c0 100644--- a/tests/_session/managers/test_ipc.py+++ b/tests/_session/managers/test_ipc.py@@ -1,14 +1,42 @@# Copyright 2026 Marimo. All rights reserved.from __future__ import annotations+import time+import pytest-from marimo._dependencies.dependencies import DependencyManager-HAS_ZMQ = DependencyManager.zmq.has()[email protected]("zmq")+class TestIPCConnection:+ def test_input_channel_direction(self) -> None:+ """Test that input flows from host to kernel (not vice versa).++ Regression test for #7972 where the input channel Push/Pull+ directions were inverted, causing input() to fail in sandbox mode.+ """+ from marimo._ipc.connection import Connection++ host_conn, connection_info = Connection.create()+ kernel_conn = Connection.connect(connection_info)++ # Allow ZeroMQ connections to establish+ time.sleep(0.05)++ try:+ # Host sends input to kernel (what happens when user+ # responds to an input() prompt)+ test_input = "user response"+ host_conn.input.queue.put(test_input)++ # Kernel receives input+ received = kernel_conn.input.queue.get(timeout=1.0)+ assert received == test_input+ finally:+ host_conn.close()+ kernel_conn.close()[email protected](not HAS_ZMQ, reason="pyzmq not installed")[email protected]("zmq")class TestIPCQueueManagerImpl:def test_from_ipc_factory(self) -> None:"""Test that IPCQueueManagerImpl.from_ipc() creates a valid instance."""