CgroupV2#

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

class zett_agent.sandbox.resources.CgroupV2(directory, _delegated=None)[source]#

The cgroup v2 hierarchy, and whether it can host a sandbox’s own group.

Parameters:
  • directory (Path)

  • _delegated (bool | None)

classmethod discover(*, mount=None, cgroup_path=None)[source]#

Return the hierarchy this process could create a group in, or None.

None means the machine has no cgroup v2, or this process is not in one. Whether the controllers are delegated is a separate question, asked by delegated(), because answering it creates and removes a directory.

Parameters:
  • mount (Path | None)

  • cgroup_path (Path | None)

Return type:

CgroupV2 | None

delegated()[source]#

Whether a child cgroup can be created here, probed once and remembered.

Return type:

bool

create(name)[source]#

Create one group for one run, or None when this hierarchy cannot hold it.

Parameters:

name (str)

Return type:

CgroupHandle | None