diff --git a/aiohttp/helpers.py b/aiohttp/helpers.py index a44a407fea2..cbfbb1e194e 100644 --- a/aiohttp/helpers.py +++ b/aiohttp/helpers.py @@ -63,10 +63,15 @@ from typing_extensions import ContextManager -all_tasks = asyncio.Task.all_tasks +def all_tasks( + loop: Optional[asyncio.AbstractEventLoop] = None +) -> Set['asyncio.Task[Any]']: + tasks = list(asyncio.Task.all_tasks(loop)) # type: ignore + return {t for t in tasks if not t.done()} + if PY_37: - all_tasks = getattr(asyncio, 'all_tasks') # use the trick to cheat mypy + all_tasks = getattr(asyncio, 'all_tasks') # noqa _T = TypeVar('_T')