-
Notifications
You must be signed in to change notification settings - Fork 938
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
Make GILReleaser exception-safe #2363
Conversation
If an exception occurs while the GIL is released, it won't be reacquired and the stack unwinding will take place without the GIL. Releasing and Reacquiring wil be removed.
Codecov Report
@@ Coverage Diff @@
## master #2363 +/- ##
==========================================
- Coverage 56.35% 56.34% -0.00%
==========================================
Files 285 285
Lines 24242 24242
==========================================
- Hits 13658 13657 -1
- Misses 10584 10585 +1
Continue to review full report at Codecov.
|
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.
Thank you for the detailed analysis and the patch! 🏅
Both make sense to me and should be merged soon.
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. Thanks.
If an exception occurs while the GIL is released, it won't be reacquired and the stack unwinding will take place without the GIL. GILReleaser::release() and GILReleaser::reacquire() is removed, because it is unsafe.
If an exception occurs while the GIL is released, it won't be reacquired and the stack unwinding will take place without the GIL. GILReleaser::release() and GILReleaser::reacquire() is removed, because it is unsafe.
Description
If an exception occurs while the GIL is released,
it won't be reacquired and the stack unwinding will take place
without the GIL. Releasing and Reacquiring wil be removed.
For example,
is not exception safe, because if
do_long_computation_2()
throws an exception, the Python object res2 will be destroyed without the GIL.Instead,
will be safe.
An IIFE would also work
Checklist