You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<neo4j._async_compat.concurrency.AsyncRLock object at 0x7f4337d148b0 [locked count=1 waiters=60 owner=<Task pending name='Task-21597' coro=<Neo4JStorage.get_node() running at /home/user/LightRAG/lightrag/kg/neo4j_impl.py:98> wait_for=<Future pending cb=[_chain_future.<locals>._call_check_cancel() at /home/user/.conda/envs/python3.10/lib/python3.10/asyncio/futures.py:385, Task.__wakeup()]> cb=[gather.<locals>._done_callback() at /home/yangyang/.conda/envs/python3.10/lib/python3.10/asyncio/tasks.py:720]>]> is bound to a different event loop
Hello, we tried to solve the issue.你好,我们尝试解决了这个问题。
This is what we did:这便是我们所做的:
Modify the query handling in the FastAPI server to properly handle concurrent requests using asyncio. This involves updating the query endpoint to use the asynchronous version of LightRAG's query method and ensuring consistent event loop usage.修改 FastAPI 服务器中的查询处理,使用 asyncio 正确处理并发请求。这涉及更新查询端点以使用 LightRAG 查询方法的异步版本,并确保一致的事件循环使用。
Disclaimer: The concept of solution was created by AI and you should never copy paste this code before you check the correctness of generated code. Solution might not be complete, you should use this code as an inspiration only.免责声明:解决方案由 AI 创造,你应在使用此代码之前检查生成代码的正确性。此解决方案可能不完整,仅供您参考使用。
If you no longer want Latta AI to attempt solving issues on your repository, you can block this account.如果你不再希望 Latta AI 尝试解决你仓库中的问题,你可以屏蔽这个账号。
部署好lightrag_api_openai_compatible_demo.py之后,测试单个调用没有问题。然后部署之后,多个人同时调用会报错,我本地写了一个同时发送十个请求,也会报错。
报错内容大致是:
我本地启动时,略微修改了一下lightrag_api_openai_compatible_demo.py中初始化LightRAG部分代码,主要是加上了Neo4j
其余部分没有改动。
我对python异步不是很了解,大致排查了一下报错的原因。
首先看一下query接口的源代码:
这里获取当前事件循环,然后在将rag的同步查询封装后使用异步的方式等待结果。
但是这个rag.query方法的内部:
再通过事件循环去执行了一个异步方法。而这里获取事件循环的逻辑是always_get_an_event_loop,这个方法中如果出现异常的会新建一个事件循环,应该就是这里导致的。
我是先把api查询接口的代码改了一下,目前可以正常多人调用,就是直接调用这个aquery的异步方法,这样不会导致使用两个不同的事件循环获取同一资源的问题。
我对Python异步不太了解,但是我估计这个方法不是最合适的方式,希望作者有时间可以修复一下~
The text was updated successfully, but these errors were encountered: