Skip to content
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

Added a 'cancellable' set of conversions for proper cancellation from Python #48

Merged
merged 8 commits into from
Oct 20, 2021

Conversation

awestlake87
Copy link
Owner

This PR addresses the issue brought up in #47 where the Rust future keeps running after the asyncio.Future has been cancelled.

For now, I've added this functionality as a separate set of cancellable_future_into_py* conversions, but I think this might be better served as the default functionality rather than an opt-in functionality. I'm open to feedback and suggestions on this though!

As it is now, it can be released as a patch, but in 0.15 the functionality in cancellable_future_into_py* might just be baked-in by default and the cancellable_future_into_py* conversions would be deprecated.

…ncelled from Python (may become default behaviour in next release)
@ShadowJonathan
Copy link

but I think this might be better served as the default functionality rather than an opt-in functionality.

Concur, because this library is all about "magically" transforming rust futures to asyncio futures, and back, and cancellation (or simply dropping a future in rust) is a big part of either functionality, so i'd say that making this the default is reasonable and expected.

@ShadowJonathan
Copy link

One thing; if you're going to instantly deprecate this in 0.15 and make it the default, then also note that in the documentation.

@awestlake87
Copy link
Owner Author

Yeah I agree, that's a good point.

@awestlake87
Copy link
Owner Author

Finally wrapping this PR up!

  • I went ahead and added a notice to all of the new cancellable variants about the future deprecation in 0.15
  • Added local_cancellable_* variants to support cancellation for !Send futures
  • Added test for local_cancellable_* variants.

Should be ready for a 0.14.1 release unless something comes up last minute!

@awestlake87 awestlake87 merged commit 1f231dc into master Oct 20, 2021
@awestlake87 awestlake87 deleted the better-cancellation branch March 15, 2022 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants