假设我有两个异步生成器:
async def get_rules():
while True:
yield 'rule=1'
asyncio.sleep(2)
async def get_snapshots():
while True:
yield 'snapshot=1'
asyncio.sleep(5)
我希望将它们合并成一个异步生成器,返回含有两个值的二元组,这两个值都是最新的。类似于
combineLatest
的功能。那么,最好的方法是什么?