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

gh-112071: Make _random.Random methods thread-safe in --disable-gil builds #112128

Merged

Conversation

chgnrdv
Copy link
Contributor

@chgnrdv chgnrdv commented Nov 15, 2023

Guard _random.Random methods with critical section API locks by using @critical_section AC directive.

Fixes #112071

…ble-gil` builds

Guard `_random.Random` methods with critical section API locks by using `@critical_section` AC directive
Copy link
Contributor

@colesbury colesbury left a comment

Choose a reason for hiding this comment

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

Thanks @chgnrdv, this LGTM.

@rhettinger, would you be able to review this? This adds @critical_section Argument Clinic directives to the methods of _random.Random. In --disable-gil builds, this acquires/releases the per-object locks around the methods. They are no-ops in the default build.

@@ -71,6 +71,7 @@
#endif

#include "Python.h"
#include "pycore_critical_section.h"
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to add this header manually since the AC automatically adds it.
Please rebase the branch and rerun the make clinic

@bedevere-app
Copy link

bedevere-app bot commented Nov 22, 2023

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be put in the comfy chair!

Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

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

LGTM (with my own push) cc @colesbury

@corona10 corona10 enabled auto-merge (squash) November 28, 2023 03:06
@corona10 corona10 merged commit ac4b442 into python:main Nov 28, 2023
25 checks passed
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
…ble-gil` builds (pythongh-112128)


Co-authored-by: Donghee Na <donghee.na@python.org>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
…ble-gil` builds (pythongh-112128)


Co-authored-by: Donghee Na <donghee.na@python.org>
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.

Make random.Random thread-safe in --disable-gil builds
4 participants