schedr.runner.usage¶
What an ended child used (rusage), read by its parent without reaping it.
The shim keeps its ended process a zombie until the agent closes the status socket (so the PID
isn’t reused), which os.wait4 can’t do. The waitid system call can: with WNOWAIT
it fills the rusage its fifth argument points to and leaves the zombie, but Python’s
os.waitid doesn’t pass that argument, so the call goes through ctypes.
It must never break the shim: prepare() loads everything in the fork server, before
any fork; read() is called only after the exit was seen (it returns at once), makes no
allocation that can fail halfway, and gives None for anything unexpected: an unknown CPU
architecture, a failing call, any exception.
- class schedr.runner.usage.Reader(syscall, number)¶
Bases:
objectReads an ended child’s usage; set up by
prepare()before forking.- Parameters:
syscall (Any)
number (int)
- read(pid)¶
The usage of an ended child that is still a zombie, which it stays.
- Parameters:
pid (int) – The child, already seen ended (
os.waitidwithWNOWAIT).- Returns:
The
ProcessUsagefields, orNoneif they can’t be read.- Return type:
dict[str, int] | None