28 May 2025
xris不是,我是指两个 async for 的列表推导式能不能并发
itertools.chain 不行的,我搜了一下得找第三方库了,小脚本,不想装,就算了
import asyncio
async def collect_from_generator(gen):
return [item async for item in gen]
async def concurrent_example():
# 并发执行两个异步生成器
result1, result2 = await asyncio.gather(
collect_from_generator(async_generator1()),
collect_from_generator(async_generator2())
)
xristext not yet in the index
能这样写吗?
[item async for item in itertools.chain([get_document_a(), get_document_b()])]