Skip to content

gh-117721: use PyMutex in _thread.lock#125110

Merged
kumaraditya303 merged 6 commits intopython:mainfrom
kumaraditya303:mutex
Oct 8, 2024
Merged

gh-117721: use PyMutex in _thread.lock#125110
kumaraditya303 merged 6 commits intopython:mainfrom
kumaraditya303:mutex

Conversation

@kumaraditya303
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread Modules/_threadmodule.c Outdated
Comment thread Modules/_threadmodule.c Outdated
@colesbury
Copy link
Copy Markdown
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
Copy Markdown
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
@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
Copy Markdown

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

@miss-islington-app
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
Member

This change introduced a regression: #125451.

@vstinner
Copy link
Copy Markdown
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
Copy Markdown
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