async def gen(): for i in range(3): yield i async def main(): total = 0 async for x in gen(): total += x print(total) asyncio.run(main())