Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-122957: Fix test flakiness in asyncio test in free-thread build (G…
…H-124039)

(cherry picked from commit eadb966)

Co-authored-by: Loïc Estève <loic.esteve@ymail.com>
  • Loading branch information
lesteve authored and miss-islington committed Sep 13, 2024
commit 12e9afa18e3d71c752c7fbd0077ac309bedf1deb
6 changes: 4 additions & 2 deletions Lib/test/test_asyncio/test_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ 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):
fut = asyncio.to_thread(func)
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.
Expand Down