MCPcopy Index your code
hub / github.com/google/adk-python / _set_resource_limits

Function _set_resource_limits

src/google/adk/tools/bash_tool.py:78–98  ·  view source on GitHub ↗

Sets resource limits for the subprocess based on the provided policy.

(policy: BashToolPolicy)

Source from the content-addressed store, hash-verified

76
77
78def _set_resource_limits(policy: BashToolPolicy) -> None:
79 """Sets resource limits for the subprocess based on the provided policy."""
80 try:
81 resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
82 if policy.max_memory_bytes:
83 resource.setrlimit(
84 resource.RLIMIT_AS,
85 (policy.max_memory_bytes, policy.max_memory_bytes),
86 )
87 if policy.max_file_size_bytes:
88 resource.setrlimit(
89 resource.RLIMIT_FSIZE,
90 (policy.max_file_size_bytes, policy.max_file_size_bytes),
91 )
92 if policy.max_child_processes:
93 resource.setrlimit(
94 resource.RLIMIT_NPROC,
95 (policy.max_child_processes, policy.max_child_processes),
96 )
97 except (ValueError, OSError) as e:
98 logger.warning("Failed to set resource limits: %s", e)
99
100
101class ExecuteBashTool(BaseTool):

Callers 1

run_asyncMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected