Currently the current task of a loop in stored in a global dict mapping loops to their corresponding current tasks.
|
/* Dictionary containing tasks that are currently active in |
|
all running event loops. {EventLoop: Task} */ |
|
PyObject *current_tasks; |
|
|
|
/* WeakSet containing scheduled 3rd party tasks which don't |
However this will perform poorly in free threading build as such I propose to store it in on the loop itself.
See https://discuss.python.org/t/store-current-task-on-the-loop/75926
Linked PRs
Currently the current task of a loop in stored in a global dict mapping loops to their corresponding current tasks.
cpython/Modules/_asynciomodule.c
Lines 100 to 104 in 8d16919
However this will perform poorly in free threading build as such I propose to store it in on the loop itself.
See https://discuss.python.org/t/store-current-task-on-the-loop/75926
Linked PRs