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

Add trio.hazmat.batch_cancellations() #900

Closed
wants to merge 1 commit into from

Conversation

oremanj
Copy link
Member

@oremanj oremanj commented Feb 3, 2019

This generalizes the "cancel multiple scopes without waking up the tasks, then wake up all the tasks at once" pattern that was previously a special case for handling cancellations on a deadline. It will simplify the
implementation of #886, and exposing it as part of hazmat lets users write their own cancellation
abstractions that work the way the native ones do.

@codecov
Copy link

codecov bot commented Feb 3, 2019

Codecov Report

Merging #900 into master will decrease coverage by 0.2%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #900      +/-   ##
==========================================
- Coverage   99.53%   99.32%   -0.21%     
==========================================
  Files         102      102              
  Lines       12411    12461      +50     
  Branches      916      918       +2     
==========================================
+ Hits        12353    12377      +24     
- Misses         36       60      +24     
- Partials       22       24       +2
Impacted Files Coverage Δ
trio/hazmat.py 100% <ø> (ø) ⬆️
trio/_core/tests/test_run.py 100% <100%> (ø) ⬆️
trio/_core/_run.py 99.71% <100%> (ø) ⬆️
trio/_subprocess_platform/waitid.py 60.52% <0%> (-39.48%) ⬇️
trio/_util.py 93.97% <0%> (-6.03%) ⬇️
trio/_core/_multierror.py 95.59% <0%> (-3.78%) ⬇️

@oremanj oremanj requested a review from njsmith February 3, 2019 23:21
This generalizes the "cancel multiple scopes without waking up the tasks, then wake up all the tasks at once"
pattern that was previously a special case for handling cancellations on a deadline. It will simplify the
implementation of python-trio#886, and exposing it as part of hazmat lets users write their own cancellation
abstractions that work the way the native ones do.
@python-trio python-trio deleted a comment from codecov bot Feb 3, 2019
@njsmith
Copy link
Member

njsmith commented Feb 3, 2019

What do you think of #860 as a way to eliminate the need for this entirely?

@oremanj
Copy link
Member Author

oremanj commented Feb 3, 2019

I had looked at that, and I agree that it would be cleaner if we can get it to work, but I'm leery of lurking bugs if the cancellation landscape changes in just the wrong way while a Cancelled exception is propagating. I didn't feel confident in my own ability to correctly do the analysis that would disprove it, at any rate. OTOH, I also tried for a while to demonstrate a specific issue and couldn't find any, so maybe #860 is a better approach after all?

@oremanj
Copy link
Member Author

oremanj commented Feb 4, 2019

We decided #860 works after all, so let's go with that instead!

@oremanj oremanj closed this Feb 4, 2019
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.

2 participants