diff --git a/tests/conftest.py b/tests/conftest.py index 6946a605..0cd84d34 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -738,7 +738,10 @@ def _get_all_tasks() -> Set[asyncio.Task]: i = 0 while True: try: - tasks = list(asyncio.tasks._all_tasks) + if sys.version_info >= (3, 12): + tasks = asyncio.tasks._eager_tasks | set(asyncio.tasks._scheduled_tasks) + else: + tasks = list(asyncio.tasks._all_tasks) except RuntimeError: i += 1 if i >= 1000: