Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 Release needs data mutation lock at end of process #1359

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions sphinx_needs/needs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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]