Skip to content

Commit 8b85f61

Browse files
mchehabJonathan Corbet
authored andcommitted
docs: jobserver: do some documentation improvements
Make Sphinx handle better jobserver class documentation Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <18a9c1406bdead680e3ee5768c97ae8b2138e8ea.1768838938.git.mchehab+huawei@kernel.org>
1 parent 7a66b29 commit 8b85f61

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

tools/lib/python/jobserver.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,23 @@
1111
A "normal" jobserver task, like the one initiated by a make subrocess would do:
1212
1313
- open read/write file descriptors to communicate with the job server;
14-
- ask for one slot by calling:
14+
- ask for one slot by calling::
15+
1516
claim = os.read(reader, 1)
16-
- when the job finshes, call:
17+
18+
- when the job finshes, call::
19+
1720
os.write(writer, b"+") # os.write(writer, claim)
1821
1922
Here, the goal is different: This script aims to get the remaining number
2023
of slots available, using all of them to run a command which handle tasks in
2124
parallel. To to that, it has a loop that ends only after there are no
2225
slots left. It then increments the number by one, in order to allow a
23-
call equivalent to make -j$((claim+1)), e.g. having a parent make creating
26+
call equivalent to ``make -j$((claim+1))``, e.g. having a parent make creating
2427
$claim child to do the actual work.
2528
2629
The end goal here is to keep the total number of build tasks under the
27-
limit established by the initial make -j$n_proc call.
30+
limit established by the initial ``make -j$n_proc`` call.
2831
2932
See:
3033
https://www.gnu.org/software/make/manual/html_node/POSIX-Jobserver.html#POSIX-Jobserver
@@ -40,21 +43,22 @@ class JobserverExec:
4043
Claim all slots from make using POSIX Jobserver.
4144
4245
The main methods here are:
46+
4347
- open(): reserves all slots;
4448
- close(): method returns all used slots back to make;
45-
- run(): executes a command setting PARALLELISM=<available slots jobs + 1>
49+
- run(): executes a command setting PARALLELISM=<available slots jobs + 1>.
4650
"""
4751

4852
def __init__(self):
49-
"""Initialize internal vars"""
53+
"""Initialize internal vars."""
5054
self.claim = 0
5155
self.jobs = b""
5256
self.reader = None
5357
self.writer = None
5458
self.is_open = False
5559

5660
def open(self):
57-
"""Reserve all available slots to be claimed later on"""
61+
"""Reserve all available slots to be claimed later on."""
5862

5963
if self.is_open:
6064
return
@@ -118,7 +122,7 @@ def open(self):
118122
self.is_open = True
119123

120124
def close(self):
121-
"""Return all reserved slots to Jobserver"""
125+
"""Return all reserved slots to Jobserver."""
122126

123127
if not self.is_open:
124128
return

0 commit comments

Comments
 (0)