cpython
cpython copied to clipboard
asyncio module state should be locked with mutexes in free-threaded builds
Feature or enhancement
Proposal:
Please see issue title.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
- gh-121622
- gh-121695
- gh-121774
I think we also want to make enter_task, leave_task, and swap_current_task behave atomically. For example, enter_task makes two dict API calls that individually lock the dictionary, but the combined operation isn't atomic.
I can think of two strategies for this:
- Try to replace multiple API calls with a single call. For example, I think
enter_taskmay be able to usePyDict_SetDefaultRefandleave_taskmay be able to use_PyDict_DelItemIfwith some modifications. - Use a critical section to lock the dict and use the "lock held" variants.
Fixed.