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-111926: Update _weakref to be threadsafe in --disable-gil build by corona10 · Pull Request #112189 · python/cpython

Conversation

@corona10

@corona10 corona10 commented Nov 17, 2023 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Issue: Make weakref thread-safe without the GIL #111926

Sorry, something went wrong.

Uh oh!

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

All reactions
@corona10 corona10 added skip news topic-free-threading labels Nov 17, 2023
@corona10 corona10 changed the title gh-111926 Update _weakref to be threadsafe in --disable-gil build gh-111926: Update _weakref to be threadsafe in --disable-gil build Nov 17, 2023
@bedevere-app bedevere-app Bot mentioned this pull request Nov 17, 2023
Make weakref thread-safe without the GIL #111926
Closed
@corona10
pythongh-111926 Update _weakref to be threadsafe in --disable-gil build
c929bc0
@corona10
corona10 force-pushed the gh-111926-weakref branch from 73233d3 to c929bc0 Compare November 17, 2023 05:30
@corona10 corona10 changed the title gh-111926: Update _weakref to be threadsafe in --disable-gil build [WIP] gh-111926: Update _weakref to be threadsafe in --disable-gil build Nov 17, 2023
@corona10
fix
8f30ab9
@corona10 corona10 changed the title [WIP] gh-111926: Update _weakref to be threadsafe in --disable-gil build gh-111926: Update _weakref to be threadsafe in --disable-gil build Nov 17, 2023
@corona10
corona10 marked this pull request as ready for review November 17, 2023 06:04
@bedevere-app bedevere-app Bot added the awaiting core review label Nov 17, 2023
@corona10
corona10 requested a review from colesbury November 17, 2023 06:04
@corona10
Update order of headers
7c6ae87
@corona10

corona10 commented Nov 17, 2023

Copy link
Copy Markdown
Member Author

I am going to work on weakref object separately.

All reactions

Sorry, something went wrong.

Uh oh!

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

@corona10

corona10 commented Nov 17, 2023

Copy link
Copy Markdown
Member Author

There was some misunderstanding with my PR, I will re-send a patch for this :)

All reactions

Sorry, something went wrong.

Uh oh!

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

@corona10 corona10 closed this Nov 17, 2023
@corona10 corona10 reopened this Nov 17, 2023
@corona10
Update is_dead_weakref
043b4b1
@corona10

corona10 commented Nov 17, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

@colesbury Hmm, I am not sure this was what you intended from #111926.

IIUC, There might be two kinds of task that should be done

  • From the side of the modules: This PR might be an example.
  • From the weakreference object side: For example, PyWeakref_GetRef or _PyWeakref_GET_REF should be updated to be thread-safe?

Please let me know if there is my misunderstanding.
The reason why I don't use AC for this PR is that AC generate the critical section based on module object rather than target object.

All reactions

Sorry, something went wrong.

Uh oh!

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

colesbury
colesbury reviewed Nov 17, 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.

This looks good, other than the issue I mention below.

We will want to make both the module-level code (like this) and the operations on the weakref object thread-safe. I think it makes sense to split them up as separate PRs as you are doing.

Regarding Argument Clinic: maybe the @critical_section directive should take an optional argument specifying which parameter name to lock. For now, I think writing the critical sections manually is fine.

The tricky bit will be making _PyWeakref_GET_REF thread-safe because the lock is in the pointed-to object (ref->wr_object), but that might change or even get deallocated. I think that will need an operation _Py_TryXFetchRef from nogil-3.12 that isn't upstreamed yet. It may be worth doing the other bits and leaving _PyWeakref_GET_REF for last

Sorry, something went wrong.

Uh oh!

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

corona10 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Modules/_weakref.c Resolved

Uh oh!

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

@colesbury colesbury mentioned this pull request Nov 17, 2023
Support specifying object to lock in Argument Clinic's @critical_section directive #112213
Closed
@corona10
Address code review
3d4fe34
@corona10
corona10 requested a review from colesbury November 18, 2023 01:32
@corona10
nit
9957179
colesbury
colesbury approved these changes Nov 18, 2023
View reviewed changes
@corona10
corona10 merged commit 0566ab9 into python:main Nov 18, 2023
@bedevere-app bedevere-app Bot removed the awaiting core review label Nov 18, 2023
@corona10
corona10 deleted the gh-111926-weakref branch November 18, 2023 07:09
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
@corona10 @aisk
pythongh-111926: Update _weakref to be threadsafe in --disable-gil bu…
eea130c
…ild (pythongh-112189)
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
@corona10 @Glyphack
pythongh-111926: Update _weakref to be threadsafe in --disable-gil bu…
55378dd
…ild (pythongh-112189)
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

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.

Uh oh!

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

2 participants

@corona10 @colesbury
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 01402520 — 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.