错误描述
我注意到在 #11513 之后,我的 OpenSearch 向量存储连接变得不稳定,我们可以通过最近与此问题相关的 bug 报告来确认这一点( #13358 , #11661 等)
- 此事件循环已经在运行。
- ConnectionError(Timeout context manager 应该在任务内部使用)导致的:RuntimeError(Timeout context manager 应该在任务内部使用)
- 等等
我还看到建议使用 asyncio,但即使使用它,我们仍然可能会遇到错误
import nest_asyncio
nest_asyncio.apply()
我还注意到,当我们在 FastAPI 中使用 LlamaIndex 时,这个错误会变得更糟。
版本
最新版本
重现步骤
只需使用 OpenSearch 向量存储足够长的时间,你就会注意到它变得不稳定。
相关日志/回溯
- 无响应*
3条答案
按热度按时间ryhaxcpt1#
为了解决在实施 #11513 后 OpenSearch vector store 的连接问题,特别是在使用 FastAPI 和 LlamaIndex 时,你需要确保 FastAPI 上下文中正确管理事件循环。你遇到的错误,如 "This event loop is already running" 和 "ConnectionError(Timeout context manager should be used inside a task) caused by: RuntimeError(Timeout context manager should be used inside a task)",通常与异步操作处理不当有关。
以下是处理事件循环的一种修订方法:
asyncio.run
管理异步操作的事件循环。以下是如何修改代码以解决这些问题的示例:
这种方法确保事件循环得到妥善管理,避免了 "This event loop is already running" 和 "ConnectionError(Timeout context manager should be used inside a task) caused by: RuntimeError(Timeout context manager should be used inside a task)" 错误。
如果问题仍然存在,请提供更具体的日志或回溯信息以进一步诊断问题。
详细信息
来源
关于 Dosu
此响应旨在帮助您节省时间并提高效率。它不是精确的解决方案,而是你自己研究的一个起点。
帮助我变得更有用!如果这有帮助,请留下一个 👍 如果无关紧要,请留下一个 👎。
sbtkgmzw2#
在这个矢量存储中支持异步会很好。如果你有任何改进的想法,欢迎提交PR😇
6ie5vjzr3#
我同意异步,但我认为如果这些更改是向后兼容的或者至少是可选的,那就太好了,这样就不会破坏现有的实现。
不幸的是,我对OpenSearch连接或Python异步处理不是很擅长,所以我无法帮助解决这个问题。