GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||
GeezerVison is showing github.com — bpo-37878: Make PyThreadState_DeleteCurrent() Internal by nanjekyejoannah · Pull Request #15315 · python/cpython Conversation
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-Authored-By: Carol Willing <[email protected]>
Co-Authored-By: Carol Willing <[email protected]>
|
@willingc Changes committed. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@vstinner, I made the function internal instead. PTAL |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| tstate->interp->num_threads--; | ||
| PyThreadState_Clear(tstate); | ||
| PyThreadState_DeleteCurrent(); | ||
| _PyThreadState_DeleteCurrent(&_PyRuntime); |
There was a problem 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).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I dismiss Carol's review since Joannah rewrote her PR, and Carol approved the previous version of the PR.
There was a problem 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.)"
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I have made the requested changes; please review again . |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for making the requested changes! @vstinner: please review the changes made to this pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @nanjekyejoannah! It now looks better: remove the function rather than documenting it :-) I prefer to have a smaller C API! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
) * Rename PyThreadState_DeleteCurrent() to _PyThreadState_DeleteCurrent() * Move it to the internal C API Co-Authored-By: Carol Willing <[email protected]>
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@vstinner: I provided some feedback on the Python bugtracker and here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
) * Rename PyThreadState_DeleteCurrent() to _PyThreadState_DeleteCurrent() * Move it to the internal C API Co-Authored-By: Carol Willing <[email protected]>
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
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 ! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I created #20489 to update the What's New in Python 3.9 document. Would you mind to review my PR? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
) * Rename PyThreadState_DeleteCurrent() to _PyThreadState_DeleteCurrent() * Move it to the internal C API Co-Authored-By: Carol Willing <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.