Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-37878: Make PyThreadState_DeleteCurrent() Internal#15315
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
nanjekyejoannah commented Aug 16, 2019 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
nanjekyejoannah commented Aug 16, 2019
willingc left a comment
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.
Thanks @nanjekyejoannah for the PR. I've made some suggested wording changes for reader clarity.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-Authored-By: Carol Willing <carolcode@willingconsulting.com>
Co-Authored-By: Carol Willing <carolcode@willingconsulting.com>
nanjekyejoannah commented Aug 17, 2019
@willingc Changes committed. |
willingc commented Aug 17, 2019
Let's give @ericsnowcurrently a chance to review too. Thanks. Please ping me if this is still open later this week and I will merge. |
vstinner left a comment
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.
I'm not sure that it's a good idea to document this function: https://bugs.python.org/issue37878#msg349954
bedevere-bot commented Aug 19, 2019
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
nanjekyejoannah commented Aug 28, 2019
@vstinner, I made the function internal instead. PTAL |
Modules/_threadmodule.c Outdated
| tstate->interp->num_threads--; | ||
| PyThreadState_Clear(tstate); | ||
| PyThreadState_DeleteCurrent(); | ||
| _PyThreadState_DeleteCurrent(&_PyRuntime); |
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.
Please add "_PyRuntimeState *runtime = &_PyRuntime;" at the beginning of the function, and replace &_PyRuntime with runtime.
Or maybe even better: add the field to "struct bootstate" and fill the field in thread_PyThread_start_new_thread(). It would make t_bootstrap() more "state-less" (don't access directly global variables).
I dismiss Carol's review since Joannah rewrote her PR, and Carol approved the previous version of the PR.
vstinner left a comment
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.
Since it is a public function, even if it's not documented, please document the removal at:
https://docs.python.org/dev/whatsnew/3.9.html#removed
You can mention that the removed function was not documented.
For example, in Python 3.8, I wrote:
"The PyByteArray_Init() and PyByteArray_Fini() functions have been removed. They did nothing since Python 2.7.4 and Python 3.2.0, were excluded from the limited API (stable ABI), and were not documented. (Contributed by Victor Stinner in bpo-35713.)"
nanjekyejoannah commented Sep 5, 2019
I have made the requested changes; please review again . |
bedevere-bot commented Sep 5, 2019
Thanks for making the requested changes! @vstinner: please review the changes made to this pull request. |
vstinner left a comment
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.
LGTM.
vstinner commented Sep 5, 2019
Thanks @nanjekyejoannah! It now looks better: remove the function rather than documenting it :-) I prefer to have a smaller C API! |
tacaswell commented Sep 24, 2019
This breaks pybind 11. Opened an issue with them (pybind/pybind11#1932). Where this should be fixed is a bit over my head at the moment. |
vstinner commented Sep 24, 2019
Your gil_scoped_acquire class implementation is scary! Would you mind to open a new issue at bugs.python.org to describe your use case and ask to revert the change which removed PyThreadState_DeleteCurrent? |
wjakob commented Sep 24, 2019
Pybind11 supports some advanced GIL-related tricks that require access this function. For instance, pybind11 can intercept a Python function call on the Kind of crazy, but why is this useful? UI libraries. On some platforms, it is not legal to poll UI events on any thread other than the main thread. This means that it's impossible to implement a proper UI event loop because Python is hogging the main thread. With the functionality in pybind11's |
wjakob commented Sep 24, 2019
@vstinner: I provided some feedback on the Python bugtracker and here. |
wjakob commented Sep 24, 2019
henryiii commented May 26, 2020
I'm confused by the attached issue; it looks like the decision was to simply revert the change with the function moved, and not add the underscore; and maybe even make it slightly easier to use. Now that 3.9b1 is out, PyBind11-based libraries cannot build, and the only fix would be to start using a now internal function in CPython. SciPy is an example of a PyBind11-using library. |
vstinner commented May 26, 2020 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
PyThreadState_DeleteCurrent() is declared by the public C API, but it's now excluded from the limited C API. Does pybind11 uses the limited C API? What is your issue? Please comment https://bugs.python.org/issue37878 instead of this merged PR (if you have a bugs.python.org account). |
henryiii commented May 28, 2020
I'm sorry, I'll add a bugs.python.org account or see if I had one in the past if I need to comment there. I realize, from looking through the code, that an underscore was not added, the function was moved intact (which was not clear from the PR), exactly as it was supposed to be in the issue. The only remaining problem is that the release notes here are wrong: https://docs.python.org/3.9/whatsnew/3.9.html#removed (which is a much better problem). I'd love it if PyBind11 could use the limited API, but it can't. Thank you, @vstinner ! |
vstinner commented May 28, 2020
I created #20489 to update the What's New in Python 3.9 document. Would you mind to review my PR? |
Make
PyThreadState_DeleteCurrent()Internal.https://bugs.python.org/issue37878