jobserver: Handle read errors before claiming a slot
Subsystems (2)
PATCH 1/1 jobserver: Handle read errors before claiming a slot
If os.read() fails with an error other than EWOULDBLOCK before any jobserver tokens are collected, the error handler falls through to self.jobs += slot. Since slot was never assigned, this raises UnboundLocalError instead of gracefully disabling jobserver parallelism.
Keep returning collected tokens conditional, but reset the claim, warn, and return for every unexpected read error. Add a regression test that injects EIO on the first read.
OpenAI Codex assisted with finding the issue and developing the fix and regression test.
Fixes b2664a90c171 ("jobserver: Split up the big try: block")
Signed-off-by Shanmugapriyan S <[email protected]>
--- tools/lib/python/jobserver.py | 6 ++--- tools/unittests/test_jobserver.py | 43 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 tools/unittests/test_jobserver.py
tools/lib/python/jobserver.py +3 -3
@@ -154,9 +154,9 @@ class JobserverExec: # if self.jobs: os.write(self.writer, self.jobs) - self.claim = None - warn('error reading from jobserver pipe', repr(e)) - return + self.claim = None + warn('error reading from jobserver pipe', repr(e)) + return self.jobs += slot # # Add a bump for our caller's reserveration, since we're just going
tools/unittests/test_jobserver.py new file +43 -0
43 lines not on this page · raw message
base-commit: d48723711bae9b8cdc56719c448ba42fef28cbee
Signature · 1 line
2.43.0