asyncio currently stores the current task in a global dict _current_tasks and on thread state. Storing it on dict in free-threading will cause significant contention under many threads and such I propose to remove it and always rely on the task stored on the thread state.
This has the added benefit that external introspection will always have the correct task and it will be guaranteed by this implementation while also being performant.
cc @asvetlov @ambv @pablogsal
Linked PRs
asynciocurrently stores the current task in a global dict_current_tasksand on thread state. Storing it on dict in free-threading will cause significant contention under many threads and such I propose to remove it and always rely on the task stored on the thread state.This has the added benefit that external introspection will always have the correct task and it will be guaranteed by this implementation while also being performant.
cc @asvetlov @ambv @pablogsal
Linked PRs