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: cross-platform server shutdown (#702)
Akshay Agrawal813ef37bef04
diff --git a/marimo/_server/api/endpoints/execution.py b/marimo/_server/api/endpoints/execution.pyindex eb157d2f7c..075c041007 100644--- a/marimo/_server/api/endpoints/execution.py+++ b/marimo/_server/api/endpoints/execution.py@@ -151,6 +151,5 @@ async def shutdown(LOGGER.debug("Received shutdown request")app_state = AppState(request)app_state.session_manager.shutdown()-- await close_uvicorn(app_state.server)+ close_uvicorn(app_state.server)return SuccessResponse()diff --git a/marimo/_server/api/lifespans.py b/marimo/_server/api/lifespans.pyindex 29ad62bd84..b8fbf9c9ab 100644--- a/marimo/_server/api/lifespans.py+++ b/marimo/_server/api/lifespans.py@@ -45,7 +45,7 @@ async def _shutdown(app: Starlette, with_error: bool = False) -> None:LOGGER.fatal("marimo shut down with an error.")mgr.shutdown()if with_error:- await close_uvicorn(app.state.server)+ close_uvicorn(app.state.server)# Compound lifespans@@ -145,7 +145,7 @@ async def signal_handler(app: Starlette) -> AsyncIterator[None]:# Interrupt handlerdef shutdown() -> None:manager.shutdown()- asyncio.create_task(close_uvicorn(app.state.server))+ close_uvicorn(app.state.server)InterruptHandler(quiet=manager.quiet,diff --git a/marimo/_server/uvicorn_utils.py b/marimo/_server/uvicorn_utils.pyindex ed499ff305..ca50c3eb6c 100644--- a/marimo/_server/uvicorn_utils.py+++ b/marimo/_server/uvicorn_utils.py@@ -8,10 +8,7 @@ from marimo import _loggersLOGGER = _loggers.marimo_logger()-async def close_uvicorn(server: uvicorn.Server) -> None:+def close_uvicorn(server: uvicorn.Server) -> None:LOGGER.debug("Shutting down uvicorn")- for s in server.servers:- s.close()- await s.wait_closed()server.handle_exit(signal.SIGINT, None)LOGGER.debug("Uvicorn shut down")