-
-
Notifications
You must be signed in to change notification settings - Fork 379
Description
Right now, whenever we create a Cancelled exception, we immediately tag it with the cancel scope that's going to catch it.
There's another option that's briefly mentioned in #606: we could wait until CancelScope.__exit__ to decide whether a given Cancelled exception "belongs" to this scope. The check would be "on the current task's stack, am I the outermost unshielded scope that's in the cancelled state?"
This can behave differently from what we have now in cases where there are multiple cancelled CancelScopes on the stack.
I'm not entirely sure if this would actually help with #606, because of complications noted there (hello KeyboardInterrupt). But it would probably simplify the cancel scope code in general, in particular _cancel_no_notify, and the issues described in this comment: #835 (comment)