Home / Function/ _apply_post_spawn_limits() — langchain Function Reference

_apply_post_spawn_limits() — langchain Function Reference

Architecture documentation for the _apply_post_spawn_limits() function in _execution.py from the langchain codebase.

Function python LangChainCore Runnables calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  6592225b_0ebb_d535_96fb_1f481b669d2c["_apply_post_spawn_limits()"]
  489b9db3_8221_6964_1dd6_b6ee6fd2e645["HostExecutionPolicy"]
  6592225b_0ebb_d535_96fb_1f481b669d2c -->|defined in| 489b9db3_8221_6964_1dd6_b6ee6fd2e645
  ea98a366_f701_dc2d_901d_9954c6c58e48["spawn()"]
  ea98a366_f701_dc2d_901d_9954c6c58e48 -->|calls| 6592225b_0ebb_d535_96fb_1f481b669d2c
  bad031b8_5bd0_bccc_ddb5_454177e775ee["_can_use_prlimit()"]
  6592225b_0ebb_d535_96fb_1f481b669d2c -->|calls| bad031b8_5bd0_bccc_ddb5_454177e775ee
  style 6592225b_0ebb_d535_96fb_1f481b669d2c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/_execution.py lines 165–183

    def _apply_post_spawn_limits(self, process: subprocess.Popen[str]) -> None:
        if not self._limits_requested or not self._can_use_prlimit():
            return
        if not _HAS_RESOURCE:  # pragma: no cover - defensive
            return
        pid = process.pid
        try:
            prlimit = typing.cast("typing.Any", resource).prlimit
            if self.cpu_time_seconds is not None:
                prlimit(pid, resource.RLIMIT_CPU, (self.cpu_time_seconds, self.cpu_time_seconds))
            if self.memory_bytes is not None:
                limit = (self.memory_bytes, self.memory_bytes)
                if hasattr(resource, "RLIMIT_AS"):
                    prlimit(pid, resource.RLIMIT_AS, limit)
                elif hasattr(resource, "RLIMIT_DATA"):
                    prlimit(pid, resource.RLIMIT_DATA, limit)
        except OSError as exc:  # pragma: no cover - depends on platform support
            msg = "Failed to apply resource limits via prlimit."
            raise RuntimeError(msg) from exc

Domain

Subdomains

Called By

Frequently Asked Questions

What does _apply_post_spawn_limits() do?
_apply_post_spawn_limits() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/_execution.py.
Where is _apply_post_spawn_limits() defined?
_apply_post_spawn_limits() is defined in libs/langchain_v1/langchain/agents/middleware/_execution.py at line 165.
What does _apply_post_spawn_limits() call?
_apply_post_spawn_limits() calls 1 function(s): _can_use_prlimit.
What calls _apply_post_spawn_limits()?
_apply_post_spawn_limits() is called by 1 function(s): spawn.

Analyze Your Own Codebase

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

Try Supermodel Free