jobserver
jobserver
¶
A GNU make jobserver client: one -j shared with whoever started this run.
make -j12 hands its children a jobserver in MAKEFLAGS: a pipe
pre-loaded with one single-byte token per job slot beyond the ones its
clients already hold. Every client owns one implicit slot; each further
concurrent job reads a token first and writes the same byte back when it
ends. GNU make, ninja and cargo speak this protocol, and so does the
superbuild's matrix TUI, so the matrix runs of several repos can share one
worker cap instead of each taking --jobs for itself.
Both of make's auth forms are understood: fifo:PATH (make 4.4 and later)
and R,W file descriptors (make 4.3, which passes them only to recipes
marked +). A token lost to a killed run only shrinks the pool; the
implicit slot keeps every run able to finish.
Jobserver(read_fd, write_fd, inherited_fds=())
¶
Job slots shared through a GNU make jobserver.
Attributes:
| Name | Type | Description |
|---|---|---|
inherited_fds |
make 4.3's pipe descriptors, which a child that joins
too must inherit ( |
Hold the jobserver's two ends; read_fd is this process's own, non-blocking.
Source code in src/terok_util/matrix/jobserver.py
inherited_fds = inherited_fds
instance-attribute
¶
from_environ(environ=os.environ)
classmethod
¶
Join the jobserver MAKEFLAGS names, or None when there is none to join.
make may repeat the option; the last one counts. The read end is opened afresh and non-blocking, so a wait for a token can be broken off; make's own descriptors keep their blocking mode, as make asks. A jobserver this process cannot reach is reported on stderr, and the run goes on without it.
Source code in src/terok_util/matrix/jobserver.py
slot(*, implicit=True)
¶
Hold one job slot: the implicit one when it is free, else a token from the server.
implicit false takes tokens only. It is for a launcher whose own slot is spoken for, such as a panel that starts other clients and does no work of its own.
A slot that waits for a token also takes the implicit slot when that frees. All of a run's slots may be waiting at once, and without this none of them would come back for the implicit one.
Raises:
| Type | Description |
|---|---|
InterruptedError
|
The jobserver was closed before a slot was free. |