python-trio / python-trio/trio
It should be possible to get a traceback out of a cancel scope
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
With fail_after, it's a bit annoying that it can't show you where the block was cancelled. (The traceback just starts at the end of the scope.)
This will be a problem in particular for test timeouts. (Well, they probably won't use fail_after, but they'll have the same problem.)
I don't think we can capture the exceptions in cancel scope objects by default, because we don't want to pin the stacks in memory.
We could have a flag that tells it to save caught exceptions, though. Or try to do something clever with catching them ourselves inside the scope, but that's basically the same thing from the user point of view, and the cancel scope already knows how to reliably catch its own exceptions.
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 by tracing how fail_after and cancel scope handle cancellation and caught exceptions. Determine how an opt-in traceback could be exposed without retaining stacks by default, and verify that the resulting traceback identifies where the scope was cancelled, including the test-timeout use case.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100