-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: RouterQueryEngine.aquery with multiple async engines raise Detected nested async
error
#17349
Comments
Hey @bkfox! 👋 I'm here to help you with any bugs, questions, or contributions you have regarding this project. Let's work together to solve this issue! The To work around this issue, you can try the following:
These approaches should help mitigate the issue until a more permanent fix is implemented in the library. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Hmm ill take a look. But the workaround here is just |
It should also be an easy pr to use asyncio gather |
Easier would be: It seems that similar issue exists also in # this calls: AsyncStreamingResponse.__str__ => asyncio_run(AsyncStreamingResponse._async_str)
response_strs.append(str(response)) Workaround: I just tested both, it seems to work (but other issues raised in the flow). BTW, |
Okay, after lots of tries and tests, it seems that:
|
Bug Description
I'm using RouterQueryEngine with two engines that are using async. When I run
aquery
from an async function (in pytest context), I've got aRuntimeError: Detected nested async
.After some investigation, it seems that the call of
run_async_tasks
from theRouterQueryEngine._aquery
is the reason why it raises the error:_aquery
is an async function, when awaited, it means that the event loop is already running;run_async_tasks
is a sync function that will try to get the loop. If the loop is already running (eg. awaited), it raises the error;run_async_tasks
is not called.I unfortunately can't give sample code here since i'm linked to non-discloure agreement.
Version
0.10.50
Steps to Reproduce
engine_N
) with async, in pytest testsRouterQueryEngine
router_engine
initialized withquery_engine_tools=[engine_1, engine_2]
Relevant Logs/Tracbacks
No response
The text was updated successfully, but these errors were encountered: