diff --git a/jupyter_server/services/sessions/sessionmanager.py b/jupyter_server/services/sessions/sessionmanager.py index 1b97eed6db..b20f4c98de 100644 --- a/jupyter_server/services/sessions/sessionmanager.py +++ b/jupyter_server/services/sessions/sessionmanager.py @@ -461,6 +461,13 @@ async def update_session(self, session_id, **kwargs): query = "UPDATE session SET %s WHERE session_id=?" % (", ".join(sets)) # noqa self.cursor.execute(query, [*list(kwargs.values()), session_id]) + if hasattr(self.kernel_manager, "update_env"): + self.cursor.execute( + "SELECT path, name, kernel_id FROM session WHERE session_id=?", [session_id] + ) + path, name, kernel_id = self.cursor.fetchone() + self.kernel_manager.update_env(kernel_id=kernel_id, env=self.get_kernel_env(path, name)) + async def kernel_culled(self, kernel_id: str) -> bool: """Checks if the kernel is still considered alive and returns true if its not found.""" return kernel_id not in self.kernel_manager