Home / Function/ _create_preexec_fn() — langchain Function Reference

_create_preexec_fn() — langchain Function Reference

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

Function python LangChainCore Runnables calls 1 called by 1

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/_execution.py lines 148–163

    def _create_preexec_fn(self) -> typing.Callable[[], None] | None:
        if not self._limits_requested or self._can_use_prlimit():
            return None

        def _configure() -> None:  # pragma: no cover - depends on OS
            if self.cpu_time_seconds is not None:
                limit = (self.cpu_time_seconds, self.cpu_time_seconds)
                resource.setrlimit(resource.RLIMIT_CPU, limit)
            if self.memory_bytes is not None:
                limit = (self.memory_bytes, self.memory_bytes)
                if hasattr(resource, "RLIMIT_AS"):
                    resource.setrlimit(resource.RLIMIT_AS, limit)
                elif hasattr(resource, "RLIMIT_DATA"):
                    resource.setrlimit(resource.RLIMIT_DATA, limit)

        return _configure

Domain

Subdomains

Called By

Frequently Asked Questions

What does _create_preexec_fn() do?
_create_preexec_fn() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/_execution.py.
Where is _create_preexec_fn() defined?
_create_preexec_fn() is defined in libs/langchain_v1/langchain/agents/middleware/_execution.py at line 148.
What does _create_preexec_fn() call?
_create_preexec_fn() calls 1 function(s): _can_use_prlimit.
What calls _create_preexec_fn()?
_create_preexec_fn() 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