Skip to content

Make generator methods gen_set_name and gen_set_qualname thread-safe in free-threaded builds #133931

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

Open
efimov-mikhail opened this issue May 12, 2025 · 1 comment
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-free-threading type-feature A feature request or enhancement

Comments

@efimov-mikhail
Copy link
Contributor

efimov-mikhail commented May 12, 2025

Feature or enhancement

Proposal:

When my PR was reviewed, some problem was found: #133373 (comment)
But my code on _GeneratorWrapper was simply copied from gen_set_name method.

So, it seems that there is no critical section in genobject.c at all.
But there is a possibility to change name or qualname for generator/async generator/coroutine.
IMO, some simple code (Py_BEGIN_CRITICAL_SECTION and Py_END_CRITICAL_SECTION) should be added to these two methods.

Also, function object seems to have exactly the same problem.

Linked PRs

@efimov-mikhail efimov-mikhail added the type-feature A feature request or enhancement label May 12, 2025
@picnixz picnixz added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label May 15, 2025
@xuantengh
Copy link
Contributor

Also, function object seems to have exactly the same problem.

Regarding function object, there was a discussion about the lock on the performance-critical fields that will be accessed during a function call:
#129016 (review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-free-threading type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

5 participants