Make generator methods gen_set_name and gen_set_qualname thread-safe in free-threaded builds #133931
Copy link
Copy link
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement
on May 12, 2025 - addedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
on May 15, 2025 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)Reacted by Mikhail Efimov
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement
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_namemethod.So, it seems that there is no critical section in
genobject.cat all.But there is a possibility to change
nameorqualnamefor generator/async generator/coroutine.IMO, some simple code (
Py_BEGIN_CRITICAL_SECTIONandPy_END_CRITICAL_SECTION) should be added to these two methods.Also,
function objectseems to have exactly the same problem.Linked PRs