我有以下简化的代码:
async def asynchronous_function(*args, **kwds):
statement = await prepare(query)
async with conn.transaction():
async for record in statement.cursor():
??? yield record ???
...
class Foo:
def __iter__(self):
records = ??? asynchronous_function ???
yield from records
...
x = Foo()
for record in x:
...
我不知道如何填写上面的???
。 我想得到记录数据,但是如何包装asyncio代码并不明显。
async for record in x
替换for record in x
是否可行? - Vincent