python-trio / python-trio/trio
Provide a helper to dump the task tree / stack tree
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
This would be useful in several situations:
-
Possibly we should default to registering a handler for
SIGUSR1(or something similarly innocuous, likeSIGIOorSIGSYS), to dump the task tree to stderr. This would help a lot with debugging deadlocks (like @Ninpo has been running into in chat recently) -
It would be useful for a watchdog thread: #591
-
pytest-trio can/should detect frozen tests (https://github.com/python-trio/pytest-trio/issues/53), and this would be really useful for diagnosing them (esp. in cases like where the deadlock happens in a remote CI system)
-
It would be useful for tutorials
There's a simple task tree formatter in notes-to-self/.
@oremanj apparently has a version that shows the full stack trace for all tasks. This involves some terrifying hacks to figure out after-the-fact which stack frames created which nurseries, and to work around bpo-32810 (see).
I had a potential idea for how to match up the frames without the terrifying hacks.
For large apps we might want to do some kind of "stack trace compression". Like if you have 1000 tasks, then probably 990 of them have the exact same stack, possibly modulo the last frame or so. Grouping them together based on common prefixes and only printing the prefix once probably makes dumps in this case much more readable.
We don't have to do all of these things in the first version. We can start simpler and iterate.
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 with the simple task tree formatter in notes-to-self/ and review the issue's references to watchdog thread #591 and pytest-trio issue 53. Define a small first version before investigating full stack traces, signal handling, or stack trace compression; done should mean the chosen task-tree dump behavior is implemented and usable for debugging.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100