Skip to content

Commit 4cd4bf1

Browse files
[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 eadb966) Co-authored-by: Loïc Estève <[email protected]>
1 parent 72139f2 commit 4cd4bf1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Lib/test/test_asyncio/test_threads.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ async def test_to_thread_once(self):
3030
func.assert_called_once()
3131

3232
async def test_to_thread_concurrent(self):
33-
func = mock.Mock()
33+
calls = []
34+
def func():
35+
calls.append(1)
3436

3537
futs = []
3638
for _ in range(10):
3739
fut = asyncio.to_thread(func)
3840
futs.append(fut)
3941
await asyncio.gather(*futs)
4042

41-
self.assertEqual(func.call_count, 10)
43+
self.assertEqual(sum(calls), 10)
4244

4345
async def test_to_thread_args_kwargs(self):
4446
# Unlike run_in_executor(), to_thread() should directly accept kwargs.

0 commit comments

Comments
 (0)