bpo-39877: take_gil() now exits the thread if finalizing#18854
bpo-39877: take_gil() now exits the thread if finalizing#18854vstinner wants to merge 2 commits into
Conversation
take_gil() is now responsible to exit the thread if Python is finalizing. Not only exit before trying to acquire the GIL, but exit also once the GIL is succesfully acquired.
|
@pitrou: My previous change introduced a race condition: https://bugs.python.org/issue39877#msg363667 This change should fix it. |
Sorry, something went wrong.
Sorry, something went wrong.
pitrou
left a comment
There was a problem hiding this comment.
I believe the fix is somehow incomplete, see below.
Also, as you say, the problem is "is it safe to destroy the GIL if there are still daemon threads trying to take it?".
Sorry, something went wrong.
|
When you're done making the requested changes, leave the comment: |
Sorry, something went wrong.
|
I have made the requested changes; please review again. |
Sorry, something went wrong.
|
Thanks for making the requested changes! @pitrou: please review the changes made to this pull request. |
Sorry, something went wrong.
|
I merged PR #18890 which checks if the thread must exit at function exit as well. In short, it restores the Python 3.8 behavior. I close this PR for now. We can revisit take_gil() later to try to adjust/optimize it later. I prefer to move step by step. |
Sorry, something went wrong.
take_gil() is now responsible to exit the thread if Python is
finalizing. Not only exit before trying to acquire the GIL, but exit
also once the GIL is succesfully acquired.
https://bugs.python.org/issue39877