gh-145254: Add thread safety annotation#145255
Open
lysnikolaou wants to merge 1 commit intopython:mainfrom
Open
gh-145254: Add thread safety annotation#145255lysnikolaou wants to merge 1 commit intopython:mainfrom
lysnikolaou wants to merge 1 commit intopython:mainfrom
Conversation
- Implement annotation for different thread safety levels - Annotate PyMutex_* APIs
Member
|
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 And as a bonus, the docs will rebuild with the new theme. |
hugovk
reviewed
Feb 27, 2026
Comment on lines
+304
to
+315
| _THREADSAFETY_DISPLAY = { | ||
| "incompatible": "Not safe to call from multiple threads.", | ||
| "compatible": "Safe to call from multiple threads with external synchronization only.", | ||
| "safe": "Safe for concurrent use.", | ||
| } | ||
|
|
||
| # Maps each thread safety level to the glossary term it should link to. | ||
| _THREADSAFETY_TERM = { | ||
| "incompatible": "thread-incompatible", | ||
| "compatible": "thread-compatible", | ||
| "safe": "thread-safe", | ||
| } |
Member
There was a problem hiding this comment.
Will this be backported?
Even if so, perhaps use frozendict on main?
Suggested change
| _THREADSAFETY_DISPLAY = { | |
| "incompatible": "Not safe to call from multiple threads.", | |
| "compatible": "Safe to call from multiple threads with external synchronization only.", | |
| "safe": "Safe for concurrent use.", | |
| } | |
| # Maps each thread safety level to the glossary term it should link to. | |
| _THREADSAFETY_TERM = { | |
| "incompatible": "thread-incompatible", | |
| "compatible": "thread-compatible", | |
| "safe": "thread-safe", | |
| } | |
| _THREADSAFETY_DISPLAY = frozendict( | |
| incompatible = "Not safe to call from multiple threads.", | |
| compatible = "Safe to call from multiple threads with external synchronization only.", | |
| safe = "Safe for concurrent use.", | |
| ) | |
| # Maps each thread safety level to the glossary term it should link to. | |
| _THREADSAFETY_TERM = frozendict( | |
| incompatible = "thread-incompatible", | |
| compatible = "thread-compatible", | |
| safe = "thread-safe", | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📚 Documentation preview 📚: https://cpython-previews--145255.org.readthedocs.build/en/145255/c-api/synchronization.html#c.PyMutex_Lock