1# test basic async for execution 2# example taken from PEP0492 3 4class AsyncIteratorWrapper: 5 def __init__(self, obj): 6 print('init') 7 self._it = iter(obj) 8 9 def __aiter__(self): 10 print('aiter') 11 return self 12 13 async def __anext__(self): 14 print('anext') 15 try: 16 value = next(self._it) 17 except StopIteration: 18 raise StopAsyncIteration 19 return value 20 21async def coro(): 22 async for letter in AsyncIteratorWrapper('abc'): 23 print(letter) 24 25o = coro() 26try: 27 o.send(None) 28except StopIteration: 29 print('finished') 30