diff --git a/demo.py b/demo.py index 339f052..0070871 100644 --- a/demo.py +++ b/demo.py @@ -47,3 +47,4 @@ async def main(): asyncio.run(main()) +taskgroup.run(main()) diff --git a/taskgroup/tasks.py b/taskgroup/tasks.py index f409a94..88d5d10 100644 --- a/taskgroup/tasks.py +++ b/taskgroup/tasks.py @@ -4,7 +4,7 @@ import collections.abc import contextvars from typing import Any, Optional, Union -from typing_extensions import TypeAlias, TypeVar +from typing_extensions import TypeAlias, TypeVar, Self import sys _YieldT_co = TypeVar("_YieldT_co", covariant=True) @@ -50,6 +50,9 @@ def throw(self, *exc_info) -> _YieldT_co: def __getattr__(self, name): return getattr(self.__coro, name) + def __await__(self) -> Self: + return self + def close(self) -> None: super().close()