ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

asyncio.run() cannot be called from a running event loop的解决方法

2026/8/17 8:47:24 拓冰建站 浏览量
asyncio.run() cannot be called from a running event loop的解决方法

# Run the agent
asyncio.run(main())

报错:

asyncio.run() cannot be called from a running event loop

 
import nest_asyncio
import asyncio
 
nest_asyncio.apply()
await main()
 
 
另外关于python async的介绍:
https://docs.llamaindex.org.cn/en/stable/getting_started/async_python/