From 4ecb354e4c727adc9bb6fe43c2e7f43bf11998da Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Fri, 24 Jan 2025 17:14:11 +0000 Subject: [PATCH] fix test --- Lib/test/test_asyncio/test_free_threading.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_asyncio/test_free_threading.py b/Lib/test/test_asyncio/test_free_threading.py index c91719cb577c2f..6da398e77e7797 100644 --- a/Lib/test/test_asyncio/test_free_threading.py +++ b/Lib/test/test_asyncio/test_free_threading.py @@ -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() @@ -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())) @@ -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 = [] pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy