🚨 Websocket connection does not send response to client till all messages are received from generator function #11723
Unanswered
asifrahaman13
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Thje query function file
Description
Hello I am trying to stream response from Open AI. I am using the yield method to do so. However even though the response is getting the streaming data it is not sending the data to client immediately. It is waiting for all the generator to complete first and then it is sending them in one go.
The lines on which it is blocking is:
Note that the response is being received as stream only. But it is not sending anything to the client unless all the messages are being received from the get_query method.
The get_query function:
Interestingly if I use some other websocket library and create a echo server it works perfectly.
Operating System
Linux
Operating System Details
Linux OS
UBUNTU 24 LTS version
FastAPI Version
0.111.0
Pydantic Version
2.7.3
Python Version
Python 3.12.3
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions