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
fix: [windows] refresh shouldn't kill server (#284)
Akshay Agrawald218d3a5fa6d
diff --git a/marimo/_runtime/runtime.py b/marimo/_runtime/runtime.pyindex 66dba8f91c..3b832055b6 100644--- a/marimo/_runtime/runtime.py+++ b/marimo/_runtime/runtime.py@@ -1012,7 +1012,8 @@ def launch_kernel(# In edit mode, kernel runs in its own process so it's interruptible.from marimo._output.formatters.formatters import register_formatters- # TODO: windows workaround+ # TODO: Windows workaround -- find a way to make the process+ # its group leaderif sys.platform != "win32":# Make this process group leader to prevent it from receiving# signals intended for the parent (server) process,@@ -1083,7 +1084,7 @@ def launch_kernel(except Exception as e:# triggered on Windows when quit with Ctrl+CLOGGER.debug("kernel queue.get() failed %s", e)- return+ breakLOGGER.debug("received request %s", request)if isinstance(request, CreationRequest):kernel.instantiate(request)diff --git a/marimo/_server/sessions.py b/marimo/_server/sessions.pyindex 4dfa505710..54cabf0048 100644--- a/marimo/_server/sessions.py+++ b/marimo/_server/sessions.py@@ -341,20 +341,8 @@ class Session:self.queue.cancel_join_thread() # type: ignoreself.queue.close() # type: ignoreif self.kernel_task.is_alive():- if (- sys.platform == "win32" or sys.platform == "cygwin"- ) and self.kernel_task.pid is not None:- # send a CTRL_BREAK_EVENT to gracefully shutdown- # since SIGTERM isn't handled on windows- os.kill(self.kernel_task.pid, signal.CTRL_BREAK_EVENT)- else:- # TODO(akshayka): Might be able to remove this- # and just rely on the fact that the kernel is a daemon- # process (so will terminate after this process terminates)- #- # Explicitly terminate the process, in case something- # prevents the server process from terminating ...- self.kernel_task.terminate()+ # Explicitly terminate the process+ self.kernel_task.terminate()tornado.ioloop.IOLoop.current().remove_handler(self.read_conn.fileno())@@ -521,6 +509,7 @@ class SessionManager:self.sessions = {}def shutdown(self) -> None:+ LOGGER.debug("Shutting down")self.close_all_sessions()if self.lsp_process is not None:self.lsp_process.terminate()