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
Detach kernel process from server (#181)
Akshay Agrawal6c9726622316
diff --git a/marimo/_runtime/runtime.py b/marimo/_runtime/runtime.pyindex 52e4c01475..4b2e56f303 100644--- a/marimo/_runtime/runtime.py+++ b/marimo/_runtime/runtime.py@@ -7,6 +7,7 @@ import dataclassesimport ioimport itertoolsimport multiprocessing as mp+import osimport queueimport signalimport sys@@ -948,8 +949,19 @@ def launch_kernel()if is_edit_mode:+ # In edit mode, kernel runs in its own process so it's interruptible.from marimo._output.formatters.formatters import register_formatters+ try:+ # Make this process group leader to prevent it from receiving+ # signals intended for the parent (server) process,+ # Ctrl+C in particular.+ os.setsid()+ except Exception:+ # Not supported on Windows.+ # TODO(akshayka): Test/fix on Windows.+ ...+# kernels are processes in edit mode, and each process needs to# install the formatter import hooksregister_formatters()diff --git a/marimo/_server/sessions.py b/marimo/_server/sessions.pyindex 2ecc9ae3d4..d711464886 100644--- a/marimo/_server/sessions.py+++ b/marimo/_server/sessions.py@@ -254,6 +254,7 @@ class Session:self.kernel_task = mp.Process(target=runtime.launch_kernel,args=(self.queue, listener.address, is_edit_mode),+ daemon=True,)else:# We use threads in run mode to minimize memory consumption;