forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a66dd3
commit f3642ae
Showing
3 changed files
with
813 additions
and
126 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import asyncio | ||
from test.support import threading_helper | ||
from unittest import TestCase | ||
from threading import Thread | ||
|
||
threading_helper.requires_working_threading(module=True) | ||
|
||
class TestFreeThreading(TestCase): | ||
def test_all_tasks_race(self) -> None: | ||
async def task(): | ||
await asyncio.sleep(0) | ||
|
||
async def main(): | ||
async with asyncio.TaskGroup() as tg: | ||
for _ in range(100): | ||
tg.create_task(task()) | ||
asyncio.all_tasks() | ||
|
||
threads = [] | ||
for _ in range(10): | ||
thread = Thread(target=lambda: asyncio.run(main())) | ||
threads.append(thread) | ||
|
||
with threading_helper.start_threads(threads): | ||
pass | ||
|
Oops, something went wrong.