plan_resources#

Run commands and agent-written programs inside an operating-system boundary. See the guide.

zett_agent.sandbox.resources.plan_resources(limits, *, strategy=MemoryStrategy.AUTO, name='zett-sandbox', create_cgroup=True, cgroup_directory=None, cgroup_path=None)[source]#

Decide how to enforce limits on this machine.

The order of preference is the strongest mechanism each limit has: a cgroup for memory, processor share and process count; a POSIX limit for processor time, file size, open files and the address space; and the parent’s sampling as the last resort for memory. Anything that cannot be enforced is named in the warnings, in the words of the thing that is missing.

Parameters:
  • limits (ResourceLimits) – What the caller asked for.

  • strategy (MemoryStrategy | str) – How to treat memory_bytes; see MemoryStrategy.

  • name (str) – Prefix of the cgroup to create.

  • create_cgroup (bool) – False asks only what would be done, for capabilities(), and creates nothing.

  • cgroup_directory (Path | None) – Override the cgroup v2 mount, for tests.

  • cgroup_path (Path | None) – Override /proc/self/cgroup, for tests.

Return type:

ResourcePlan