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
10 changes: 7 additions & 3 deletions Lib/test/test_asyncio/test_free_threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ def runner():
def test_all_tasks_different_thread(self) -> None:
loop = None
started = threading.Event()

done = threading.Event() # used for main task not finishing early
async def coro():
await asyncio.sleep(0.01)
await asyncio.Future()

lock = threading.Lock()
tasks = set()
Expand All @@ -77,6 +77,7 @@ async def main():
with lock:
asyncio.create_task(coro())
tasks = self.all_tasks(loop)
done.wait()

runner = threading.Thread(target=lambda: asyncio.run(main()))

Expand All @@ -86,11 +87,14 @@ def check():
self.assertSetEqual(tasks & self.all_tasks(loop), tasks)

threads = [threading.Thread(target=check) for _ in range(10)]
threads.append(runner)
runner.start()

with threading_helper.start_threads(threads):
pass

done.set()
runner.join()

def test_run_coroutine_threadsafe(self) -> None:
results = []

Expand Down
Loading