python-trio / python-trio/trio
Maybe rework run_in_worker_thread API for cancellation handling?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
Right now we just have a boolean flag, and it's name is maybe a bit misleading. Maybe it would be better to make it like:
run_in_worker_thread(..., on_cancel="abandon" or "carry-on")
and maybe there should be some option beyond these for actually signaling the thread? Like you can say on_cancel=my_list and we'll append something to the list if you're cancelled so you can occasionally do if my_list: abort()? Or maybe even append the cancel raiser function so it's like if my_list: my_list[0]()? But really this shouldn't be used for complex operations that are frequently returning to Python mode to check a value like this...
Even if we only want those two options for run_in_worker_thread, we probably want more options for the eventual run_in_worker_process -- like on_cancel="kill".
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 locating run_in_worker_thread and its current boolean cancellation handling. Review the cancellation behavior described here and determine a settled API and completion criteria; the issue does not name files or tests, and its alternatives need maintainer agreement before implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100