ResourcePlan#

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

class zett_agent.sandbox.resources.ResourcePlan(report, rlimits=(), cgroup=None, watchdog=False, warnings=(), sample_seconds=0.25)[source]#

What will be done about resources for one run.

Parameters:
report#

The mechanism behind each limit, before the run measured anything.

Type:

zett_agent.sandbox.resources.ResourceReport

rlimits#

The setrlimit calls to make in the child.

Type:

tuple[zett_agent.sandbox.resources.RlimitStep, …]

cgroup#

The group the child joins, when one was created.

Type:

zett_agent.sandbox.resources.CgroupHandle | None

watchdog#

Whether the parent samples the process group’s memory.

Type:

bool

warnings#

Limits that were asked for and cannot be enforced here.

Type:

tuple[str, …]

sample_seconds: float#

The watchdog’s sampling interval, from the limits it was planned for.

preexec()[source]#

Return a callable for subprocess’ preexec_fn, or None when nothing to do.

Return type:

Callable[[], None] | None

cleanup()[source]#

Release what planning created.

Return type:

None

measured(*, peak_memory_bytes, limits_hit, warnings=())[source]#

Return the report with what the run observed added to it.

Parameters:
  • peak_memory_bytes (int | None)

  • limits_hit (tuple[str, ...])

  • warnings (tuple[str, ...])

Return type:

ResourceReport