Skip to content

Add exception message for easier debugging with Cancelled #3232

@Zac-HD

Description

@Zac-HD

Occasionally we end up digging through logs trying to work out why something was cancelled, and eventually it occurred to me that Trio could help with this. I don't have a complete design proposal, but it would be great to handle each of three cases:

  • a deadline was reached.
  • a sibling task in the Nursery raised an exception, including the name of the erroring task
  • someone called CancelScope.cancel(), including the name of the task in which this was called
    • add a new reason: str | None = None param, so that users can explicitly annotate why they cancelled something

I think we could represent this as a string argument to Cancelled like any other exception message; the only tricky part will be threading it through all the cancellation-delivery machinery 🙂

Comments and design input most welcome, of course!

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