GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-112071: Make `_random.Random` methods thread-safe in `--disable-gil` builds by chgnrdv · Pull Request #112128 · python/cpython

Conversation

@chgnrdv

@chgnrdv chgnrdv commented Nov 15, 2023 •
edited by colesbury
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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

Fixes #112071

  • Issue: Make random.Random thread-safe in --disable-gil builds #112071

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@chgnrdv
gh-112071: Make _random.Random methods thread-safe in `--disable-gi…
54180e1
…l` builds

Guard `_random.Random` methods with critical section API locks by using `@critical_section` AC directive
@chgnrdv
chgnrdv requested a review from rhettinger as a code owner November 15, 2023 21:24
@bedevere-app bedevere-app Bot added the awaiting review label Nov 15, 2023
@bedevere-app bedevere-app Bot mentioned this pull request Nov 15, 2023
Make random.Random thread-safe in --disable-gil builds #112071
Closed
@colesbury colesbury added topic-free-threading skip news labels Nov 15, 2023
colesbury
colesbury approved these changes Nov 15, 2023
View reviewed changes

@colesbury colesbury left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chgnrdv reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Nov 15, 2023
corona10
corona10 requested changes Nov 22, 2023
View reviewed changes
Comment thread Modules/_randommodule.c Outdated
#endif

#include "Python.h"
#include "pycore_critical_section.h"

@corona10 corona10 Nov 22, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting changes and removed awaiting core review labels Nov 22, 2023
@bedevere-app

bedevere-app Bot commented Nov 22, 2023

Copy link
Copy Markdown

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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rhettinger
rhettinger approved these changes Nov 23, 2023
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting changes labels Nov 23, 2023
corona10 added 2 commits November 28, 2023 12:02
@corona10
Merge remote-tracking branch 'upstream/main' into make-_random-Random…
d5a48dc
…-thread-safe-in-nogil
@corona10
Remove unnecessary header including
0d112fc
corona10
corona10 approved these changes Nov 28, 2023
View reviewed changes

@corona10 corona10 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this 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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

colesbury reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@corona10
corona10 enabled auto-merge (squash) November 28, 2023 03:06
@corona10
corona10 merged commit ac4b442 into python:main Nov 28, 2023
@bedevere-app bedevere-app Bot removed the awaiting merge label Nov 28, 2023
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
@chgnrdv @corona10 @aisk
pythongh-112071: Make _random.Random methods thread-safe in `--disa…
8e17880
…ble-gil` builds (pythongh-112128)


Co-authored-by: Donghee Na <[email protected]>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
@chgnrdv @corona10 @Glyphack
pythongh-112071: Make _random.Random methods thread-safe in `--disa…
9a4e278
…ble-gil` builds (pythongh-112128)


Co-authored-by: Donghee Na <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@colesbury colesbury colesbury approved these changes
@rhettinger rhettinger rhettinger approved these changes
@corona10 corona10 corona10 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news topic-free-threading

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@chgnrdv @colesbury @rhettinger @corona10
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.