GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-145254: Add thread safety annotation by lysnikolaou · Pull Request #145255 · python/cpython Conversation
|
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| refexplicit="True", | ||
| ) | ||
| prefix = sphinx_gettext("Thread safety:") + " " | ||
| classes = [f"threadsafety-{level}"] |
There was a problem 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".
| classes = [f"threadsafety-{level}"] | |
| classes = ["threadsafety", f"threadsafety-{level}"] |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
- 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
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| global state in an unsynchronized way and must only be called from a single | ||
| thread throughout the program's lifetime. | ||
|
|
||
| Example: a function that modifies process-wide state such as signal handlers |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Another good example for this is APIs that return borrowed references
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Not all of them :)
It would be nice to use specific functions as examples, like with PyList_GetItemRef and PyMutex_IsLocked below.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| # Name of the function. | ||
| name: str | ||
| # Thread safety level. | ||
| # One of: 'incompatible', 'compatible', 'safe'. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
maybe use literal instead of str
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This looks good, thank you!
Let's merge to unblock the other changes; details can always be adjusted afterwards.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| global state in an unsynchronized way and must only be called from a single | ||
| thread throughout the program's lifetime. | ||
|
|
||
| Example: a function that modifies process-wide state such as signal handlers |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Not all of them :)
It would be nice to use specific functions as examples, like with PyList_GetItemRef and PyMutex_IsLocked below.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks @lysnikolaou for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
(cherry picked from commit 0dce4c6) Co-authored-by: Lysandros Nikolaou <[email protected]>
|
GH-145862 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…145862) Co-authored-by: Lysandros Nikolaou <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.