[3.13] gh-122957: Fix test flakiness in asyncio test in free-thread build (GH-124039) (#124067)

gh-122957: Fix test flakiness in asyncio test in free-thread build (GH-124039)
(cherry picked from commit eadb9660ed)

Co-authored-by: Loïc Estève <loic.esteve@ymail.com>
This commit is contained in:
Miss Islington (bot) 2024-09-23 20:07:41 +02:00 committed by GitHub
parent 72139f276e
commit 4cd4bf10be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -30,7 +30,9 @@ async def test_to_thread_once(self):
func.assert_called_once()
async def test_to_thread_concurrent(self):
func = mock.Mock()
calls = []
def func():
calls.append(1)
futs = []
for _ in range(10):
@ -38,7 +40,7 @@ async def test_to_thread_concurrent(self):
futs.append(fut)
await asyncio.gather(*futs)
self.assertEqual(func.call_count, 10)
self.assertEqual(sum(calls), 10)
async def test_to_thread_args_kwargs(self):
# Unlike run_in_executor(), to_thread() should directly accept kwargs.