From ccce14f5eefcab514d86d99ef8017ecfc43e6a91 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Fri, 29 Nov 2024 12:46:33 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Release=20needs=20data=20mutatio?= =?UTF-8?q?n=20lock=20at=20end=20of=20process=20(#1359)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sphinx_needs/needs.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sphinx_needs/needs.py b/sphinx_needs/needs.py index e4917bda3..0306eb597 100644 --- a/sphinx_needs/needs.py +++ b/sphinx_needs/needs.py @@ -305,6 +305,7 @@ def setup(app: Sphinx) -> dict[str, Any]: app.connect("build-finished", build_needs_id_json) app.connect("build-finished", build_needumls_pumls) app.connect("build-finished", debug.process_timing) + app.connect("build-finished", release_data_locks, priority=9999) # Be sure Sphinx-Needs config gets erased before any events or external API calls get executed. # So never but this inside an event. @@ -734,3 +735,14 @@ def check_configuration(app: Sphinx, config: Config) -> None: class NeedsConfigException(SphinxError): pass + + +def release_data_locks(app: Sphinx, _exception: Exception) -> None: + """Release the lock on needs data mutations. + + This should ONLY be used at the very end of the sphinx processing. + The only reason is it is included is because esbonio does not properly re-start sphinx builds, + such that this would be re-set. + """ + SphinxNeedsData(app.env).needs_is_post_processed = False + app.env._needs_warnings_executed = False # type: ignore[attr-defined]