python-trio / python-trio/trio
Can we talk about "cancelled" instead of "cancelled_caught" and "raised Cancelled" and similar circumlocutions?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
In this comment, @mehaase wrote:
Most low-level operations in trio provide a guarantee: if they raise trio.Cancelled, this means that they had no effect
I didn't understand this passage at first, because of the phrase "if they raise trio.Cancelled", which makes it sound like it got cancelled for some internal reason. From the user's point of view, it would make more sense to say, "if a call to
send_all()is cancelled..."
I'm actually not sure what he's quoting, but it sure sounds like something I'd write in the docs, especially back when I was still struggling to come to grips with fine distinctions like cancel_scope.cancel_called versus cancel_scope.cancelled_caught. And I'm pretty sure the reason I didn't say "if a call to send_all() is cancelled" is because technically you could call .cancel() on a scope surrounding a call to send_all but the call didn't raise Cancelled because it had already passed the point of no return. Which... is technically accurate, but as Mark points out, super confusing to ordinary humans. And probably saying "if a call to send_all() is cancelled" would be totally clear to actual readers; if the tiny edge case was pointed out they'd just shrug and think "well, I guess it wasn't cancelled then".
And btw the distinction between .cancel_called and .cancelled_caught is also super confusing to regular humans.
Maybe we should change the official way of talking about this to more like: cancel_scope.cancel() requests a cancellation, but code might or might not actually be cancelled (= raise Cancelled).
That would suggest renaming the CancelScope attributes to something like .cancel_requested and .cancel_succeeded, and also probably updating the docs to use this language more uniformly (though I haven't read through the docs to check).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the documentation and the CancelScope API references mentioned in the issue, especially cancel_called, cancelled_caught, and Cancelled usage around send_all(). Determine the intended terminology and whether the proposed attribute renames are part of the scope. Done means the project has an agreed naming direction and the affected API and documentation consistently reflect it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100