-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-121621: Move asyncio freelist to thread state #121915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-121621: Move asyncio freelist to thread state #121915
Conversation
Fidget-Spinner
commented
Jul 17, 2024
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Issue: asyncio module state should be locked with mutexes in free-threaded builds #121621
static inline void | ||
_PyAsyncModule_ClearFreeLists(struct _Py_object_freelists *freelists, int is_finalization) | ||
{ | ||
#ifdef WITH_FREELISTS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does anyone with better freelist internals knowledge know why this happens:
When I remove this function's body, the refleak tests pass. Otherwise they currently fail.
@@ -147,6 +156,39 @@ extern void _PyAsyncGen_ClearFreeLists(struct _Py_object_freelists *freelists, i | |||
extern void _PyContext_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization); | |||
extern void _PyObjectStackChunk_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization); | |||
|
|||
// Keep in sync with _asynciomodule.c ! | |||
typedef struct futureiterobject_dummy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned by Sam we should try to find a way to avoid this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we go with #121934, then that will make the asyncio freelist implementation a lot easier and will avoid a lot of these warts.
Maybe, in the meantime, we should just disable the freelist in the free-threaded build? That would be a much smaller change and wouldn't introduce duplicate types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could backport the disabling of freelist in the free-threaded build to 3.13 to fix the race conditions.