-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Use PyEval_InitThreads()
as intended
#4350
Conversation
https://docs.python.org/3.6/c-api/init.html#c.PyEval_InitThreads > This function is not available when thread support is disabled at compile time.
@eacousineau there is no specific reason for requesting a review from you, but @henryiii has been unresponsive for 3 weeks. It would be great if you could help out with a second set of eyes. |
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.
Sounds good, and thanks for the writeup! Though I'm afraid I may be a bit slow to catch up on the issues.
It's hard for me to posit from above Windows-based failure that the above indicated misplacement. Can I ask if the following is the correct reasoning, reasoning within Python 3.6?
- Calling
PyEval_InitThreads()
inget_internals()
via nominal usage did nothing per 3.6 docs stating that "This is a no-op when called for a second time", so this is a harmless (but noisy) misplacement. - The missing call in
embed.h
are why Windows (and others?) fail. This smells like it'd happen when the embedded interpreter exits beforeget_internals()
was called. Is this the case? (is it spurious, or deterministic?)
…t is always false.
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.
Still not sure on the whole of the changes (per questions in first post), but def. won't block progress - thanks!
Sorry I wasn't able to finish the below before a long meeting, continuing now ...
Yes, in the sense that it is harmless if there is actually a correct placement. That's not the case before this PR. I was thinking of "misplaced" as in "we're moving it from the wrong place to the right place".
Not deterministic. "flaky" is the term I see getting used around Google. My understanding is not complete, but IIUC the Python documentation correctly, prior to Python 3.7,
is before this:
Now pure speculation: I think that the "non-simple" code in gil.h covered that up, somehow. I'm thinking that because we didn't see the flakiness I'm trying to fix with this PR before PR #4216. Thanks for the approvals! |
Sweet, that all makes sense - thanks for the thorough response! |
Description
This PR actually matters
-DPYBIND11_SIMPLE_GIL_MANAGEMENT=ON
(evidently, based on CI flakes observed since PR AddPYBIND11_SIMPLE_GIL_MANAGEMENT
option (cmake, C++ define) #4216 was merged),Hypothesis:
-DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF
covers up thatPyEval_InitThreads()
was misplaced.This PR almost does not matter anymore at all:
Note that Python 3.6 EOL was 2021-12-23 (https://endoflife.date/python), but since PR #4216 was merged we had distracting CI flakes that this PR aims to get rid of, e.g.:
Suggested changelog entry:
Bug fix affecting only Python 3.6 under very specific, uncommon conditions: move ``PyEval_InitThreads()`` call to the correct location.