Repository navigation
asyncio thread-safety issues in the free-threaded build #120974
Copy link
Copy link
Closed
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixestopic-asynciotopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes
on Jun 24, 2024 I think that the pure Python fallback isn't thread safe either, FWIW I think there are more thread safety issues than these, asyncio code was written with assumption of GIL.
asyncio code was written with assumption of GIL.
Yeah, but for landing PEP 703, we are trying to change modules, not depending on the GIL, even if we need to re-write some parts of the implementation with a conditional flag. (If the new written part requires some performance overhead)
- added a commit that references this issue
on Jul 23, 2024 - added a commit that references this issue
on Jul 23, 2024 6 remaining items
- added 4 commits that reference this issue
on Jul 24, 2024 - added a commit that references this issue
on Aug 2, 2024 - added a commit that references this issue
on Aug 2, 2024
Metadata
Metadata
Assignees
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixestopic-asynciotopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
- StatusShow more project fieldsDone
Bug report
fi_freelistisn't thread-safe (move topycore_freelist.hand follow that pattern)enter_task,leave_task, andswap_current_taskaren't thread-safe due to sharedstate->current_tasksand borrowed references.register_taskandunregister_taskaren't thread-safe due to sharedstate->asyncio_taskslinked list_asyncio_all_tasks_implisn't thread-safe due the theasyncio_taskslinked list.For 2, 3, and 4, we can consider using critical sections to protect the accesses to
state->current_tasksandstate->asyncio_tasks.Longer term, moving data to per-loop will probably help with multi-threaded scaling.
Linked PRs
swap_current_tasksafe in free-threaded build #122317swap_current_tasksafe in free-threaded build (GH-122317) #122612