daily pastebin goal
35%
SHARE
TWEET

Untitled

a guest Jan 15th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import asyncio
  2. import abc
  3. import contextlib
  4. from typing import AsyncIterator
  5.  
  6.  
  7. class Test(abc.ABC):
  8.     @abc.abstractmethod
  9.     async def request(self) -> AsyncIterator:
  10.         pass
  11.  
  12.  
  13. class SubTest(Test):
  14.     @contextlib.asynccontextmanager
  15.     async def request(self) -> AsyncIterator:
  16.         await asyncio.sleep(1)
  17.         yield 1
  18.         await asyncio.sleep(1)
  19.  
  20.  
  21. async def main():
  22.     obj = SubTest()
  23.     async with obj.request() as res:
  24.         print(res)
  25.  
  26.  
  27. asyncio.run(main())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top