Skip to content

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.

fix: Copy `ExecutionContext.output` to `marimo.Thread` (#8413)

Gijs Burghoorne4674f4b5f2c
diff --git a/marimo/_runtime/threads.py b/marimo/_runtime/threads.py
index d2ecc9afe2..4d14ec05ae 100644
--- a/marimo/_runtime/threads.py
+++ b/marimo/_runtime/threads.py
@@ -147,10 +147,18 @@ class Thread(threading.Thread):
initialize_context(self._marimo_ctx)
except RuntimeError:
pass
+
+ output = None
+ if (mctx := self._marimo_ctx) is not None and (
+ ectx := mctx.execution_context
+ ) is not None:
+ output = ectx.output
+
if isinstance(self._marimo_ctx, KernelRuntimeContext):
self._marimo_ctx.execution_context = ExecutionContext(
cell_id=self._marimo_ctx.stream.cell_id, # type: ignore
setting_element_value=False,
+ output=output,
)
thread_id = threading.get_ident()
THREADS.add(thread_id)