python-trio / python-trio/trio
Maybe make task-local storage work from run_in_worker_thread functions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
This is handy for logging, and safe because we know that either the task or the thread is running, but never both - so no locking is needed. But maybe confusing (it can't work for run-locals, or run_in_worker_process)?
What should current_task() return in a run_in_worker_thread function? Currently we effectively find the task-locals by looking up the current task, so the most naive way to make task-locals work would to make current_task() work and then task-locals would work for free. Is that good or bad?
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 the behavior of current_task() and task-local storage when called from run_in_worker_thread functions, and compare it with run_in_worker_process. Define and verify the intended behavior for task-locals and current_task(), including what should happen in worker-thread and worker-process functions.
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