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/
 
 
 

posted @ 2025-12-12 20:19  blcblc  阅读(2)  评论(0)    收藏  举报