Description
We have several loop-scoped global variables now. Some are Python objects, but llist_node
is a plain C structure.
Let's make a super-base C Extension class where we can put all these objects (both python and plain C) and inherit BaseEventLoop from it.
I personally feel that we will have more loop-scoped things like llist_node
in the future; now is a good time to settle a place for them.
Originally posted by @asvetlov in #128416 (comment)
Metadata
Metadata
Assignees
Projects
Status
Activity
graingert commentedon Jan 8, 2025
Could you expose these so user code can use it? I'd like to implement RunVars - which are like ContextVars but for a particular asyncio.run. currently we use WeakKeyDictionaries from loop to object
We also use WeakKeyDictionaries to map from task to the CancelScope it's in. I'd like to make one WeakKeyDictionary per event loop rather than having one global one
kumaraditya303 commentedon Feb 9, 2025
Unfortunately we cannot do this or move current task to loop because the newly added external introspection rely on storing it on thread state.
I have another idea to fix this for free-threading I'll be posting that soon in a different issue.
cc @asvetlov
asvetlov commentedon Feb 9, 2025
@graingert could you elaborate?
In my mind, both selector and proctor asyncio event loops could derive from an opaque base class implemented in C. This class is a container for data required for futures, tasks, etc.
It is perhaps not what you need
kumaraditya303 commentedon May 16, 2025
The task linked list is per thread now so this isn't needed anymore, also moving data to per loop scoped variable would break the newly added external introspection so closing as won't fix.