Title: Dict watcher API is not thread-safe in free-threaded builds · Issue #145235 · python/cpython · GitHub
Open Graph Title: Dict watcher API is not thread-safe in free-threaded builds · Issue #145235 · python/cpython
X Title: Dict watcher API is not thread-safe in free-threaded builds · Issue #145235 · python/cpython
Description: Bug report Bug description: PyDict_AddWatcher, PyDict_ClearWatcher, PyDict_Watch, PyDict_Unwatch, and _PyDict_SendEvent are not safe to call concurrently in free-threaded builds. The shared callback array and per-dict _ma_watcher_tag can...
Open Graph Description: Bug report Bug description: PyDict_AddWatcher, PyDict_ClearWatcher, PyDict_Watch, PyDict_Unwatch, and _PyDict_SendEvent are not safe to call concurrently in free-threaded builds. The shared callbac...
X Description: Bug report Bug description: PyDict_AddWatcher, PyDict_ClearWatcher, PyDict_Watch, PyDict_Unwatch, and _PyDict_SendEvent are not safe to call concurrently in free-threaded builds. The shared callbac...
Opengraph URL: https://github.com/python/cpython/issues/145235
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Dict watcher API is not thread-safe in free-threaded builds","articleBody":"# Bug report\n\n### Bug description:\n\n`PyDict_AddWatcher`, `PyDict_ClearWatcher`, `PyDict_Watch`, `PyDict_Unwatch`, and `_PyDict_SendEvent` are not safe to call concurrently in free-threaded builds. The shared callback array and per-dict _ma_watcher_tag can race when watchers are registered, removed, or triggered from multiple threads.\n\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-145233\n* gh-149690\n* gh-149691\n\u003c!-- /gh-linked-prs -->\n\n\n---\nNote: Running `test.test_free_threading.test_dict_watcher` (added in #145233) emits tsan warnings in the free-threaded tsan build.","author":{"url":"https://github.com/yoney","@type":"Person","name":"yoney"},"datePublished":"2026-02-25T21:32:46Z","url":"https://github.com/python/cpython/issues/145235"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:5c72e0df-05af-ce43-da05-531b531500d1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D022:CE438:109044F:1625EA2:6B01F359 |
| html-safe-nonce | a13e6be8924083d02d45e816bb9003cfa9546625d734d8f04ee32c34b7b4235f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDIyOkNFNDM4OjEwOTA0NEY6MTYyNUVBMjo2QjAxRjM1OSIsInZpc2l0b3JfaWQiOiI1NTg1NDQ1ODI0NTI1MTAzOTYxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ff96dc92dba1fbe0a3243d1cf0487db22623d12410179b9dc0f996bcada2c87d |
| hovercard-subject-tag | issue:3991947260 |
| 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/145235/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3a8bd68b73a6bd33bc1aeb2c7e34e7e5cb928dc14b1b2d6be1351964eaa49408/python/cpython/issues/145235 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3a8bd68b73a6bd33bc1aeb2c7e34e7e5cb928dc14b1b2d6be1351964eaa49408/python/cpython/issues/145235 |
| og:image:alt | Bug report Bug description: PyDict_AddWatcher, PyDict_ClearWatcher, PyDict_Watch, PyDict_Unwatch, and _PyDict_SendEvent are not safe to call concurrently in free-threaded builds. The shared callbac... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yoney |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width