plan_rlimits#
Run commands and agent-written programs inside an operating-system boundary. See the guide.
- zett_agent.sandbox.resources.plan_rlimits(limits, *, supported=None, user_tasks=None)[源代码]#
Turn the POSIX limits into
setrlimitcalls, and say what cannot be applied.A requested value above the machine's hard limit is lowered to it with a warning rather than failing: the hard limit is already a ceiling the process cannot pass, so the request cannot be honoured as written and the caller is told.
core_dumpsis off unless asked for, so it appears in almost every plan.cpu_percenthas no POSIX limit and is left to the cgroup.Two limits are not applied as written:
cpu_secondssets the hard limit one second above the soft one. With the two equal, Linux skipsSIGXCPUand kills the process withSIGKILL, so the run could not say it hit the limit; with a second between them the process is ended bySIGXCPUat the limit, and the hard limit still stops one that handles it.processesis the number of processes the command may add. The kernel comparesRLIMIT_NPROCwith every process the user owns, so the limit is that count plus the request. Taking the number literally would stop every command on a machine where the user already runs more than that. Other processes of the same user that start during the run use up the same allowance, which is why a cgroup, where one is available, is preferred.
- 参数:
user_tasks (int | None) -- The user's current process count; counted here when None.
limits (ResourceLimits)
supported (frozenset[str] | None)
- 返回类型:
tuple[tuple[RlimitStep, ...], tuple[str, ...]]