Skip to content

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

Closed

Conversation

Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented Jul 17, 2024

static inline void
_PyAsyncModule_ClearFreeLists(struct _Py_object_freelists *freelists, int is_finalization)
{
#ifdef WITH_FREELISTS
Copy link
Member Author

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 {
Copy link
Member Author

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.

Copy link
Contributor

@colesbury colesbury Jul 17, 2024

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.

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants