Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- import abc
- import contextlib
- from typing import AsyncIterator
- class Test(abc.ABC):
- @abc.abstractmethod
- async def request(self) -> AsyncIterator:
- pass
- class SubTest(Test):
- @contextlib.asynccontextmanager
- async def request(self) -> AsyncIterator:
- await asyncio.sleep(1)
- yield 1
- await asyncio.sleep(1)
- async def main():
- obj = SubTest()
- async with obj.request() as res:
- print(res)
- asyncio.run(main())
Add Comment
Please, Sign In to add comment