python-trio / python-trio/trio
Make it easier to see if a `Task` is created/running/exited
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
It is currently possible to check the status of a task with https://docs.python.org/3/library/inspect.html#inspect.getcoroutinestate, but this is fairly obscure and not very readable.
We should either document this, or add properties to Task that are easy to interface with.
For implementing it, I think has_started() -> bool and has_exited -> bool would be a clean way of doing it.
I personally encountered this in https://github.com/python-trio/trio/issues/3035#issuecomment-2312328838 which would only be for internal use, but I'm guessing it might be useful enough to surface in the public API.
See discussion in Gitter: https://matrix.to/#/!OqDVTrmPstKzivLwZW:gitter.im/$umF5oOw9d2Z20gb95GF_C48HyBi2l6eD3ZW4r_4ark0?via=gitter.im&via=matrix.org&via=zoltan.site
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 reviewing Python's inspect.getcoroutinestate documentation and the Task API, then read the linked Trio discussion and Gitter conversation for the intended public behavior. Decide whether documentation alone is sufficient or whether Task status properties are needed; done means the chosen approach clearly distinguishes created, running, and exited states.
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
- Needs clarification
- Newbie friendliness
- 25/100