python-trio / python-trio/trio
Add exception message for easier debugging with `Cancelled`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
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
Nurseryraised 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 = Noneparam, so that users can explicitly annotate why they cancelled something
- add a new
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!
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 at the Cancelled exception, CancelScope.cancel(), and Nursery cancellation paths, then trace the cancellation-delivery machinery; the issue names no files or tests. Done means defining and implementing messages for deadlines, sibling-task failures, and explicit cancellation reasons, including the requested task names and optional reason.
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
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100