Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[WIP] bpo-40533: Make PyObject.ob_refcnt atomic in subinterpreters #19958

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

Closed
wants to merge 1 commit into from
Closed

[WIP] bpo-40533: Make PyObject.ob_refcnt atomic in subinterpreters #19958

wants to merge 1 commit into from

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented May 6, 2020

When Python is built with experimental isolated interpreters, declare
PyObject.ob_refcnt and _dictkeysobject.dk_refcnt as atomic variables.

Temporary workaround until subinterpreters stop sharing Python
objects.

https://bugs.python.org/issue40533

When Python is built with experimental isolated interpreters, declare
PyObject.ob_refcnt and _dictkeysobject.dk_refcnt as atomic variables.

Temporary workaround until subinterpreters stop sharing Python
objects.
@vstinner
Copy link
Member Author

vstinner commented May 6, 2020

@aeros
Copy link
Contributor

aeros commented May 6, 2020

Based on the discussion at https://mail.python.org/archives/list/[email protected]/thread/2WHQBHFK7UQ7OYAJV5S2QCINODVVKGJY/#2WHQBHFK7UQ7OYAJV5S2QCINODVVKGJY, I think we should leave a DO-NOT-MERGE label until the 3.9 branch is created.

@vstinner vstinner marked this pull request as draft May 6, 2020 22:34
@vstinner
Copy link
Member Author

vstinner commented May 6, 2020

Based on the discussion at https://mail.python.org/archives/list/[email protected]/thread/2WHQBHFK7UQ7OYAJV5S2QCINODVVKGJY/#2WHQBHFK7UQ7OYAJV5S2QCINODVVKGJY, I think we should leave a DO-NOT-MERGE label until the 3.9 branch is created.

Right, thanks. I converted this PR into a draft to ensure that nobody merges it by mistake.

@vstinner vstinner changed the title bpo-40533: Make PyObject.ob_refcnt atomic in subinterpreters [WIP] bpo-40533: Make PyObject.ob_refcnt atomic in subinterpreters May 6, 2020
Comment on lines +107 to +111
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
/* bpo-40533: Use an atomic variable for PyObject.ob_refcnt, to ensure that
Py_INCREF() and Py_DECREF() are safe when called in parallel, until
subinterpreters stop sharing Python objects. */
_Atomic Py_ssize_t ob_refcnt;
Copy link
Contributor

@aeros aeros May 6, 2020

Choose a reason for hiding this comment

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

Perhaps this is somewhat emphasized by the "experimental" part, but could we possibly make it a bit more crystal clear that this is only a temporary stopgap measure? I personally find that "until subinterpreters stop sharing Python objects" could be interpreted as a near indefinite amount of time; I'm not confident that most readers will go over the full context in the bpo issue and related discussions.

Normally, this wouldn't be a huge concern, but I think object.h is likely one of the most public-facing header files in CPython, so it seems important to communicate this as clearly as possible.

@vstinner
Copy link
Member Author

The current plan is to not share any object between two interpreters, so this PR is not needed. I close it.

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.

4 participants