Skip to content

Commit

Permalink
🔧 Release needs data mutation lock at end of process (#1359)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell authored Nov 29, 2024
1 parent c5acec6 commit ccce14f
Showing 1 changed file with 12 additions and 0 deletions.
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]

0 comments on commit ccce14f

Please sign in to comment.