Skip to content

Can we talk about "cancelled" instead of "cancelled_caught" and "raised Cancelled" and similar circumlocutions? #885

@njsmith

Description

@njsmith

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions