FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-127065: Make methodcaller thread-safe and re-entrant (v2) by eendebakpt · Pull Request #127746 · python/cpython · GitHub

Repository navigation

gh-127065: Make methodcaller thread-safe and re-entrant (v2) - #127746

Merged
colesbury merged 29 commits into
python:mainfrom
eendebakpt:methodcaller_ft_v2
Dec 11, 2024
Merged

colesbury merged 29 commits into
python:mainfrom
eendebakpt:methodcaller_ft_v2

Conversation

eendebakpt commented Dec 8, 2024 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

Comment thread Modules/_operator.c
Py_VISIT(mc->args);
Py_VISIT(mc->kwds);
Py_VISIT(mc->vectorcall_args);
Py_VISIT(mc->vectorcall_kwnames);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Note mc->vectorcall_kwnames is a tuple of strings, but the strings can be subclasses of str, so we need to visit this.

colesbury left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks good. A few small comments below

Comment thread Modules/_operator.c Outdated
Comment thread Modules/_operator.c Outdated
Comment thread Modules/_operator.c Outdated
Comment thread Modules/_operator.c Outdated

colesbury left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM. Thanks for fixing this!

colesbury merged commit b0f278f into python:main Dec 11, 2024
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 8, 2025
…GH-127746)

The function `operator.methodcaller` was not thread-safe since the additional
of the vectorcall method in pythongh-89013. In the free threading build the issue
is easy to trigger, for the normal build harder.

This makes the `methodcaller` safe by:

* Replacing the lazy initialization with initialization in the constructor.
* Using a stack allocated space for the vectorcall arguments and falling back
  to `tp_call` for calls with more than 8 arguments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL