FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-128002: fix `test_all_tasks_different_thread` in asyncio by kumaraditya303 · Pull Request #129267 · python/cpython · GitHub

/ cpython Public
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
10 changes: 7 additions & 3 deletions Lib/test/test_asyncio/test_free_threading.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL