Home / Function/ stop() — langchain Function Reference

stop() — langchain Function Reference

Architecture documentation for the stop() function in shell_tool.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  8e7ca27f_5ba4_f43b_b7dd_ea19f14cf7c4["stop()"]
  cf4eeaa4_4bcc_69d9_a0f3_664b1eecb4e8["ShellSession"]
  8e7ca27f_5ba4_f43b_b7dd_ea19f14cf7c4 -->|defined in| cf4eeaa4_4bcc_69d9_a0f3_664b1eecb4e8
  3fc9d5a9_a23d_6df7_d3e2_bba6248f9184["_cleanup_resources()"]
  3fc9d5a9_a23d_6df7_d3e2_bba6248f9184 -->|calls| 8e7ca27f_5ba4_f43b_b7dd_ea19f14cf7c4
  376fc508_1bee_23a7_7de6_267e13821247["restart()"]
  376fc508_1bee_23a7_7de6_267e13821247 -->|calls| 8e7ca27f_5ba4_f43b_b7dd_ea19f14cf7c4
  3d2455b7_eaeb_053d_fc17_21aaa32050ca["_create_resources()"]
  3d2455b7_eaeb_053d_fc17_21aaa32050ca -->|calls| 8e7ca27f_5ba4_f43b_b7dd_ea19f14cf7c4
  689aee59_b72f_671f_1bc6_26e76e9d6fba["_kill_process()"]
  8e7ca27f_5ba4_f43b_b7dd_ea19f14cf7c4 -->|calls| 689aee59_b72f_671f_1bc6_26e76e9d6fba
  style 8e7ca27f_5ba4_f43b_b7dd_ea19f14cf7c4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/shell_tool.py lines 191–215

    def stop(self, timeout: float) -> None:
        """Stop the shell subprocess."""
        if not self._process:
            return

        if self._process.poll() is None and not self._terminated:
            try:
                self._stdin.write("exit\n")
                self._stdin.flush()
            except (BrokenPipeError, OSError):
                LOGGER.debug(
                    "Failed to write exit command; terminating shell session.",
                    exc_info=True,
                )

        try:
            if self._process.wait(timeout=timeout) is None:
                self._kill_process()
        except subprocess.TimeoutExpired:
            self._kill_process()
        finally:
            self._terminated = True
            with contextlib.suppress(Exception):
                self._stdin.close()
            self._process = None

Domain

Subdomains

Frequently Asked Questions

What does stop() do?
stop() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/shell_tool.py.
Where is stop() defined?
stop() is defined in libs/langchain_v1/langchain/agents/middleware/shell_tool.py at line 191.
What does stop() call?
stop() calls 1 function(s): _kill_process.
What calls stop()?
stop() is called by 3 function(s): _cleanup_resources, _create_resources, restart.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free