Skip to content

gh-145254: Add thread safety annotation#145255

Open
lysnikolaou wants to merge 3 commits intopython:mainfrom
lysnikolaou:thread-safety-annotation
Open

gh-145254: Add thread safety annotation#145255
lysnikolaou wants to merge 3 commits intopython:mainfrom
lysnikolaou:thread-safety-annotation

Conversation

@lysnikolaou
Copy link
Member

@lysnikolaou lysnikolaou commented Feb 26, 2026

  • Implement annotation for different thread safety levels
  • Annotate PyMutex_* APIs

📚 Documentation preview 📚: https://cpython-previews--145255.org.readthedocs.build/en/145255/c-api/synchronization.html#c.PyMutex_Lock

- Implement annotation for different thread safety levels
- Annotate PyMutex_* APIs
@hugovk
Copy link
Member

hugovk commented Feb 27, 2026

python/python-docs-theme#297 is merged and released in https://github.com/python/python-docs-theme/releases/tag/2026.2

Fix the lint with uvx prek run --all-files or uvx prek run --all-files ruff-format.

And as a bonus, the docs will rebuild with the new theme.

refexplicit="True",
)
prefix = sphinx_gettext("Thread safety:") + " "
classes = [f"threadsafety-{level}"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CSS requires, as it should, the "threadsafety" class as well as "threadsafety-FOO".

Suggested change
classes = [f"threadsafety-{level}"]
classes = ["threadsafety", f"threadsafety-{level}"]

Copy link
Member

@encukou encukou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding some comments.

FWIW, I don't want to step on your toes, but I'd be happy to take over this PR & let you review, in case you'd prefer that.

- Change levels to include atomic and safe on distinct objects.
- Add a section explaining the levels in the thread safety page
- Cross reference levels section from annotation
@lysnikolaou
Copy link
Member Author

I've addressed all feedback. Additionally, after some more discussions on this, I've settled on having five different thread safety levels. I've also opened python/python-docs-theme#299 for the changes required there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants