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
Add `marimo._ipc` for multi-environment kernels (#6303)
Trevor Manz51cf484e5de2
diff --git a/marimo/_ipc/__init__.py b/marimo/_ipc/__init__.pynew file mode 100644index 0000000000..4e278b9749--- /dev/null+++ b/marimo/_ipc/__init__.py@@ -0,0 +1,12 @@+# Copyright 2025 Marimo. All rights reserved.+"""Experimental IPC implementation (using ZeroMQ)."""++from __future__ import annotations++from marimo._ipc.queue_manager import QueueManager+from marimo._ipc.types import KernelArgs++__all__ = [+ "KernelArgs",+ "QueueManager",+]diff --git a/marimo/_ipc/connection.py b/marimo/_ipc/connection.pynew file mode 100644index 0000000000..8a65d31cd5--- /dev/null+++ b/marimo/_ipc/connection.py@@ -0,0 +1,190 @@+# Copyright 2025 Marimo. All rights reserved.+"""ZeroMQ connection management for inter-process communication."""++from __future__ import annotations++import dataclasses+import queue+import sys+import typing++import zmq++from marimo import _loggers+from marimo._ipc.queue_proxy import PushQueue, start_receiver_thread+from marimo._ipc.types import ConnectionInfo+from marimo._server.types import QueueType++if typing.TYPE_CHECKING:+ from marimo._messaging.types import KernelMessage+ from marimo._runtime.requests import (+ CodeCompletionRequest,+ ControlRequest,+ SetUIElementValueRequest,+ )++LOGGER = _loggers.marimo_logger()+ADDR = "tcp://127.0.0.1"++T = typing.TypeVar("T")+++class Channel(typing.Generic[T]):+ """A typed communication channel wrapping a ZeroMQ socket and queue.++ Channels can be either:+ - Push: Send-only, uses PushQueue to immediately send via socket+ - Pull: Receive-only, uses Queue to buffer received messages+ """++ kind: typing.Literal["push", "pull"]+ socket: zmq.Socket[bytes]+ queue: QueueType[T]++ @classmethod+ def Push(+ cls, context: zmq.Context[zmq.Socket[bytes]], *, maxsize: int = 0+ ) -> Channel[T]:+ """Create a push (send-only) channel.++ Note: maxsize is ignored for push channels as ZeroMQ handles buffering.+ """+ socket = context.socket(zmq.PUSH)+ return cls(+ kind="push",+ socket=socket,+ queue=PushQueue(socket, maxsize=maxsize),+ )++ @classmethod+ def Pull(+ cls, context: zmq.Context[zmq.Socket[bytes]], *, maxsize: int = 0+ ) -> Channel[T]:+ """Create a pull (receive-only) channel.++ Args:+ context: ZeroMQ context for creating sockets+ maxsize: Maximum queue size (0 = unlimited)+ """+ socket = context.socket(zmq.PULL)+ return cls(+ kind="pull",+ socket=socket,+ queue=queue.Queue(maxsize=maxsize),+ )+++class Connection:+ """Manages all ZeroMQ sockets for marimo IPC communication."""++ context: zmq.Context[zmq.Socket[bytes]]++ control: Channel[ControlRequest]+ ui_element: Channel[SetUIElementValueRequest]+ completion: Channel[CodeCompletionRequest]+ win32_interrupt: Channel[bool] | None++ input: Channel[str]+ stream: Channel[KernelMessage]++ def __post_init__(self) -> None:+ """Start receiver threads for all pull channels."""+ receivers: dict[zmq.Socket[bytes], QueueType[typing.Any]] = {}+ if self.control.kind == "pull":+ receivers[self.control.socket] = self.control.queue+ if self.ui_element.kind == "pull":+ receivers[self.ui_element.socket] = self.ui_element.queue+ if self.completion.kind == "pull":+ receivers[self.completion.socket] = self.completion.queue+ if self.win32_interrupt and self.win32_interrupt.kind == "pull":+ receivers[self.win32_interrupt.socket] = self.win32_interrupt.queue+ if self.input.kind == "pull":+ receivers[self.input.socket] = self.input.queue+ if self.stream.kind == "pull":+ receivers[self.stream.socket] = self.stream.queue++ self._stop_event, self._receiver_thread = start_receiver_thread(+ receivers+ )++ @classmethod+ def create(cls) -> tuple[Connection, ConnectionInfo]:+ """Create host-side connection with all sockets bound to random ports.++ Returns:+ Tuple of (Connection instance, ConnectionInfo with port numbers)+ """+ context = zmq.Context()+ conn = cls(+ context=context,+ control=Channel.Push(context),+ ui_element=Channel.Push(context),+ completion=Channel.Push(context),+ win32_interrupt=(+ Channel.Push(context) if sys.platform == "win32" else None+ ),+ input=Channel.Pull(context, maxsize=1),+ stream=Channel.Pull(context),+ )+ info = ConnectionInfo(+ control=conn.control.socket.bind_to_random_port(ADDR),+ ui_element=conn.ui_element.socket.bind_to_random_port(ADDR),+ completion=conn.completion.socket.bind_to_random_port(ADDR),+ input=conn.input.socket.bind_to_random_port(ADDR),+ stream=conn.stream.socket.bind_to_random_port(ADDR),+ win32_interrupt=conn.win32_interrupt.socket.bind_to_random_port(+ ADDR+ )+ if conn.win32_interrupt+ else None,+ )+ return conn, info++ @classmethod+ def connect(cls, connection_info: ConnectionInfo) -> Connection:+ """Connect to host with all sockets and start receivers.++ Args:+ connection_info: Port information from host++ Returns:+ Connected Connection instance+ """+ context = zmq.Context()++ conn = cls(+ context=context,+ control=Channel.Pull(context),+ ui_element=Channel.Pull(context),+ completion=Channel.Pull(context),+ win32_interrupt=Channel.Pull(context)+ if connection_info.win32_interrupt+ else None,+ input=Channel.Push(context, maxsize=1),+ stream=Channel.Push(context),+ )++ # Attach to existing ports+ conn.control.socket.connect(f"{ADDR}:{connection_info.control}")+ conn.ui_element.socket.connect(f"{ADDR}:{connection_info.ui_element}")+ conn.completion.socket.connect(f"{ADDR}:{connection_info.completion}")+ if conn.win32_interrupt:+ conn.win32_interrupt.socket.connect(+ f"{ADDR}:{connection_info.win32_interrupt}"+ )+ conn.input.socket.connect(f"{ADDR}:{connection_info.input}")+ conn.stream.socket.connect(f"{ADDR}:{connection_info.stream}")++ return conn++ def close(self) -> None:+ """Close all sockets and cleanup resources."""+ # Stop receiver thread+ self._stop_event.set()+ if self._receiver_thread.is_alive():+ self._receiver_thread.join(timeout=1)++ # Close all associated sockets (and finally terminate)+ self.context.destroy()diff --git a/marimo/_ipc/launch_kernel.py b/marimo/_ipc/launch_kernel.pynew file mode 100644index 0000000000..ddd00a9942--- /dev/null+++ b/marimo/_ipc/launch_kernel.py@@ -0,0 +1,61 @@+# Copyright 2025 Marimo. All rights reserved.+"""Standalone kernel server entry point for IPC (using ZeroMQ)."""++from __future__ import annotations++import sys++from marimo._ipc.queue_manager import QueueManager+from marimo._ipc.types import KernelArgs+from marimo._runtime import runtime+++def main() -> None:+ """Launch a marimo kernel using ZeroMQ for IPC.++ This function is the entry point for the kernel subprocess. It reads+ connection information from stdin and sets up ZeroMQ queues that proxy+ to marimo's internal kernel.++ Typically, this entry point is invoked via the command line with:++ python -m marimo._ipc.launch_kernel++ IMPORTANT: The module path "marimo._ipc.launch_kernel" is a public API+ used by external consumers (e.g., marimo-lsp). Changing this path is a+ BREAKING CHANGE and should be done with care and proper deprecation.+ """+ args = KernelArgs.decode_json(sys.stdin.buffer.read())+ queue_manager = QueueManager.connect(args.connection_info)++ sys.stdout.write("KERNEL_READY\n")+ sys.stdout.flush()++ runtime.launch_kernel(+ set_ui_element_queue=queue_manager.set_ui_element_queue,+ interrupt_queue=queue_manager.win32_interrupt_queue,+ completion_queue=queue_manager.completion_queue,+ control_queue=queue_manager.control_queue,+ input_queue=queue_manager.input_queue,+ app_metadata=args.app_metadata,+ log_level=args.log_level,+ user_config=args.user_config,+ configs=args.configs,+ profile_path=args.profile_path,+ # Virtual files require a web server to serve file URLs. Since we're+ # not running one, content must be embedded as data URLs instead.+ virtual_files_supported=False,+ # NB: Unique parameter combination required for ZeroMQ. The `stream_queue`+ # and `socket_addr` are mutually exclusive. Normally RUN mode doesn't+ # redirect console, while EDIT mode does. Our ZeroMQ proxy needs both+ # `stream_queue` AND console redirection, but also other behavior of+ # EDIT, so we require this combination.+ stream_queue=queue_manager.stream_queue,+ socket_addr=None,+ is_edit_mode=True,+ redirect_console_to_browser=True,+ )+++if __name__ == "__main__":+ main()diff --git a/marimo/_ipc/queue_manager.py b/marimo/_ipc/queue_manager.pynew file mode 100644index 0000000000..38fdecbdb2--- /dev/null+++ b/marimo/_ipc/queue_manager.py@@ -0,0 +1,103 @@+# Copyright 2025 Marimo. All rights reserved.+"""Queue manager for generic inter-process communication."""++from __future__ import annotations++import dataclasses+import typing++from marimo._ipc.connection import Connection+from marimo._ipc.types import ConnectionInfo++if typing.TYPE_CHECKING:+ from marimo._messaging.types import KernelMessage+ from marimo._runtime.requests import (+ CodeCompletionRequest,+ ControlRequest,+ SetUIElementValueRequest,+ )+ from marimo._server.types import QueueType+++class QueueManager:+ """High-level interface for inter-process communication queues.++ Usage:+ # Host side - create and bind+ host_manager, connection_info = QueueManager.create()++ # Kernel side - connect+ kernel_manager = QueueManager.connect(connection_info)++ # Send/receive messages through queues+ host_manager.control_queue.put(request)+ response = kernel_manager.stream_queue.get()+ """++ conn: Connection++ @property+ def control_queue(self) -> QueueType[ControlRequest]:+ """Queue for control requests (execute, interrupt, etc.)."""+ return self.conn.control.queue++ @property+ def set_ui_element_queue(self) -> QueueType[SetUIElementValueRequest]:+ """Queue for UI element value updates."""+ return self.conn.ui_element.queue++ @property+ def completion_queue(self) -> QueueType[CodeCompletionRequest]:+ """Queue for code completion requests."""+ return self.conn.completion.queue++ @property+ def win32_interrupt_queue(self) -> typing.Union[QueueType[bool], None]:+ """Queue for Windows interrupt signals (None on non-Windows)."""+ return (+ self.conn.win32_interrupt.queue+ if self.conn.win32_interrupt+ else None+ )++ @property+ def input_queue(self) -> QueueType[str]:+ """Queue for user input responses."""+ return self.conn.input.queue++ @property+ def stream_queue(self) -> QueueType[KernelMessage]:+ """Queue for kernel output messages."""+ return self.conn.stream.queue++ def close_queues(self) -> None:+ """Close all queues and cleanup resources."""+ self.conn.close()++ @classmethod+ def create(+ cls,+ ) -> tuple[QueueManager, ConnectionInfo]:+ """Create host-side queue manager with all sockets bound.++ Returns:+ Tuple of (QueueManager instance, ConnectionInfo for kernel)+ """+ conn, info = Connection.create()+ return cls(conn=conn), info++ @classmethod+ def connect(+ cls,+ connection_info: ConnectionInfo,+ ) -> QueueManager:+ """Connect to host and create kernel-side queue manager.++ Args:+ connection_info: Connection details from host++ Returns:+ Connected QueueManager instance+ """+ return cls(conn=Connection.connect(connection_info))diff --git a/marimo/_ipc/queue_proxy.py b/marimo/_ipc/queue_proxy.pynew file mode 100644index 0000000000..48537c3c94--- /dev/null+++ b/marimo/_ipc/queue_proxy.py@@ -0,0 +1,106 @@+# Copyright 2025 Marimo. All rights reserved.+"""Queue proxy for ZeroMQ sockets."""++from __future__ import annotations++import pickle+import threading+import typing++import zmq++from marimo import _loggers+from marimo._server.types import QueueType++LOGGER = _loggers.marimo_logger()++T = typing.TypeVar("T")+++class PushQueue(QueueType[T]):+ """Queue for pushing messages through ZeroMQ socket (sender side only).++ This is a simple wrapper that sends messages over a ZeroMQ PUSH socket.+ """++ def __init__(+ self,+ socket: zmq.Socket[bytes],+ *,+ maxsize: int = 0,+ ) -> None:+ self.socket = socket+ self.maxsize = maxsize++ def put(+ self,+ obj: T,+ block: bool = True, # noqa: ARG002+ timeout: float | None = None, # noqa: ARG002+ ) -> None:+ """Put an item into the queue."""+ self.socket.send(pickle.dumps(obj))++ def put_nowait(self, obj: T) -> None:+ """Put an item into the queue without blocking."""+ self.put(obj, block=False)++ def get(self, block: bool = True, timeout: float | None = None) -> T: # noqa: FBT001, FBT002+ """Get an item from the queue (stub - not implemented for PushQueue)."""+ msg = "PushQueue does not support get operations"+ raise NotImplementedError(msg)++ def get_nowait(self) -> T:+ """Get an item from the queue without blocking (stub - not implemented)."""+ msg = "PushQueue does not support get operations"+ raise NotImplementedError(msg)++ def empty(self) -> bool:+ """Return True if the queue is empty (stub - not implemented for PushQueue)."""+ msg = "PushQueue does not support empty() operation"+ raise NotImplementedError(msg)+++def start_receiver_thread(+ receivers: dict[zmq.Socket[bytes], QueueType[typing.Any]],+) -> tuple[threading.Event, threading.Thread]:+ """Start receiver thread."""++ def receive_loop(+ receivers: dict[zmq.Socket[bytes], QueueType[typing.Any]],+ stop_event: threading.Event,+ ) -> None:+ """Receive messages from sockets and put them in queues using polling."""+ poller = zmq.Poller()+ for socket in receivers:+ poller.register(socket, zmq.POLLIN)++ while not stop_event.is_set():+ try:+ # Poll with 100ms timeout+ socks = dict(poller.poll(100))+ for socket, event in socks.items():+ if event & zmq.POLLIN:+ msg = socket.recv(flags=zmq.NOBLOCK)+ obj = pickle.loads(msg)+ receivers[socket].put(obj)+ except zmq.Again:+ continue+ except zmq.ZMQError as e:+ LOGGER.debug(f"ZeroMQ socket error in receiver thread: {e}")+ break+ except Exception as e:+ LOGGER.warning(+ f"Unexpected error in ZeroMQ receiver thread: {e}",+ exc_info=True,+ )+ continue++ stop_event = threading.Event()+ thread = threading.Thread(+ target=receive_loop,+ args=(receivers, stop_event),+ daemon=True,+ )+ thread.start()+ return stop_event, threaddiff --git a/marimo/_ipc/types.py b/marimo/_ipc/types.pynew file mode 100644index 0000000000..4ea9bce615--- /dev/null+++ b/marimo/_ipc/types.py@@ -0,0 +1,43 @@+# Copyright 2025 Marimo. All rights reserved.+from __future__ import annotations++import typing++import msgspec+import msgspec.json++from marimo._ast.cell import CellConfig+from marimo._config.config import MarimoConfig+from marimo._messaging.msgspec_encoder import encode_json_bytes+from marimo._runtime.requests import AppMetadata+from marimo._types.ids import CellId_t+++class ConnectionInfo(msgspec.Struct):+ """ZeroMQ socket connection info."""++ control: int+ ui_element: int+ completion: int+ win32_interrupt: typing.Union[int, None]++ input: int+ stream: int+++class KernelArgs(msgspec.Struct):+ """Args to send to the kernel."""++ configs: dict[CellId_t, CellConfig]+ app_metadata: AppMetadata+ user_config: MarimoConfig+ log_level: int+ profile_path: typing.Union[str, None]+ connection_info: ConnectionInfo++ def encode_json(self) -> bytes:+ return encode_json_bytes(self)++ @classmethod+ def decode_json(cls, buf: bytes) -> KernelArgs:+ return msgspec.json.decode(buf, type=cls)diff --git a/pyproject.toml b/pyproject.tomlindex be6489bdb3..9e7be9d9ed 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -196,6 +196,8 @@ dependencies = ["types-Markdown~=3.6.0.20240316","types-PyYAML~=6.0.12.20240808","mcp>=1.0.0; python_version >= '3.10'",+ # zeromq+ "pyzmq>=27.1.0",][tool.hatch.envs.typecheck.scripts]@@ -207,6 +209,7 @@ tutorials = "mypy marimo/_tutorials"[tool.hatch.envs.test]extra-dependencies = [+ "dirty-equals~=0.9.0","hypothesis~=6.102.1",# For server testing"httpx~=0.27.0",@@ -237,6 +240,7 @@ test-narwhals = """[tool.hatch.envs.test-optional]template = "test"extra-dependencies = [+ "dirty-equals~=0.9.0","hypothesis~=6.102.1","httpx~=0.27.0","matplotlib~=3.9.2",@@ -286,6 +290,8 @@ extra-dependencies = ["torch>=2.4.0; python_version == '3.12'","scikit-bio>=0.6.3; python_version == '3.12'","mcp>=1.0.0; python_version >= '3.10'",+ # zeromq+ "pyzmq>=27.1.0",][[tool.hatch.envs.test-optional.matrix]]diff --git a/tests/_ipc/test_kernel_communication.py b/tests/_ipc/test_kernel_communication.pynew file mode 100644index 0000000000..5865df3b2e--- /dev/null+++ b/tests/_ipc/test_kernel_communication.py@@ -0,0 +1,266 @@+"""Tests for ZeroMQ-based kernel communication."""++from __future__ import annotations++import json+import queue+import subprocess+import sys+import time++import pytest+from dirty_equals import IsFloat, IsList, IsUUID++from marimo._ast.app_config import _AppConfig+from marimo._ast.cell import CellConfig+from marimo._config.config import DEFAULT_CONFIG+from marimo._config.settings import GLOBAL_SETTINGS+from marimo._dependencies.dependencies import DependencyManager+from marimo._runtime.requests import (+ AppMetadata,+ ExecuteMultipleRequest,+)+from marimo._types.ids import CellId_t++HAS_DEPS = DependencyManager.has("zmq")++[email protected](not HAS_DEPS, reason="optional dependencies not installed")+def test_kernel_launch_and_execute_cells():+ """Test launching a kernel and executing cells with stdout/stderr."""+ from marimo._ipc import KernelArgs, QueueManager++ execute_request = ExecuteMultipleRequest(+ cell_ids=[CellId_t("cell1")],+ codes=[+ """\+import sys+print("stdout")+print("stderr", file=sys.stderr)+x = 42"""+ ],+ )++ queue_manager, connection_info = QueueManager.create()+ kernel_args = KernelArgs(+ connection_info=connection_info,+ profile_path=None,+ configs={cid: CellConfig() for cid in execute_request.cell_ids},+ user_config=DEFAULT_CONFIG,+ log_level=GLOBAL_SETTINGS.LOG_LEVEL,+ app_metadata=AppMetadata(+ query_params={}, cli_args={}, app_config=_AppConfig()+ ),+ )++ # IMPORTANT: The module path "marimo._ipc.launch_kernel" is a public API+ # used by external consumers (e.g., marimo-lsp). Changing this path is a+ # BREAKING CHANGE and should be done with care and proper deprecation.+ process = subprocess.Popen(+ [sys.executable, "-m", "marimo._ipc.launch_kernel"],+ stdin=subprocess.PIPE,+ stdout=subprocess.PIPE,+ stderr=subprocess.PIPE,+ )++ assert process.stdin is not None+ process.stdin.write(kernel_args.encode_json())+ process.stdin.flush()+ process.stdin.close()++ assert process.stdout is not None+ assert process.stderr is not None++ ready_line = process.stdout.readline().decode("utf-8").strip()++ if ready_line != "KERNEL_READY":+ exit_code = process.poll()+ stderr_content = process.stderr.read().decode("utf-8")+ if exit_code is not None and exit_code != 0:+ raise RuntimeError(+ f"Kernel process failed with exit code {exit_code}. Stderr: {stderr_content}"+ )+ else:+ raise RuntimeError(+ f"Expected KERNEL_READY, got: '{ready_line}'. Stderr: {stderr_content}"+ )++ queue_manager.control_queue.put(execute_request)++ messages = []+ seen_completed = False+ extra_collection_start = None++ while True:+ try:+ op, encoded = queue_manager.stream_queue.get(timeout=0.01)+ decoded = json.loads(encoded)+ messages.append(decoded)++ if op == "completed-run":+ seen_completed = True+ extra_collection_start = time.time()++ except queue.Empty:+ if seen_completed and extra_collection_start is not None:+ # FIXME: stdin/stdout are flushed every 10ms, so wait 100ms+ # (after "completed-run") to ensure all related events.+ if time.time() - extra_collection_start >= 0.1:+ break++ # If we haven't seen completed-run yet, continue waiting+ continue++ assert messages == [+ {+ "op": "variables",+ "variables": IsList(+ {+ "declared_by": [+ "cell1",+ ],+ "name": "x",+ "used_by": [],+ },+ {+ "declared_by": [+ "cell1",+ ],+ "name": "sys",+ "used_by": [],+ },+ check_order=False,+ ),+ },+ {+ "cell_id": "cell1",+ "console": None,+ "op": "cell-op",+ "output": None,+ "run_id": IsUUID(),+ "serialization": None,+ "stale_inputs": None,+ "status": "queued",+ "timestamp": IsFloat(),+ },+ {+ "cell_id": "cell1",+ "op": "remove-ui-elements",+ },+ {+ "cell_id": "cell1",+ "console": [],+ "op": "cell-op",+ "output": None,+ "run_id": IsUUID(),+ "serialization": None,+ "stale_inputs": None,+ "status": "running",+ "timestamp": IsFloat(),+ },+ {+ "op": "variable-values",+ "variables": IsList(+ {+ "datatype": "int",+ "name": "x",+ "value": "42",+ },+ {+ "datatype": "module",+ "name": "sys",+ "value": "sys",+ },+ check_order=False,+ ),+ },+ {+ "cell_id": "cell1",+ "console": None,+ "op": "cell-op",+ "output": {+ "channel": "output",+ "data": "",+ "mimetype": "text/plain",+ "timestamp": IsFloat(),+ },+ "run_id": IsUUID(),+ "serialization": None,+ "stale_inputs": None,+ "status": None,+ "timestamp": IsFloat(),+ },+ {+ "cell_id": "cell1",+ "console": None,+ "op": "cell-op",+ "output": None,+ "run_id": None,+ "serialization": None,+ "stale_inputs": None,+ "status": "idle",+ "timestamp": IsFloat(),+ },+ {+ "op": "completed-run",+ },+ {+ "cell_id": "cell1",+ "console": {+ "channel": "stdout",+ "data": "stdout\n",+ "mimetype": "text/plain",+ "timestamp": IsFloat(),+ },+ "op": "cell-op",+ "output": None,+ "run_id": None,+ "serialization": None,+ "stale_inputs": None,+ "status": None,+ "timestamp": IsFloat(),+ },+ {+ "cell_id": "cell1",+ "console": {+ "channel": "stderr",+ "data": "stderr\n",+ "mimetype": "text/plain",+ "timestamp": IsFloat(),+ },+ "op": "cell-op",+ "output": None,+ "run_id": None,+ "serialization": None,+ "stale_inputs": None,+ "status": None,+ "timestamp": IsFloat(),+ },+ ]++ process.terminate()+ process.wait(timeout=2)+ queue_manager.close_queues()++[email protected](not HAS_DEPS, reason="optional dependencies not installed")+def test_queue_manager_connection():+ """Test creating and connecting queue managers."""+ from marimo._ipc import QueueManager++ host_manager, connection_info = QueueManager.create()+ client_manager = QueueManager.connect(connection_info)++ test_request = ExecuteMultipleRequest(+ cell_ids=[CellId_t("cell1")],+ codes=["print('test')"],+ )+ host_manager.control_queue.put(test_request)+ assert client_manager.control_queue.get(timeout=1) == test_request++ kernel_message = ("test-op", b'{"data": "test"}')+ client_manager.stream_queue.put(kernel_message)+ assert host_manager.stream_queue.get(timeout=1) == kernel_message++ host_manager.close_queues()+ client_manager.close_queues()