chilly-magazine-2154503/13/2021, 11:36 AM
Here’s the rule: if it’s in the trio namespace, and you use await to call it, then it’s cancellable (see Checkpoints above). Cancellable means:
- If you try to call it when inside a cancelled scope, then it will raise Cancelled.
- If it blocks, and while it’s blocked then one of the scopes around it becomes cancelled, it will return early and raise Cancelled.
- Raising Cancelled means that the operation did not happen. If a Trio socket’s send method raises Cancelled, then no data was sent. If a Trio socket’s recv method raises Cancelled then no data was lost – it’s still sitting in the socket receive buffer waiting for you to call recv again. And so forth.