MCPcopy Create free account
hub / github.com/langchain-ai/deepagents / restart

Method restart

libs/code/deepagents_code/server.py:724–745  ·  view source on GitHub ↗

Restart the server process, reusing the existing config directory. Stops the subprocess, then starts a new one. Any env overrides staged via `update_env()` are applied within a `_scoped_env_overrides` context manager so that failures automatically roll back the environment t

(self, *, timeout: float = _HEALTH_TIMEOUT)

Source from the content-addressed store, hash-verified

722 self._persistent_env_overrides.update(overrides)
723
724 async def restart(self, *, timeout: float = _HEALTH_TIMEOUT) -> None: # noqa: ASYNC109
725 """Restart the server process, reusing the existing config directory.
726
727 Stops the subprocess, then starts a new one. Any env overrides staged
728 via `update_env()` are applied within a `_scoped_env_overrides` context
729 manager so that failures automatically roll back the environment to the
730 last known-good state.
731
732 Args:
733 timeout: Max seconds to wait for the server to become healthy.
734 """
735 logger.info("Restarting langgraph dev server")
736 # Offload the synchronous subprocess shutdown (it blocks up to
737 # `_SHUTDOWN_TIMEOUT` + SIGKILL grace waiting on `process.wait`) so the
738 # caller's event loop — the Textual reactor for `/restart` — keeps
739 # processing input instead of freezing the TUI.
740 await asyncio.to_thread(self._stop_process)
741
742 with _scoped_env_overrides(self._env_overrides):
743 await self.start(timeout=timeout)
744
745 self._env_overrides.clear()
746
747 async def __aenter__(self) -> Self:
748 """Async context manager entry.

Calls 3

startMethod · 0.95
_scoped_env_overridesFunction · 0.85
clearMethod · 0.45