Title: `asyncio` thread-safety issues in the free-threaded build · Issue #120974 · python/cpython · GitHub
Open Graph Title: `asyncio` thread-safety issues in the free-threaded build · Issue #120974 · python/cpython
X Title: `asyncio` thread-safety issues in the free-threaded build · Issue #120974 · python/cpython
Description: Bug report fi_freelist isn't thread-safe (move to pycore_freelist.h and follow that pattern) enter_task, leave_task, and swap_current_task aren't thread-safe due to shared state->current_tasks and borrowed references. register_task and u...
Open Graph Description: Bug report fi_freelist isn't thread-safe (move to pycore_freelist.h and follow that pattern) enter_task, leave_task, and swap_current_task aren't thread-safe due to shared state->current_tasks and ...
X Description: Bug report fi_freelist isn't thread-safe (move to pycore_freelist.h and follow that pattern) enter_task, leave_task, and swap_current_task aren't thread-safe due to shared state->current...
Opengraph URL: https://github.com/python/cpython/issues/120974
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`asyncio` thread-safety issues in the free-threaded build","articleBody":"# Bug report\r\n\r\n1. `fi_freelist` isn't thread-safe (move to `pycore_freelist.h` and follow that pattern)\r\n2. `enter_task`, `leave_task`, and `swap_current_task` aren't thread-safe due to shared `state-\u003ecurrent_tasks` and borrowed references. \r\n3. `register_task` and `unregister_task` aren't thread-safe due to shared `state-\u003easyncio_tasks` linked list\r\n4. `_asyncio_all_tasks_impl` isn't thread-safe due the the `asyncio_tasks` linked list.\r\n\r\nFor 2, 3, and 4, we can consider using critical sections to protect the accesses to `state-\u003ecurrent_tasks` and `state-\u003easyncio_tasks`.\r\n\r\nLonger term, moving data to per-loop will probably help with multi-threaded scaling.\r\n\r\n\u003c!-- gh-linked-prs --\u003e\r\n### Linked PRs\r\n* gh-122132\r\n* gh-122138\r\n* gh-122139\r\n* gh-122152\r\n* gh-122186\r\n* gh-122317\r\n* gh-122612\n* gh-122801\n\u003c!-- /gh-linked-prs --\u003e\r\n","author":{"url":"https://github.com/colesbury","@type":"Person","name":"colesbury"},"datePublished":"2024-06-24T21:49:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/120974/cpython/issues/120974"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0c1dd6d9-c864-d84f-e933-558803a62b87 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9B78:21F2BE:E3C6C1:140156D:696A26CE |
| html-safe-nonce | e4011e1c65f84d452af4c2eb61ddf0ea770c3db24cb6685ac9948ce7c981698a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Qjc4OjIxRjJCRTpFM0M2QzE6MTQwMTU2RDo2OTZBMjZDRSIsInZpc2l0b3JfaWQiOiI2NTY1Mzk4NjA5NjAxNTk0MzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 01c71d7d3968f3ff468b12d5a318ceaa52434d37f2220bb80a2bf15d547df33a |
| hovercard-subject-tag | issue:2371165212 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/120974/issue_layout |
| twitter:image | https://opengraph.githubassets.com/49caf75a9fbae788028d43d0a8dae00dd03313bca727a28a46c51e42c4bdc1ce/python/cpython/issues/120974 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/49caf75a9fbae788028d43d0a8dae00dd03313bca727a28a46c51e42c4bdc1ce/python/cpython/issues/120974 |
| og:image:alt | Bug report fi_freelist isn't thread-safe (move to pycore_freelist.h and follow that pattern) enter_task, leave_task, and swap_current_task aren't thread-safe due to shared state->current_tasks and ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | colesbury |
| hostname | github.com |
| expected-hostname | github.com |
| None | a1022f03e4f0d91ea173e4e5dac892c982e0588c62f1ce56121d755a320a3569 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f472b8e6c7b3fdd5d0354972a3f4c516289bf0be |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width