Fix: avoid indefinite Sphinx build freeze from unbounded git log call#1636
Fix: avoid indefinite Sphinx build freeze from unbounded git log call#1636suhr25 wants to merge 5 commits intoQubesOS:mainfrom
Conversation
Prevent sphinx-autobuild from hanging indefinitely when git is slow or locked. Fall back to last_edition_datetime=None on timeout. Signed-off-by: suhr25 <suhridmarwah07@gmail.com>
|
Hi @unman , |
parulin
left a comment
There was a problem hiding this comment.
Maybe it would be even better to only include this extension in specific situations, in conf.py:
if os.environ.get('READTHEDOCS') or os.environ.get('QUBES_DOC_FULL_BUILD'):
extensions.append('last_edition')…r handling - Reduce default subprocess timeout from 5s to 1s to avoid accumulating delay across ~190 pages; make it overridable via QUBES_LAST_EDITION_TIMEOUT - Extend exception handling to also catch FileNotFoundError, PermissionError, and OSError so any git invocation failure is silently ignored - Gate the extension in conf.py behind READTHEDOCS or QUBES_DOC_FULL_BUILD env vars to avoid running git on every plain local build
|
Ok, nice. Sorry, but I think that now, we also need to document those variables, maybe in |
|
No need to mention everyone. I made a PR to your personal repo to avoid more work for you. I will try to merge our two versions and update it. |
* add a section about building with environment variables * rewrite part of the last_edition extension section * use `QUBES_DOC_` prefix to be consistent * minor typos in how-to-edit-the-rst-documentation
|
Just a few tips about the documentation style guide:
|
|
Thanks for the improvements and the style guidance. I will align with the no hardwrap rule going forward. |
Add documentation for build environment variables
|
@parulin |
|
There is nothing new to review for me. |
|
Let me know if anything else is needed from my side. |
|
@parulin, |
Summary
This PR fixes a blocking issue in
_ext/last_edition.pywhere agit logsubprocess is executed without a timeout inside thehtml_page_contexthook.Since
html_page_contextruns once per page during Sphinx builds, the following code path is executed repeatedly:Without a timeout, any delay/hang in
git(repo lock, concurrent git operations, slow filesystem, etc.) can block the entire Sphinx build indefinitely. This is especially noticeable withsphinx-autobuild, where one stuck build prevents subsequent rebuilds.Fix
The subprocess call is now bounded with a timeout and handles timeout failures gracefully:
Key improvements
gitis slow/unavailablelast_editionmetadata for affected pagesVerification
sphinx-autobuildlocally and confirmed rebuilds continue under simulatedgitdelays (e.g., temporary repo lock / slow response)git logexecutes quickly