-
Notifications
You must be signed in to change notification settings - Fork 760
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
Various fixes to edge cases with GILGuard #1036
Conversation
8a723f5
to
b90e7c6
Compare
Thank you!
|
src/gil.rs
Outdated
// Safety check & update counter | ||
GILGUARD_COUNT.with(|c| { | ||
if c.get() - 1 != self.previous_count { | ||
panic!("GILGuards must be dropped in the reverse of the order they are created.") |
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.
We should panic only when the gstate is PyGILState_UNLOCKED
and GILGuard is nested.
In this nested case we care, gstate
is always PyGILState_LOCKED
and it's not problematic to set it in an incorrect order.
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.
What I meant is:
GIL_COUNT.try_with(|c| {
if c.get() > 0 && self.gstate == PyGILState_UNLOCKED { panic!("...") }
});
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.
Good idea, I'll go for that. Avoids needing to add GILGUARD_COUNT
Having looked further into these and subsequent tests, I've concluded that For For the |
|
It's not quite so clear-cut as that. Even for extensions, use of I have to say I really don't like the Also, I think I'll change |
b90e7c6
to
93098ac
Compare
I've pushed those discussed changes. One interesting discovery from this was that |
Thank you, though I don't understand the intention of some changes in the test files.
I agree that |
The example for Anyway, please hold on merging this PR; I'll make a new PR for
Maybe the changes you are referring to are where I had to remove |
403baf6
to
6c0cc78
Compare
6c0cc78
to
1f37dbc
Compare
Having made the |
Closes #1019
I introduce panics for the two "nasty" cases discussed in that issue.