GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-121621: Move asyncio freelist to thread state by Fidget-Spinner · Pull Request #121915 · python/cpython

Conversation

@Fidget-Spinner

@Fidget-Spinner Fidget-Spinner commented Jul 17, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: asyncio module state should be locked with mutexes in free-threaded builds #121621

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Fidget-Spinner added 12 commits July 11, 2024 20:20
@Fidget-Spinner
Use PyMutex for writes to asyncio state
4822190
@Fidget-Spinner
Address review
143747b
@Fidget-Spinner
fix default build
580304c
@Fidget-Spinner
Fix typo
1faed12
@Fidget-Spinner
Address review
ba3d771
@Fidget-Spinner
fixup whitespace
ec2c175
@Fidget-Spinner
minor nit
e1b730a
@Fidget-Spinner
Move asyncio freelist to per-thread
f9fb6e1
@Fidget-Spinner
Move running loop to thread state
c9ac6bb
@Fidget-Spinner
Merge remote-tracking branch 'upstream/main' into asyncio_rest_thread…
b450b96
…safe
@Fidget-Spinner
Merge remote-tracking branch 'upstream/main' into asyncio_clear_freelist
b3aa591
@Fidget-Spinner
remove freelist tracking
e514426
@Fidget-Spinner
Fidget-Spinner requested review from 1st1, asvetlov, ericsnowcurrently, gvanrossum, kumaraditya303 and willingc as code owners July 17, 2024 14:18
@bedevere-app bedevere-app Bot mentioned this pull request Jul 17, 2024
asyncio module state should be locked with mutexes in free-threaded builds #121621
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Jul 17, 2024
@Fidget-Spinner
Fidget-Spinner requested a review from colesbury July 17, 2024 14:18
@Fidget-Spinner Fidget-Spinner added skip news topic-free-threading labels Jul 17, 2024
Fidget-Spinner
Fidget-Spinner commented Jul 17, 2024
View reviewed changes
Comment thread Include/internal/pycore_freelist.h
static inline void
_PyAsyncModule_ClearFreeLists(struct _Py_object_freelists *freelists, int is_finalization)
{
#ifdef WITH_FREELISTS

@Fidget-Spinner Fidget-Spinner Jul 17, 2024

Copy link
Copy Markdown
Member Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Fidget-Spinner
Fidget-Spinner commented Jul 17, 2024
View reviewed changes
Comment thread Include/internal/pycore_freelist.h
extern void _PyObjectStackChunk_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization);

// Keep in sync with _asynciomodule.c !
typedef struct futureiterobject_dummy {

@Fidget-Spinner Fidget-Spinner Jul 17, 2024

Copy link
Copy Markdown
Member Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@colesbury colesbury Jul 17, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Fidget-Spinner reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@Fidget-Spinner Fidget-Spinner Jul 18, 2024

Copy link
Copy Markdown
Member Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Fidget-Spinner
cleanup
7786eeb
@Fidget-Spinner Fidget-Spinner closed this Jul 18, 2024
@Fidget-Spinner Fidget-Spinner removed the topic-free-threading label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@1st1 1st1 Awaiting requested review from 1st1 1st1 is a code owner
@asvetlov asvetlov Awaiting requested review from asvetlov asvetlov is a code owner
@gvanrossum gvanrossum Awaiting requested review from gvanrossum
@kumaraditya303 kumaraditya303 Awaiting requested review from kumaraditya303 kumaraditya303 is a code owner
@willingc willingc Awaiting requested review from willingc willingc is a code owner
@colesbury colesbury Awaiting requested review from colesbury

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Fidget-Spinner @colesbury
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.