Title: `test_asyncio` `test_to_thread_concurrent` flaky · Issue #122957 · python/cpython · GitHub
Open Graph Title: `test_asyncio` `test_to_thread_concurrent` flaky · Issue #122957 · python/cpython
X Title: `test_asyncio` `test_to_thread_concurrent` flaky · Issue #122957 · python/cpython
Description: The call_count counter on mock.Mock is not atomic, so updates may be lost: cpython/Lib/test/test_asyncio/test_threads.py Lines 32 to 41 in ab094d1 async def test_to_thread_concurrent(self): func = mock.Mock() futs = [] for _ in range(10)...
Open Graph Description: The call_count counter on mock.Mock is not atomic, so updates may be lost: cpython/Lib/test/test_asyncio/test_threads.py Lines 32 to 41 in ab094d1 async def test_to_thread_concurrent(self): func = ...
X Description: The call_count counter on mock.Mock is not atomic, so updates may be lost: cpython/Lib/test/test_asyncio/test_threads.py Lines 32 to 41 in ab094d1 async def test_to_thread_concurrent(self): func = ...
Opengraph URL: https://github.com/python/cpython/issues/122957
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`test_asyncio` `test_to_thread_concurrent` flaky","articleBody":"The `call_count` counter on `mock.Mock` is not atomic, so updates may be lost:\r\n\r\nhttps://github.com/python/cpython/blob/ab094d1b2b348f670743f88e52d1a3f2cab5abd5/Lib/test/test_asyncio/test_threads.py#L32-L41\r\n\r\nThis leads to occasional errors like:\r\n\r\n```\r\nFile \"Lib/test/test_asyncio/test_threads.py\", line 41, in test_to_thread_concurrent\r\nself.assertEqual(func.call_count, 10)\r\n~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^\r\nAssertionError: 9 != 10\r\n```\r\n\r\nI think the update is not actually atomic even with the GIL because of the use of `_delegating_property` in `Mock`, but I'm not entirely sure. The failures are definitely more likely to occur in the free-threaded build.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-124039\n* gh-124067\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/colesbury","@type":"Person","name":"colesbury"},"datePublished":"2024-08-12T19:22:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/122957/cpython/issues/122957"}
| 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:873139a0-9f96-3899-214b-d374ed3ea566 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A5DA:B267E:A0983D:DAEC67:6A51E5B2 |
| html-safe-nonce | a50cb8cf7c0f57b6ff5128159d0811f481e01bf2df644acbc13bcb90b8780adc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNURBOkIyNjdFOkEwOTgzRDpEQUVDNjc6NkE1MUU1QjIiLCJ2aXNpdG9yX2lkIjoiOTExMjE1ODQ1NjEyMzYxNDY0MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b63f5dc97d2d71fe40cfd3ecda888de9c1f0baed31c5d9dfe6227c94028d1fa4 |
| hovercard-subject-tag | issue:2461726896 |
| 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/122957/issue_layout |
| twitter:image | https://opengraph.githubassets.com/de6f5d89459f0198d7100244e0624b4a679620960e2352004a06ee7abdb77aac/python/cpython/issues/122957 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/de6f5d89459f0198d7100244e0624b4a679620960e2352004a06ee7abdb77aac/python/cpython/issues/122957 |
| og:image:alt | The call_count counter on mock.Mock is not atomic, so updates may be lost: cpython/Lib/test/test_asyncio/test_threads.py Lines 32 to 41 in ab094d1 async def test_to_thread_concurrent(self): func = ... |
| 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 | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width