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-117721: use PyMutex in _thread.lock #125110

Merged
merged 6 commits into from
Oct 8, 2024
Merged

Conversation

kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Oct 8, 2024

Changes:

  • use PyMutex instead of PyThread_type_lock
  • as enhancement use Py_TPFLAGS_MANAGED_WEAKREF

@kumaraditya303 kumaraditya303 marked this pull request as ready for review October 8, 2024 13:59
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.

LGTM. Minor comments below

Modules/_threadmodule.c Outdated Show resolved Hide resolved
Modules/_threadmodule.c Outdated Show resolved Hide resolved
@colesbury
Copy link
Contributor

@kumaraditya303, see #125058. We should check if this makes threading.Lock.acquire() interruptible on Windows. If so, it probably deserves a NEWS entry and possibly a documentation update.

@kumaraditya303
Copy link
Contributor Author

We should check if this makes threading.Lock.acquire() interruptible on Windows. If so, it probably deserves a NEWS entry and possibly a documentation update.

It doesn't, it is not interruptible.

@kumaraditya303 kumaraditya303 merged commit fca5529 into python:main Oct 8, 2024
35 checks passed
@kumaraditya303 kumaraditya303 deleted the mutex branch October 8, 2024 14:47
@kumaraditya303 kumaraditya303 added the needs backport to 3.13 bugs and security fixes label Oct 8, 2024
@miss-islington-app
Copy link

Thanks @kumaraditya303 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @kumaraditya303, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker fca552993da32044165223eec2297b6aaaac60ad 3.13

@bedevere-app
Copy link

bedevere-app bot commented Oct 8, 2024

GH-125116 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Oct 8, 2024
kumaraditya303 added a commit to kumaraditya303/cpython that referenced this pull request Oct 8, 2024
kumaraditya303 added a commit that referenced this pull request Oct 8, 2024
* gh-117721: use PyMutex in `_thread.lock` (#125110)

(cherry picked from commit fca5529)
efimov-mikhail pushed a commit to efimov-mikhail/cpython that referenced this pull request Oct 9, 2024
@vstinner
Copy link
Member

This change introduced a regression: #125451.

@vstinner
Copy link
Member

#125116 is a backport of this pull request to the 3.13 branch.

IMO this change should not be backported to 3.13 in a bugfix release. It's too big, it can cause regression as you can see.

@colesbury
Copy link
Contributor

I don't think there's a bug in _thread.lock, but I'm okay with reverting the backport

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.

3 participants