-
Notifications
You must be signed in to change notification settings - Fork 805
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
RFC: Add Python::with_pool as a safe alternative to GILPool usage. #3167
Conversation
2973477
to
9fff95f
Compare
9fff95f
to
005b64a
Compare
Great insight that there is potential for a safe API here. However, I'm a bit concerned that on stable this conflicts with #2141. How do you feel about making this nightly-only, where the auto trait makes it sound? |
Didn't get a notification mail again... Hhhmmm, I am not sure about making it One thing that is in favour of adding this as a safe if technically unsound API on stable is that I think this would reduce the probability of making mistakes compared to the existing |
So do we add this another option or should it replace the current API? Is it nightly-only or also-stable? |
I agree this is significantly easier to use than How do you feel about offering this on both stable and with the |
I think that is definitely the case. We are in the wrong, but we cannot make it right without either using nightly features or making the feature useless using the
Strictly speaking it is incorrect, but I think we might need to make room for the immaturity of the language here to avoid the perfect being the enemy of the good. Especially since from a strict point of view,
If we do this and deprecate Hence, under these requirements, it seems better to me to just add this as a new (mostly unsafe) API without a deprecation of the existing one, possibly even targetting v0.19.x instead of v0.20.0, so that it can gain some voluntary users before we push people this way by starting a deprecation cycle. |
Sure thing, so is the agreement that in this PR we will add impl Python<'_> {
#[cfg(not(feature = "nightly"))]
unsafe fn with_pool(...) { ... }
#[cfg(feature = "nightly")]
fn with_pool(...) { ... } which is suitable to cherry-pick for 0.19.1 (should we have reason to create a patch release), and we can leave an issue in the backlog to deprecate My reluctance to add it as "safe" on stable also comes from the hope that we can eliminate the need for the pool entirely before too much longer. In fact, I'm just going to push the prototype I have for that now so that we can discuss whether what I've been sketching out makes sense and begin iteration in that direction. |
(Corrected the above snippet to Also posted my current branch which might be how we remove the pool in #3205 |
I think that if there is a realistic path towards removal of |
Ok - though I think it might be quite a while before we manage to phase out the |
The
Ungil
bound is required to prevent the closure from reusing the outer GIL token via captures which does give this a limited applicability compared to direct usage ofGILPool
, but nevertheless I think it should be safe.Obviously only draft as this would require a deprecation cycle and an extensive update of the documentation.